]> Savannah Git Hosting - gnulib.git/commit
fchmodat: AT_SYMLINK_NOFOLLOW fix for non-symlinks
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 8 Feb 2020 00:34:12 +0000 (16:34 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 8 Feb 2020 00:35:18 +0000 (16:35 -0800)
commitc483c787fcf4d98f9cf86e2422ba8e4e7226b6a1
tree16086d275465a988355d2e6d313ecacdcc5e49df
parent02c8a3da2c4462ecf78944af9f6fd2c986fa536c
fchmodat: AT_SYMLINK_NOFOLLOW fix for non-symlinks

Fix lchmod, and fchmodat with AT_SYMLINK_NOFOLLOW, so that
they act like chmod on non-symlinks.
* NEWS:
* doc/glibc-functions/lchmod.texi (lchmod):
* doc/posix-functions/fchmodat.texi (fchmodat):
Mention this.
* lib/fchmodat.c: Define __need_system_sys_stat_h before including
config.h, and undef it after including sys/stat.h the first time.
Include fcntl.h, stdio.h, unistd.h, intprops.h, and include
sys/stat.h a second time after defining orig_fchmodat.
(orig_fchmodat) [HAVE_FCHMODAT]: New function.
(fchmodat) [HAVE_FCHMODAT]: Work around the AT_SYMLINK_NOFOLLOW bug.
* lib/lchmod.c: New file.
* lib/sys_stat.in.h (fchmodat, lchmod):
Support replacing these functions.
* m4/fchmodat.m4 (gl_FUNC_FCHMODAT): If fchmodat exists,
test that AT_SYMLINK_NOFOLLOW works on non-symlinks.
* m4/lchmod.m4 (gl_FUNC_LCHMOD): Check for lstat.
Test that lchmod works on non-symlinks.
* m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS):
Default REPLACE_FCHMODAT and REPLACE_LCHMOD to 0.
* modules/fchmodat (Depends-on): Add fstatat, intprops, lchmod, unistd.
(Depends-on, configure.ac): Check REPLACE_FCHMODAT too.
* modules/lchmod (Files): Add lib/lchmod.c.
(Depends-on): Add errno, fcntl-h, fchmodat, intprops, lstat, unistd.
(configure.ac): Compile lchmod.c if needed.
(lib_SOURCES): Add lchmod.c.
* modules/sys_stat (sys/stat.h): Substitute REPLACE_FCHMODAT
and REPLACE_LCHMOD.
* tests/test-fchmodat.c: Include fcntl.h, sys/stat.h.
(main): Test fchmodat with AT_SYMLINK_NOFOLLOW on non-symlinks.
14 files changed:
ChangeLog
NEWS
doc/glibc-functions/lchmod.texi
doc/posix-functions/fchmodat.texi
lib/fchmodat.c
lib/lchmod.c [new file with mode: 0644]
lib/sys_stat.in.h
m4/fchmodat.m4
m4/lchmod.m4
m4/sys_stat_h.m4
modules/fchmodat
modules/lchmod
modules/sys_stat
tests/test-fchmodat.c