diff options
author | Jim Meyering <jim@meyering.net> | 2003-07-12 08:37:36 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-07-12 08:37:36 +0000 |
commit | 8e34468f61f043b0a8bef0064054f9b27a969015 (patch) | |
tree | 09f0ed4b6509ee203ffacaea7832e9dd622bb13e /src | |
parent | 32a804c9411ea25201cc0b4582ba625fdc7df2c0 (diff) | |
download | coreutils-8e34468f61f043b0a8bef0064054f9b27a969015.tar.xz |
(change_file_owner): Do not restore any special
permission bits (e.g., set-user-ID, set-group-ID) that are reset
by chown(2) on some systems. Suggestion and insistence :-) from
Michael Stone.
Diffstat (limited to 'src')
-rw-r--r-- | src/chown-core.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/chown-core.c b/src/chown-core.c index a46dd7ef7..57b91a95e 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -332,23 +332,12 @@ change_file_owner (int cmdline_arg, const char *file, uid_t uid, gid_t gid, } 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_IFMT | S_IRWXUGO) - /* If we called lchown above (which means this is a symlink), - then skip it. */ - && ! called_lchown) - { - if (chmod (file, file_stats.st_mode)) - { - error (0, saved_errno, - _("unable to restore permissions of %s"), - quote (file)); - fail = 1; - } - } + /* The change succeeded. On some systems (e.g., Linux-2.4.x), + the chown function resets the `special' permission bits. + Do *not* restore those bits; doing so would open a window in + which a malicious user, M, could subvert a chown command run + by some other user and operating on files in a directory + where M has write access. */ } } else if (chopt->verbosity == V_high) |