Symbolic Link Permissions
Antoine Verheijen via rsync <[email protected]> Fri, 22 May 2026 18:09:42 -0600
| Newsgroups | gmane.network.rsync.general |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_12EF3510-B4BD-4D1B-AB77-6422889E0DA5
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
Please note: this is essentially a repeat of an item I submitted almost
a year ago when it received basically no notice. With the recent flurry
of activity, I'm hoping it might be considered for inclusion in an
upcoming release.
The included patch provides a compile-time option to use the POSIX
fchmodat() function to set permissions for a symbolic link (the link
itself, not its target). It only gets compiled in, as part of do_chmod()
in syscall.c, if setattrlist() does not exist and as a last resort before
failure would result for symbolic links.
It's not OS-specific, although I'll admit that OpenBSD is the only
system I've encountered to date that needs it. (On OpenBSD, this is the
ONLY item that prevents me from being able to make a perfect clone.)
It's small: 1 line change in configure.ac and 2 lines added in syscall.c.
It is intended for the rsync version just released ("3.5.x started").
I've been using it for more than a year and a half without issue. I've
also tried compilations with the patched code on a variety of other
systems (various Linux, MacOS, FreeBSD) where it (naturally) had no
effect since the new code was not compiled in.
Thanks so much for your attention. I look forward to hearing back (one
way or other other).
And thanks for all the great work on what is one of the truly great
utility tools in existence.
------------------------------------------------------------------------
Antoine Verheijen Email: [email protected]
. Phone: (780) 462-9696
--Apple-Mail=_12EF3510-B4BD-4D1B-AB77-6422889E0DA5
Content-Disposition: attachment;
filename=patch-symlink
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="patch-symlink"
Content-Transfer-Encoding: 7bit
diff --git a/configure.ac b/configure.ac
index 4062651d..3debbe01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -887,7 +887,7 @@ dnl AC_FUNC_MEMCMP
AC_FUNC_UTIME_NULL
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(waitpid wait4 getcwd chown chmod lchmod mknod mkfifo \
- fchmod fstat ftruncate strchr readlink link utime utimes lutimes strftime \
+ fchmod fchmodat fstat ftruncate strchr readlink link utime utimes lutimes strftime \
chflags getattrlist mktime innetgr linkat \
memmove lchown vsnprintf snprintf vasprintf asprintf setsid strpbrk \
strlcat strlcpy stpcpy strtol mallinfo mallinfo2 getgroups setgroups geteuid getegid \
diff --git a/syscall.c b/syscall.c
index e317bccc..f3a60e28 100644
--- a/syscall.c
+++ b/syscall.c
@@ -788,6 +788,8 @@ int do_chmod(const char *path, mode_t mode)
break;
if (errno == ENOTSUP)
code = 1;
+# elif defined HAVE_FCHMODAT
+ code = fchmodat(AT_FDCWD, path, mode & CHMOD_BITS, AT_SYMLINK_NOFOLLOW);
# else
code = 1;
# endif
--Apple-Mail=_12EF3510-B4BD-4D1B-AB77-6422889E0DA5
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
--Apple-Mail=_12EF3510-B4BD-4D1B-AB77-6422889E0DA5--