On 27/07/17 10:10, Michael Felt wrote:
> On 27/07/2017 10:22, Michael Felt wrote:
>> Hint: I expect the issue here is that the ln is done on a NFS server 
>> rather than "local" filesystem.
>>
>> Also, not run (here) as root, so those tests were skipped here.
>>
>> ========================================================
>>    GNU coreutils 8.27.4-3c9d7: ./tests/test-suite.log
>> ========================================================
>>
>> # TOTAL: 592
>> # PASS:  414
>> # SKIP:  177
>> # XFAIL: 0
>> # FAIL:  1
>> # XPASS: 0
>> # ERROR: 0
>>
>> from ./tests/test-suite.log
>>
>> FAIL: tests/ln/sf-1
>> =================== 
> 
> Ok, it looks like the test above above succeeds when on jfs2.

The attached patches should address the above and all previous issues you 
mentioned.
I've made a dist tarball for test available at:
https://www.pixelbeat.org/cu/coreutils-8.27.70-bfe8dc.tar.xz

Re the following discussion of cp, I couldn't follow it exactly.
Which test failed for you?
Are you saying that you would expect `cp -p` to not
preserve set[ug]id bits when not copying your own files?
I wouldn't expect that and I also see this comment in copy.c:

/* POSIX says that 'cp -p' must restore the following:
     - permission bits
     - setuid, setgid bits
     - owner and group
     If it fails to restore any of those, we may give a warning but
     the destination must not be removed.

cheers,
Pádraig.

> Running as root - a test previously skipped now fails. And it is a real 
> bug, it seems, as the AIX cp command (/usr/bin/cp) works as expected.
> 
> Look at the commands used to create the c4 and c8 files (the directory 
> was given mode 777 to permit the writing regardless of userid.
> 
> 
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]touch c
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]chmod a=r,ug+sx c
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]ls -l c
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]su
> root's Password:
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]cp -p c c1
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]chroot --skip-chdir 
> --user=nobody src/cp -p c c2
> chroot: option --skip-chdir only permitted if NEWROOT is old '/'
> Try 'chroot --help' for more information.
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]chroot --skip-chdir 
> --user=nobody / src/cp -p c c2
> cp: cannot create regular file 'c2': Permission denied
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]ls -l c c??
> ls: cannot access 'c??': No such file or directory
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]ls -l c c?
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c1
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]chmod 777 .
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]chroot --skip-chdir 
> --user=nobody / src/cp -p c c2
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]ls -l c c?
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c1
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c2
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]su nobody -c src/cp 
> -p c c3
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]ls -l c c?
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c1
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c2
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c3
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]su nobody -c 
> /usr/bin/cp -p c c4
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]ls -l c c?
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c1
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c2
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c3
> -r-xr-xr-- 1 nobody  felt 0 Jul 27 16:53 c4
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]
> 
> Here I exit from SU mode.
> 
> As the file c is owned by michael - not surprising that c5 has 
> permission bits. But c2 is owned by nobody, and I would not expect those 
> special bits to copy as michael
> 
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]id
> uid=199(michael) gid=1954(felt) 
> groups=1954(felt),1(staff),33(httpd),208(xdata)
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]cp -p c c5
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]src/cp -p c c6
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]ls -l c c?
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c1
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c2
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c3
> -r-xr-xr-- 1 nobody  felt 0 Jul 27 16:53 c4
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c5
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c6
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]src/cp -p c2 c6
> cp: cannot create regular file 'c6': Permission denied
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]src/cp -p c2 c7
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]ls -l c c?
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c1
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c2
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c3
> -r-xr-xr-- 1 nobody  felt 0 Jul 27 16:53 c4
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c5
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c6
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c7
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]/usr/bin/cp -p c2 c8
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]ls -l c c?
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c1
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c2
> -r-sr-sr-- 1 nobody  felt 0 Jul 27 16:53 c3
> -r-xr-xr-- 1 nobody  felt 0 Jul 27 16:53 c4
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c5
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c6
> -r-sr-sr-- 1 michael felt 0 Jul 27 16:53 c7
> -r-xr-xr-- 1 michael felt 0 Jul 27 16:53 c8
> michael@x071:[/home/michael/coreutils-8.27.4-3c9d7]
> 
> So, it seems that src/cp is still copying the file mode, regardless.

From 2eb74053e9ec5e5e4865f38e32b7b7d6c1350638 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Thu, 3 Aug 2017 21:20:08 -0700
Subject: [PATCH 1/3] tests: avoid false failures on AIX

* tests/ln/sf-1.sh: Limit the symlink size to 1MiB
to avoid memory exhaustion seen on NFS on AIX, giving:
  + printf '%0*d' 4294967296 0
  + ./tests/ln/sf-1.sh: line 38: printf: warning: 0: Result too large
* tests/id/setgid.sh: Skip the test when the adjusted gid
would equal 4294967295, as that's reserved on AIX.
Reported by Michael Felt.
---
 tests/id/setgid.sh | 5 +++++
 tests/ln/sf-1.sh   | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tests/id/setgid.sh b/tests/id/setgid.sh
index 61a1d99..09f9eb0 100755
--- a/tests/id/setgid.sh
+++ b/tests/id/setgid.sh
@@ -20,11 +20,16 @@
 print_ver_ id
 require_root_
 
+getlimits_
+
 # Construct a different group number
 gp1=$NON_ROOT_GID
 gp1=$(expr $gp1 + 1) ||
   skip_ "failed to adjust GID $NON_ROOT_GID"
 
+test "$gp1" -lt $GID_T_MAX ||
+  skip_ "GID $gp1 is reserved on some systems"
+
 echo $gp1 > exp || framework_failure_
 
 # With coreutils-8.16 and earlier, id -G would print both:
diff --git a/tests/ln/sf-1.sh b/tests/ln/sf-1.sh
index 149b275..492fce9 100755
--- a/tests/ln/sf-1.sh
+++ b/tests/ln/sf-1.sh
@@ -33,9 +33,14 @@ esac
 
 # Ensure we replace symlinks that don't or can't link to an existing target.
 # coreutils-8.22 would fail to replace {ENOTDIR,ELOOP,ENAMETOOLONG}_link below.
-name_max_plus1=$(expr $(stat -f -c %l .) + 1)
+name_max=$(stat -f -c %l .) || skip_ 'Error determining NAME_MAX'
+# Apply a limit since AIX returns 2^32-1 which would trigger resource issues.
+name_limit=$((1024*1024))
+test "$name_max" -lt "$name_limit" || name_max="$name_limit"
+name_max_plus1=$(expr $name_max + 1)
 test $name_max_plus1 -gt 1 || skip_ 'Error determining NAME_MAX'
 long_name=$(printf '%0*d' $name_max_plus1 0)
+
 for f in '' f; do
   ln -s$f missing ENOENT_link || fail=1
   ln -s$f a/b ENOTDIR_link || fail=1
-- 
2.9.3


From 12e74aa7fd295fe8c658c36f8521502893a0029e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Thu, 3 Aug 2017 23:39:26 -0700
Subject: [PATCH 2/3] build: use the appropriate single file include option
 with xlc

* configure.ac: Set USE_XLC_INCLUDE when __xlc__ is defined.
* src/local.mk: Use it to select the appropriate include option.
Reported by Michael Felt.
---
 configure.ac | 12 ++++++++++++
 src/local.mk | 10 ++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7c7c8c2..d2459ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -496,6 +496,18 @@ fi
 CFLAGS=$ac_save_CFLAGS
 LDFLAGS=$ac_save_LDFLAGS
 
+# Detect when using xlc to determine whether to use -qinclude=
+AC_CACHE_CHECK([whether the system supports xlc include], [utils_cv_xlc],
+  [AC_COMPILE_IFELSE(
+     [AC_LANG_PROGRAM([[
+          #ifndef __xlc__
+            #error "not xlc"
+          #endif
+        ]])],
+     [utils_cv_xlc=yes],
+     [utils_cv_xlc=no])])
+AM_CONDITIONAL([USE_XLC_INCLUDE], [test "$utils_cv_xlc" = yes])
+
 ############################################################################
 
 dnl Autogenerated by the 'gen-lists-of-programs.sh' auxiliary script.
diff --git a/src/local.mk b/src/local.mk
index 9b2b172..1cb6859 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -397,8 +397,14 @@ src_sha384sum_SOURCES = src/md5sum.c
 src_sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
 src_sha512sum_SOURCES = src/md5sum.c
 src_sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
-src_b2sum_CPPFLAGS = -include config.h -DHASH_ALGO_BLAKE2=1 \
-                    $(AM_CPPFLAGS)
+# Include the file on the command line to avoid modifying
+# the blake2 upstream source
+if USE_XLC_INCLUDE
+src_b2sum_CPPFLAGS = -qinclude=config.h
+else
+src_b2sum_CPPFLAGS = -include config.h
+endif
+src_b2sum_CPPFLAGS += -DHASH_ALGO_BLAKE2=1 $(AM_CPPFLAGS)
 src_b2sum_SOURCES = src/md5sum.c \
                    src/blake2/blake2.h src/blake2/blake2-impl.h \
                    src/blake2/blake2b-ref.c \
-- 
2.9.3


From bfe8dc187c30c01c2b5a965ef5abea1ac304b486 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Sun, 23 Jul 2017 03:25:32 -0700
Subject: [PATCH 3/3] kill: fix signal number to name lookup on AIX

* src/operand2sig.c (operand2sig): AIX uses a different bit pattern
in the returned status from the wait() functions and from shells.
Therefore hardcode the selection of the lower bits of the number.
* NEWS: Mention the fix.
---
 NEWS              |  4 ++++
 src/operand2sig.c | 11 +++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index eb0c0dc..6b6cafd 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,10 @@ GNU coreutils NEWS                                    -*- 
outline -*-
   Now, it prints a diagnostic or a line to stdout for each argument.
   [bug introduced in the bourne-shell-to-C rewrite for coreutils-6.11]
 
+  kill now converts from number to signal name correctly on AIX.
+  Previously it would have always returned the 'EXIT' name.
+  [bug introduced in fileutils-4.1.9]
+
   split no longer exits when invocations of a --filter return EPIPE.
   [bug introduced in coreutils-8.26]
 
diff --git a/src/operand2sig.c b/src/operand2sig.c
index d59ccb9..db5ceea 100644
--- a/src/operand2sig.c
+++ b/src/operand2sig.c
@@ -53,8 +53,15 @@ operand2sig (char const *operand, char *signame)
       char *endp;
       long int l = (errno = 0, strtol (operand, &endp, 10));
       int i = l;
-      signum = (operand == endp || *endp || errno || i != l ? -1
-                : WIFSIGNALED (i) ? WTERMSIG (i) : i);
+      signum = (operand == endp || *endp || errno || i != l ? -1 : i);
+
+      if (signum != -1)
+        {
+          /* Note AIX uses a different bit pattern for status returned
+             from shell and wait(), so we can't use WTERMSIG etc. here.
+             Also ksh returns 0xFF + signal number.  */
+          signum &= signum >= 0xFF ? 0xFF : 0x7F;
+        }
     }
   else
     {
-- 
2.9.3

Reply via email to