From 11b02d927f2d809aeade01768b16b690220c1049 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Tue, 16 Oct 2007 16:00:41 +0000 Subject: [PATCH] Adding Wesley Terpstra's lchmod()-equivalent that uses setattrlist(). --- syscall.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 -- 2.34.1