chown: work around OpenBSD bug
authorEric Blake <ebb9@byu.net>
Mon, 16 Nov 2009 21:35:41 +0000 (14:35 -0700)
committerEric Blake <ebb9@byu.net>
Wed, 18 Nov 2009 05:30:00 +0000 (22:30 -0700)
commit84405cbc35207f178b1b50617254cb85ea803128
treea6d4b75f1704db36681f0801e4e3d7c22fb89ebd
parent83e045030538b7838367305c0b92c7c756c90651
chown: work around OpenBSD bug

chown(name,geteuid(),-1) failed to update the change time if
name was already owned by the current effective user.  Work
around it by using chmod, which does not have this bug.

Unfortunately, lchown has the same bug, but OpenBSD 4.0 lacks
lchmod and lutimes, so there is no way to affect ctime without
unlinking and recreating the symlink, which is too dangerous.

* lib/chown.c (rpl_chown): Work around the bug.
* lib/lchown.c (rpl_lchown): Attempt to do likewise.
* m4/chown.m4 (gl_FUNC_CHOWN): Test for ctime bug.
* m4/lchown.m4 (gl_FUNC_LCHOWN): Check for lchmod.
* modules/chown (Depends-on): Add stdbool.
* modules/lchown (Depends-on): Likewise.
* doc/posix-functions/chown.texi (chown): Document the bug.
* doc/posix-functions/lchown.texi (lchown): Likewise.
* tests/test-lchown.h (test_chown): Relax test.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/posix-functions/chown.texi
doc/posix-functions/lchown.texi
lib/chown.c
lib/lchown.c
m4/chown.m4
m4/lchown.m4
modules/chown
modules/lchown
tests/test-lchown.h