summaryrefslogtreecommitdiff
path: root/src/install.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-05-01 13:55:09 +0000
committerJim Meyering <jim@meyering.net>2000-05-01 13:55:09 +0000
commitef34c8704c99dbe54b0f7a7fabbc3d1c9ca9b16c (patch)
tree86eb7cbe30b6f543ffe0c390a5ffed28b65dd786 /src/install.c
parentb0d42f0a5c1305aabe28ad92839dfee3bb75e1a0 (diff)
downloadcoreutils-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/install.c')
-rw-r--r--src/install.c22
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.