diff options
author | 2015-01-24 19:13:03 +0000 | |
---|---|---|
committer | 2015-01-24 19:13:03 +0000 | |
commit | 80a23c5363fbf64cd4420edd462e23d89b3e8a39 (patch) | |
tree | 8a6901585c2c55ca6ca878e75b0f72f997b30ee0 /pw | |
parent | f3f1481c2b79a9f8747738acd08571ab4c50eb3a (diff) | |
download | pw-darwin-80a23c5363fbf64cd4420edd462e23d89b3e8a39.tar.gz pw-darwin-80a23c5363fbf64cd4420edd462e23d89b3e8a39.tar.zst pw-darwin-80a23c5363fbf64cd4420edd462e23d89b3e8a39.zip |
Allow negative numbers in -u and -g options
PR: 196514
MFC after: 1 week
Diffstat (limited to 'pw')
-rw-r--r-- | pw/pw_group.c | 6 | ||||
-rw-r--r-- | pw/pw_user.c | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/pw/pw_group.c b/pw/pw_group.c index b20ce88..51166cd 100644 --- a/pw/pw_group.c +++ b/pw/pw_group.c @@ -68,7 +68,11 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args) }; if (a_gid != NULL) { - if (strspn(a_gid->val, "0123456789") != strlen(a_gid->val)) + const char *teststr; + teststr = a_gid->val; + if (*teststr == '-') + teststr++; + if (strspn(teststr, "0123456789") != strlen(teststr)) errx(EX_USAGE, "-g expects a number"); } diff --git a/pw/pw_user.c b/pw/pw_user.c index 483148a..f146b46 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -322,7 +322,10 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) a_name = NULL; } } else { - if (strspn(a_uid->val, "0123456789") != strlen(a_uid->val)) + const char *teststr = a_uid->val; + if (*teststr == '-') + teststr++; + if (strspn(teststr, "0123456789") != strlen(teststr)) errx(EX_USAGE, "-u expects a number"); } |