From: Wayne Davison Date: Fri, 1 Oct 2021 20:28:57 +0000 (-0700) Subject: Change do_chmod to always try lchmod() first (when possible). X-Git-Tag: v3.2.4pre1~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15dd2058fda8d9996af47785afd225cce08449e4;p=thirdparty%2Frsync.git Change do_chmod to always try lchmod() first (when possible). --- diff --git a/syscall.c b/syscall.c index 181be11d..bf0de8ba 100644 --- a/syscall.c +++ b/syscall.c @@ -231,19 +231,13 @@ int do_open(const char *pathname, int flags, mode_t mode) #ifdef HAVE_CHMOD int do_chmod(const char *path, mode_t mode) { - static int switch_step = 0; int code; if (dry_run) return 0; RETURN_ERROR_IF_RO_OR_LO; - switch (switch_step) { #ifdef HAVE_LCHMOD -#include "case_N.h" - if ((code = lchmod(path, mode & CHMOD_BITS)) == 0 || errno != ENOTSUP) - break; - switch_step++; + if ((code = lchmod(path, mode & CHMOD_BITS)) < 0 && errno == ENOTSUP) #endif - -#include "case_N.h" + { if (S_ISLNK(mode)) { # if defined HAVE_SETATTRLIST struct attrlist attrList; @@ -258,7 +252,6 @@ int do_chmod(const char *path, mode_t mode) # endif } else code = chmod(path, mode & CHMOD_BITS); /* DISCOURAGED FUNCTION */ - break; } if (code != 0 && (preserve_perms || preserve_executability)) return code;