From ef34c8704c99dbe54b0f7a7fabbc3d1c9ca9b16c Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 1 May 2000 13:55:09 +0000 Subject: [PATCH] [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. --- src/install.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/install.c b/src/install.c index 099fc54..20931f6 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. -- 2.7.4