Bug 19748

Summary: fetch -o will unlink special files
Product: Base System Reporter: lyonsm <lyonsm>
Component: binAssignee: Dag-Erling Smørgrav <des>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description lyonsm 2000-07-07 08:30:01 UTC
(This is arguably a change-request and not a sw-bug.)

In some circumstances, fetch -o will unlink the target file if a transfer
fails.  It's true that this behaviour can be suppressed with the -R
switch; however, fetch should probably never unlink special files or files
it didn't create (or other people who use fetch -o/dev/null in a script
might find themselves wondering why /dev/null keeps disappearing. :)

Fix: The following patch to src/usr.bin/fetch/util.c makes fetch
more careful about unlinking special files.  A better fix might
be to have fetch decline to unlink files it didn't create.

How-To-Repeat: 
As root, fetch an unreachable address to /dev/null, and then kill with
SIGINT before it times out:

  # cp -Rp /dev/null /tmp/mynull
  # fetch -o/tmp/mynull http://1.2.3.4/foo
  (wait a few sec, then hit CTRL-C)
  # ls -l /tmp/mynull
  (it's gone!)
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 2000-07-07 15:13:30 UTC
Responsible Changed
From-To: freebsd-bugs->des

DES will be interested in this observation. 

Note to the originator: don't expect anything to happen in 
a hurry.  DES is re-implementing fetch(1) in the 
development branch of FreeBSD at a moment, so it may be a while 
before you see any such change (if any change is made).
Comment 2 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2000-08-31 17:06:12 UTC
State Changed
From-To: open->feedback

Fixed in -CURRENT, awaiting MFC.
Comment 3 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2000-09-17 21:00:10 UTC
State Changed
From-To: feedback->closed

MFCed.