From: Alan T. DeKok Date: Thu, 2 May 2019 17:00:31 +0000 (-0400) Subject: WARN if the permissions are different. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88cb76e308c8dcac746e8eb26432e5757525619c;p=thirdparty%2Ffreeradius-server.git WARN if the permissions are different. But change them only if the permissions REMOVE the ones we care about. --- diff --git a/src/lib/server/exfile.c b/src/lib/server/exfile.c index 796f7a6fb7a..d3b9acb6b0f 100644 --- a/src/lib/server/exfile.c +++ b/src/lib/server/exfile.c @@ -472,15 +472,24 @@ try_lock: * Sometimes the file permissions are changed externally. * just be sure to update the permission if necessary. */ - if ((st.st_mode & ~S_IFMT) != permissions) { + if ((st.st_mode & ~S_IFMT) != permissions) { char str_need[10], oct_need[5]; + char str_have[10], oct_have[5]; rad_mode_to_oct(oct_need, permissions); rad_mode_to_str(str_need, permissions); - WARN("Correcting file %s permission to %s (%s)", filename, oct_need, str_need); + rad_mode_to_oct(oct_have, st.st_mode & ~S_IFMT); + rad_mode_to_str(str_have, st.st_mode & ~S_IFMT); - if (fchmod(ef->entries[i].fd, permissions) < 0) { + WARN("File %s permissions are %s (%s) not %s (%s))", filename, + oct_have, str_have, oct_need, str_need); + + if (((st.st_mode | permissions) != st.st_mode) && + (fchmod(ef->entries[i].fd, (st.st_mode & ~S_IFMT) | permissions) < 0)) { + rad_mode_to_oct(oct_need, (st.st_mode & ~S_IFMT) | permissions); + rad_mode_to_str(str_need, (st.st_mode & ~S_IFMT) | permissions); + WARN("Failed resetting file %s permissions to %s (%s): %s", filename, oct_need, str_need, fr_syserror(errno)); }