/bin/rm: fix removing symlinks with uchg/uappnd set
authorJohn Marino <draco@marino.st>
Thu, 15 Nov 2012 23:31:35 +0000 (00:31 +0100)
committerJohn Marino <draco@marino.st>
Thu, 15 Nov 2012 23:44:56 +0000 (00:44 +0100)
commitcbe044e0f12b5ae86a47b7ec1bc61bbe0ad785ad
treeda593f948dd7c0d2e86c78594f05cfc0bd5dbf3f
parentfc8c7a91ff2e30d25ba17d9469e9f0ac19adba26
/bin/rm: fix removing symlinks with uchg/uappnd set

One error case described in FreeBSD PR bin/111226:
  /bin/rm when running as super user and failing to unlink a
  UF_APPEND|UF_IMMUTABLE protected symbolic link will reset the
  UF_APPEND and UF_IMMUTABLE flags on the symbolic link's target (if
  that target exists) - an object that /bin/rm should not touch! (Quote
  from SUSv3: "The rm utility removes symbolic links themselves, not
  the files they refer to, as a consequence of the dependence on the
  unlink() functionality").

There was a failure case for /usr/bin/find as well, but swildner
recently synchronized find with FreeBSD and fixed that one.

Taken-from: FreeBSD SVN 193087 (30 MAY 2009)
bin/rm/rm.c