]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
copy: ensure the correct root ID is checked on all platforms
authorJoachim Schmitz <jojo@schmitz-digital.de>
Tue, 19 Feb 2013 11:36:57 +0000 (11:36 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 20 Feb 2013 04:05:30 +0000 (04:05 +0000)
* src/copy.c (copy_reg): Check ROOT_UID rather than 0,
which is significant on HP-NonStop.

src/copy.c

index 244313ee707b2f53a20827bfde24d414c841d43e..5c0ee1e703d8494b71eda67436a12c5d79a9a5ef 100644 (file)
@@ -51,6 +51,7 @@
 #include "ignore-value.h"
 #include "ioblksize.h"
 #include "quote.h"
+#include "root-uid.h"
 #include "same.h"
 #include "savedir.h"
 #include "stat-size.h"
@@ -1127,7 +1128,7 @@ preserve_metadata:
     {
       bool access_changed = false;
 
-      if (!(sb.st_mode & S_IWUSR) && geteuid () != 0)
+      if (!(sb.st_mode & S_IWUSR) && geteuid () != ROOT_UID)
         access_changed = fchmod_or_lchmod (dest_desc, dst_name, 0600) == 0;
 
       if (!copy_attr (src_name, source_desc, dst_name, dest_desc, x)
@@ -2718,7 +2719,7 @@ cp_options_default (struct cp_options *x)
     priv_freeset (pset);
   }
 #else
-  x->chown_privileges = x->owner_privileges = (geteuid () == 0);
+  x->chown_privileges = x->owner_privileges = (geteuid () == ROOT_UID);
 #endif
 }