[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

'install' sets time stamp after changing owner; should do it before?

From: Paul Eggert
Subject: 'install' sets time stamp after changing owner; should do it before?
Date: Mon, 04 Dec 2006 00:50:24 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

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

diff --git a/ChangeLog b/ChangeLog
index 94db40d..ac45753 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-03  Paul Eggert  <address@hidden>
+       * 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  <address@hidden>
        * 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,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]