The 'install' command sets the time stamp on the installed file after
changing ownership, whereas other coreutils commands (cp, mv) set the
time stamp before chowning.  The other coreutils commands seem right
to me, if only so that the time stamp is set correctly on hosts that
let non-root users give away files via chown.

Here's a proposed patch to make them consistent.  This patch doesn't
fix any bugs that I can see on ordinary platforms where non-root users
can't give away files, but it does make the code a bit more
consistent.

diff --git a/ChangeLog b/ChangeLog
index 94db40d..ac45753 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-03  Paul Eggert  <[EMAIL PROTECTED]>
+
+       * src/install.c (install_file_in_file): Preserve time stamps
+       before changing owner or file mode bits, for consistency with
+       other coreutils programs.
+
 2006-12-02  Jim Meyering  <[EMAIL PROTECTED]>
 
        * tests/du/basic: Generate 4KB file simply using printf, rather than
diff --git a/src/install.c b/src/install.c
index 1ccc774..a5d832f 100644
--- a/src/install.c
+++ b/src/install.c
@@ -459,11 +459,10 @@ install_file_in_file (const char *from,
     return false;
   if (strip_files)
     strip (to);
-  if (! change_attributes (to))
+  if (x->preserve_timestamps && (strip_files || ! S_ISREG (from_sb.st_mode))
+      && ! change_timestamps (&from_sb, to))
     return false;
-  if (x->preserve_timestamps && (strip_files || ! S_ISREG (from_sb.st_mode)))
-    return change_timestamps (&from_sb, to);
-  return true;
+  return change_attributes (to);
 }
 
 /* Copy file FROM into directory TO_DIR, keeping its same name,


_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to