]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - pw/pw.c
Fix setting uid/gid min/max via pw
[pw-darwin.git] / pw / pw.c
diff --git a/pw/pw.c b/pw/pw.c
index d8d8c034080c14eb261f7f15d4b82ee7a0707862..30fb55b4f61d133ac6ce44a8e098bc67bcab8591 100644 (file)
--- a/pw/pw.c
+++ b/pw/pw.c
@@ -251,11 +251,20 @@ main(int argc, char *argv[])
                                addarg(&arglist, 'g', optarg);
                                break;
                        }
-                       /* FALLTHROUGH */
-               case 'u':
                        if (strspn(optarg, "0123456789") != strlen(optarg))
-                               errx(EX_USAGE, "%s expects a number",
-                                   which == 1 ? "-g" : "-u" );
+                               errx(EX_USAGE, "-g expects a number");
+                       id = strtonum(optarg, 0, LONG_MAX, &errstr);
+                       if (errstr != NULL)
+                               errx(EX_USAGE, "Bad id '%s': %s", optarg,
+                                   errstr);
+                       break;
+               case 'u':
+                       if (strspn(optarg, "0123456789,") != strlen(optarg))
+                               errx(EX_USAGE, "-u expects a number");
+                       if (strchr(optarg, ',') != NULL) {
+                               addarg(&arglist, 'u', optarg);
+                               break;
+                       }
                        id = strtonum(optarg, 0, LONG_MAX, &errstr);
                        if (errstr != NULL)
                                errx(EX_USAGE, "Bad id '%s': %s", optarg,