]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: fix minor bugs in helper program, setuidgid
authorJim Meyering <meyering@redhat.com>
Tue, 3 Jul 2012 18:13:09 +0000 (20:13 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 3 Jul 2012 18:13:09 +0000 (20:13 +0200)
* src/setuidgid.c (main): Fix two error-before-usage calls not to exit.
Exit with status SETUIDGID_FAILURE (not EXIT_FAILURE) consistently.

src/setuidgid.c

index 39044ce9002ec14be77923746b47eb6cac11024c..4dc055bb9e40af6d128b8897c856d5c32edf24cd 100644 (file)
@@ -107,7 +107,7 @@ main (int argc, char **argv)
                   {
                     if (! (xstrtoul (gr, &ptr, 10, &tmp_ul, NULL) == LONGINT_OK
                            && tmp_ul <= GID_T_MAX))
-                      error (EXIT_FAILURE, 0, _("invalid group %s"),
+                      error (SETUIDGID_FAILURE, 0, _("invalid group %s"),
                              quote (gr));
                     if (n_gids == n_gids_allocated)
                       gids = X2NREALLOC (gids, &n_gids_allocated);
@@ -159,8 +159,7 @@ main (int argc, char **argv)
         pwd = getpwnam (user);
         if (pwd == NULL)
           {
-            error (SETUIDGID_FAILURE, errno,
-                   _("unknown user-ID: %s"), quote (user));
+            error (0, errno, _("unknown user-ID: %s"), quote (user));
             usage (SETUIDGID_FAILURE);
           }
         uid = pwd->pw_uid;
@@ -170,7 +169,7 @@ main (int argc, char **argv)
         pwd = getpwuid (uid);
         if (pwd == NULL)
           {
-            error (SETUIDGID_FAILURE, errno,
+            error (0, errno,
                    _("to use user-ID %s you need to use -g too"), quote (user));
             usage (SETUIDGID_FAILURE);
           }
@@ -181,8 +180,8 @@ main (int argc, char **argv)
       {
         int n = xgetgroups (pwd->pw_name, pwd->pw_gid, &gids);
         if (n <= 0)
-          error (EXIT_FAILURE, errno, _("failed to get groups for user %s"),
-                 quote (pwd->pw_name));
+          error (SETUIDGID_FAILURE, errno,
+                 _("failed to get groups for user %s"), quote (pwd->pw_name));
         n_gids = n;
       }