diff options
author | Jim Meyering <jim@meyering.net> | 2000-05-01 13:55:09 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-05-01 13:55:09 +0000 |
commit | ef34c8704c99dbe54b0f7a7fabbc3d1c9ca9b16c (patch) | |
tree | 86eb7cbe30b6f543ffe0c390a5ffed28b65dd786 /src | |
parent | b0d42f0a5c1305aabe28ad92839dfee3bb75e1a0 (diff) | |
download | coreutils-ef34c8704c99dbe54b0f7a7fabbc3d1c9ca9b16c.tar.xz |
[checked in with intention to back out...]
(change_attributes): Unlink the destination file
if either of the chown or the chmod calls fails. Don't even attempt
the chmod if the chown fails.
Suggestion from Marc Olzheim.
Diffstat (limited to 'src')
-rw-r--r-- | src/install.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/install.c b/src/install.c index 099fc5444..20931f63b 100644 --- a/src/install.c +++ b/src/install.c @@ -506,15 +506,25 @@ change_attributes (const char *path) && errno != EPERM #endif ) - err = errno; - if (chmod (path, mode)) - err = errno; + { + error (0, errno, "cannot change ownership of `%s'", path); + err = 1; + } + + if (!err && chmod (path, mode)) + { + error (0, errno, "cannot change permissions of `%s'", path); + err = 1; + } + if (err) { - error (0, err, "%s", path); - return 1; + error (0, 0, "removing file: `%s'", path); + if (unlink (path)) + error (0, errno, "cannot remove `%s'", path); } - return 0; + + return err; } /* Set the timestamps of file TO to match those of file FROM. |