coreutils
[Top][All Lists]
Advanced

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

groups bug fix, groups test fix and NEWS tweak


From: Jim Meyering
Subject: groups bug fix, groups test fix and NEWS tweak
Date: Sat, 08 Jul 2017 18:42:55 +0200

Here are three proposed patches:

  groups: do not exit early
  tests: groups-dash.sh: avoid false failure
  doc: tweak wording

>From df2c30dca6bb9c07be9b6e5b12ff6d1634e6c417 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 2 Jun 2017 21:50:04 -0700
Subject: [PATCH 1/3] doc: tweak wording

* NEWS (Bug fixes): Tweak wording of the mv/cp-vs-symlink-ownership
entry and the one about df.
---
 NEWS | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index b834fa16c..35ba31197 100644
--- a/NEWS
+++ b/NEWS
@@ -4,9 +4,9 @@ GNU coreutils NEWS                                    -*- 
outline -*-

 ** Bug fixes

-  cp and mv now only warn about failure to preserve ownership of symlinks.
-  cp (without -p) will no longer exit with a failure status, and mv will
-  also no longer leave such symlinks remaining in the source file system.
+  cp and mv now merely warn about any failure to preserve symlink ownership.
+  Before, cp (without -p) would exit with a failure status, and a cross-device
+  mv would leave such symlinks behind in the source file system.
   [the bug dates back to the initial implementation]

   date and touch no longer overwrite the heap with large
@@ -18,7 +18,7 @@ GNU coreutils NEWS                                    -*- 
outline -*-
   [bug introduced in coreutils-8.24]

   df no longer interacts with excluded file system types, so for example
-  specifying -x nfs will no longer hang with problematic nfs mounts.
+  specifying -x nfs no longer hangs with problematic nfs mounts.
   [bug introduced in coreutils-8.21]

   split no longer exits when invocations of a --filter return EPIPE.
-- 
2.13.0


>From ed57568ea5fc9dcca8fd4dce00bb3085727e119a Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 8 Jul 2017 12:01:34 +0200
Subject: [PATCH 2/3] tests: groups-dash.sh: avoid false failure
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* tests/misc/groups-dash.sh: Avoid false failure on a system for which
"none" is a valid user name.  The first invocation would succeed, and
the second would fail with "groups: ‘--’: no such user".
Use a user name that cannot exist.
---
 tests/misc/groups-dash.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/misc/groups-dash.sh b/tests/misc/groups-dash.sh
index ca81cb40b..37675b4db 100755
--- a/tests/misc/groups-dash.sh
+++ b/tests/misc/groups-dash.sh
@@ -19,12 +19,14 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ groups

+# An invalid user name
+user=:invalid
+
+printf '%s\n' "groups: ':invalid': no such user" > exp || framework_failure_
+
 # Coreutils 6.9 and earlier failed to display information on first argument
 # if later argument was --.
-groups none -- > out 2>&1 && fail=1
-echo $? >> out
-groups -- none -- > exp 2>&1 && fail=1
-echo $? >> exp
+returns_ 1 groups $user -- > out 2>&1 || fail=1

 compare exp out || fail=1

-- 
2.13.0


>From 3542aedddb1e90e75a48d3a7ad97f179db783072 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 8 Jul 2017 13:01:55 +0200
Subject: [PATCH 3/3] groups: do not exit early

Most programs take care to operate on all command-line-specified
operands before exiting.  That is an important feature that allows
to identify all problems with the first run.  However, groups would
exit upon the first problematic user name.
* src/groups.c (main): Do not exit immediately upon error.
* tests/misc/groups-process-all.sh: New file. Test for this.
* tests/local.mk (all_tests): Add it.
* NEWS (Bug fixes): Mention this.
---
 NEWS                             |  3 +++
 src/groups.c                     | 11 +++++++----
 tests/local.mk                   |  1 +
 tests/misc/groups-process-all.sh | 26 ++++++++++++++++++++++++++
 4 files changed, 37 insertions(+), 4 deletions(-)
 create mode 100755 tests/misc/groups-process-all.sh

diff --git a/NEWS b/NEWS
index 35ba31197..c8cb5cb5a 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,9 @@ GNU coreutils NEWS                                    -*- 
outline -*-
   specifying -x nfs no longer hangs with problematic nfs mounts.
   [bug introduced in coreutils-8.21]

+  `groups inva:lid root` no longer exits immediately upon failure.
+  Now, it prints a diagnostic or a line to stdout for each argument.
+
   split no longer exits when invocations of a --filter return EPIPE.
   [bug introduced in coreutils-8.26]

diff --git a/src/groups.c b/src/groups.c
index 0a5c5be88..ccfe8a2d5 100644
--- a/src/groups.c
+++ b/src/groups.c
@@ -122,17 +122,20 @@ main (int argc, char **argv)
   else
     {
       /* At least one argument.  Divulge the details of the specified users.  
*/
-      while (optind < argc)
+      for ( ; optind < argc; optind++)
         {
           struct passwd *pwd = getpwnam (argv[optind]);
           if (pwd == NULL)
-            die (EXIT_FAILURE, 0, _("%s: no such user"),
-                 quote (argv[optind]));
+            {
+              error (0, 0, _("%s: no such user"), quote (argv[optind]));
+              ok = false;
+              continue;
+            }
           ruid = pwd->pw_uid;
           rgid = egid = pwd->pw_gid;

           printf ("%s : ", argv[optind]);
-          if (!print_group_list (argv[optind++], ruid, rgid, egid, true, ' '))
+          if (!print_group_list (argv[optind], ruid, rgid, egid, true, ' '))
             ok = false;
           putchar ('\n');
         }
diff --git a/tests/local.mk b/tests/local.mk
index 235bcbe65..8fc48c489 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -296,6 +296,7 @@ all_tests =                                 \
   tests/misc/false-status.sh                   \
   tests/misc/fold.pl                           \
   tests/misc/groups-dash.sh                    \
+  tests/misc/groups-process-all.sh             \
   tests/misc/groups-version.sh                 \
   tests/misc/head-c.sh                         \
   tests/misc/head-pos.sh                       \
diff --git a/tests/misc/groups-process-all.sh b/tests/misc/groups-process-all.sh
new file mode 100755
index 000000000..a352ecc10
--- /dev/null
+++ b/tests/misc/groups-process-all.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Ensure groups processes all arguments before exiting.
+# With coreutils-2.27 and prior, it would exit upon first failure.
+
+# Copyright (C) 2017 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ groups
+
+returns_ 1 groups :1 :2 :3 2> err || fail=1
+test $(wc -l < err) = 3 || fail=1
+
+Exit $fail
-- 
2.13.0




reply via email to

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