From: Wayne Davison Date: Tue, 16 Oct 2007 16:00:41 +0000 (+0000) Subject: Adding Wesley Terpstra's lchmod()-equivalent that uses setattrlist(). X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/11b02d927f2d809aeade01768b16b690220c1049 Adding Wesley Terpstra's lchmod()-equivalent that uses setattrlist(). --- diff --git a/syscall.c b/syscall.c index faa75c28..0dfcaa01 100644 --- a/syscall.c +++ b/syscall.c @@ -25,6 +25,9 @@ #if !defined MKNOD_CREATES_SOCKETS && defined HAVE_SYS_UN_H #include #endif +#ifdef HAVE_SYS_ATTR_H +#include +#endif extern int dry_run; extern int am_root; @@ -151,6 +154,14 @@ int do_chmod(const char *path, mode_t mode) if (S_ISLNK(mode)) { #ifdef HAVE_LCHMOD code = lchmod(path, mode & CHMOD_BITS); +#elif defined HAVE_SETATTRLIST + struct attrlist attrList; + uint32_t m = mode & CHMOD_BITS; /* manpage is wrong: not mode_t! */ + + memset(&attrList, 0, sizeof attrList); + attrList.bitmapcount = ATTR_BIT_MAP_COUNT; + attrList.commonattr = ATTR_CMN_ACCESSMASK; + code = setattrlist(path, &attrList, &m, sizeof m, FSOPT_NOFOLLOW); #else code = 1; #endif