1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-08-18 01:18:51 +02:00

(change_file_owner): Restore special file permission

bits, since calling chown resets them on some systems.
Reported by Matt Perry.
This commit is contained in:
Jim Meyering
2000-12-09 10:15:17 +00:00
parent 497d1d9e97
commit 73f1bc31d7
+19
View File
@@ -236,6 +236,25 @@ change_file_owner (int cmdline_arg, const char *file, uid_t user, gid_t group,
quote (file));
errors = 1;
}
else
{
/* The change succeeded. On some systems, the chown function
resets the `special' permission bits. When run by a
`privileged' user, this program must ensure that at least
the set-uid and set-group ones are still set. */
if (file_stats.st_mode & ~S_IRWXUGO
/* If this is a symlink and we changed *it*, then skip it. */
&& ! (S_ISLNK (file_stats.st_mode) && change_symlinks))
{
if (chmod (file, file_stats.st_mode))
{
error (0, saved_errno,
_("unable to restore permissions of %s"),
quote (file));
fail = 1;
}
}
}
}
else if (verbosity == V_high)
{