]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
io: Implement lchmod using fchmodat [BZ #14578]
authorFlorian Weimer <fweimer@redhat.com>
Wed, 22 Jan 2020 17:56:04 +0000 (18:56 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 12 Feb 2020 07:43:59 +0000 (08:43 +0100)
include/sys/stat.h
io/fchmodat.c
io/lchmod.c
sysdeps/mach/hurd/fchmodat.c
sysdeps/unix/sysv/linux/fchmodat.c

index b82d4527801d4797bcd18ba3729a96379163b044..92284ca48b5b3df56dc7f30045ad2f956a0070b7 100644 (file)
@@ -9,6 +9,7 @@ extern int __lstat (const char *__file, struct stat *__buf);
 extern int __chmod (const char *__file, __mode_t __mode);
 libc_hidden_proto (__chmod)
 extern int __fchmod (int __fd, __mode_t __mode);
+libc_hidden_proto (fchmodat)
 extern __mode_t __umask (__mode_t __mask);
 extern int __mkdir (const char *__path, __mode_t __mode);
 libc_hidden_proto (__mkdir)
index 7f3a07aaa2488bce11d011e08d81853f7d09284c..78895ac187e3f9474eb7a6959364992cf301c758 100644 (file)
@@ -42,3 +42,4 @@ fchmodat (int fd, const char *file, mode_t mode, int flag)
   return -1;
 }
 stub_warning (fchmodat)
+libc_hidden_def (fchmodat)
index 90b33a49f97b774427b7f5e9890074f12d358167..8b788034ee382630c070d9f4a163b8594c9bffee 100644 (file)
@@ -1,4 +1,4 @@
-/* lchmod -- Change the protections of a file or symbolic link.  Stub version.
+/* lchmod -- Change the protections of a file or symbolic link.  Generic version.
    Copyright (C) 2002-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <sys/stat.h>
+#include <fcntl.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 /* Change the protections of FILE to MODE.  */
 int
 lchmod (const char *file, mode_t mode)
 {
-  __set_errno (ENOSYS);
-  return -1;
+  return fchmodat (AT_FDCWD, file, mode, AT_SYMLINK_NOFOLLOW);
 }
-
-stub_warning (lchmod)
index cd227d5c831bc99e0072f9065db34a6f1ea1c5c6..d42f9520e9eadaea2acd70dcadd43a76c76faf40 100644 (file)
@@ -37,3 +37,4 @@ fchmodat (int fd, const char *file, mode_t mode, int flag)
     return __hurd_fail (err);
   return 0;
 }
+libc_hidden_def (fchmodat)
index 224439ffbae323ef162dfc53fc247cb8347ea02d..c41ebb290dab0075e54a04e98b916da811811350 100644 (file)
@@ -38,3 +38,4 @@ fchmodat (int fd, const char *file, mode_t mode, int flag)
 
   return INLINE_SYSCALL (fchmodat, 3, fd, file, mode);
 }
+libc_hidden_def (fchmodat)