[checked in with intention to back out...]
authorJim Meyering <jim@meyering.net>
Mon, 1 May 2000 13:55:09 +0000 (13:55 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 1 May 2000 13:55:09 +0000 (13:55 +0000)
(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

index 099fc54..20931f6 100644 (file)
@@ -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.