Subject: bug#10305: coreutils-8.21, some changes needed

From: "Joachim Schmitz" <[email-masked]>
Date: Tue, 19 Feb 2013 09:17:45 +0100

Hi folks

In an attempt to port coreutils 8.21 to HP-NonStop I stumbled accross a couple problems, here are my fixes to them:

Here another file needs to get adjusted to using the new root-uid.h

diff -EBbu ./src/copy.c.orig ./src/copy.c
--- ./src/copy.c.orig   2013-02-07 03:37:05 -0600
+++ ./src/copy.c        2013-02-18 09:29:22 -0600
@@ -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 @@
     {
       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 @@
     priv_freeset (pset);
   }
 #else
-  x->chown_privileges = x->owner_privileges = (geteuid () == 0);
+  x->chown_privileges = x->owner_privileges = (geteuid () == ROOT_UID);
 #endif
 }

On HP-NonStop we use  0x80000000 instead of -1 for getuid(), getgid() and friends to indicate NO_UID rsp. NO_GID
Guess that difference could go into gnulibs root-uid.h?
Such a change would affect coreutils in ...src/{groups,id,install,test,whoami}.c (in addition to root-uid.h of course)

Here two trailing _ seem missing?

diff -EBbu ./src/numfmt.c.orig ./src/numfmt.c
--- ./src/numfmt.c.orig 2013-02-14 08:49:30 -0600
+++ ./src/numfmt.c      2013-02-18 10:58:27 -0600
@@ -1195,7 +1195,7 @@
    Returns a pointer to the *delimiter* of the requested field,
    or a pointer to NUL (if reached the end of the string).  */
 static inline char *
-__attribute ((pure))
+__attribute__ ((pure))
 skip_fields (char *buf, int fields)
 {
   char *ptr = buf;