home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / v21 / 041 / text0000.txt < prev   
Encoding:
Internet Message Format  |  1990-12-05  |  2.0 KB

  1. From:  Andy Tanenbaum <ast@cs.vu.nl>
  2.  
  3. While studying the P1003.2 description of the 'cp' utility, I ran into an
  4. ambiguity. In paragraph 4.13.2 (description), line 1985 & 1996-2000, it says:
  5.  
  6.     (1) If the destination path exists:
  7.  
  8.         (b) If the permissions of the file to which the destination path
  9.         refers to do not permit writing, actions are performed equivalent to
  10.         the unlink() #5.5.1[POSIX.1] function call using destination as the
  11.         path argument, and, if this fails for any reason...
  12.  
  13. In paragraph 4.13.3 (options), next page, lines 2010 & 2011 says:
  14.  
  15.     -f   For each existing destination pathname, remove it and create a new
  16.          file, without prompting for confirmation regardless of its permissions
  17.  
  18. Now, I believe that the description should say:
  19.  
  20.          (b) If the permissions of the file to which the destination path
  21.          refers to do not permit writing, or if the -f option is specified, ...
  22.  
  23. to be consistent, but then "cp -f" would snap any existing links to the 
  24. destination file, and even change the destination file mode, owner and group 
  25. (without a -p being specified), while "cp" wouldn't.
  26.  
  27. Example:
  28.  
  29. -rw-r--r-- 1   user1    group1         srcfile
  30. -rw-rw-rw- 2   user2    group2         dstfile
  31.  
  32. If user3 (group3) invokes cp srcfile dstfile, then the dstfile's mode, owner,
  33. group and links do not change. However, if cp -f srcfile dstfile is invoked,
  34. then the dstfile becomes:
  35.  
  36. -rw-r--r-- 1   user3    group3         dstfile
  37.  
  38. Now, this behavior might be correct, but is this effect really intended by
  39. P1003.2? Possibly, the user that wish to replace the dstfile entirely (as
  40. opposed to overwriting it) should use rm BEFORE calling cp, and the -f option
  41. should be used only to suppress interaction with the user.
  42.  
  43. Maybe draft 10 clarifies the situation?
  44.  
  45.  
  46. Vincent Archer             | Email:archer%segin4.segin.fr@relay.prime.com
  47. "People that are good at finding excuses are never good at anything else"
  48.  
  49.  
  50. (Posted by Andy Tanenbaum because Vincent does not have USENET access.)
  51.  
  52. Volume-Number: Volume 21, Number 41
  53.  
  54.