diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-07-24 00:12:12 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-07-24 00:12:12 +0400 |
commit | f36c78a4872e5b8fc1a2334c6ed71371a642deb8 (patch) | |
tree | 6d5008818159052eb3b62c5b80afb34d14410310 /winsup/utils/mkpasswd.c | |
parent | f9519bcd1a6dbf9246d8ea02dcaf47b7b4a017c7 (diff) |
* mkgroup.c (main): Fix test for duplicate domain/machine request.
* mkpasswd.c (main): Ditto.
Diffstat (limited to 'winsup/utils/mkpasswd.c')
-rw-r--r-- | winsup/utils/mkpasswd.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/winsup/utils/mkpasswd.c b/winsup/utils/mkpasswd.c index 19d2291a9..546ba24cc 100644 --- a/winsup/utils/mkpasswd.c +++ b/winsup/utils/mkpasswd.c @@ -725,12 +725,22 @@ main (int argc, char **argv) "domains and machines.\n", __progname); return 1; } + domlist[print_domlist].domain = (c == 'd' || c == 'D'); opt = optarg ?: argv[optind] && argv[optind][0] != '-' ? argv[optind] : NULL; for (i = 0; i < print_domlist; ++i) - if ((!domlist[i].str && !opt) - || (domlist[i].str && opt && !strcmp (domlist[i].str, opt))) - goto skip; + if (domlist[i].domain == domlist[print_domlist].domain + && ((!domlist[i].str && !opt) + || (domlist[i].str && opt + && (off = strlen (domlist[i].str)) + && !strncmp (domlist[i].str, opt, off) + && (!opt[off] || opt[off] == ',')))) + { + fprintf (stderr, "%s: Duplicate %s '%s'. Skipping...\n", + __progname, domlist[i].domain ? "domain" : "machine", + domlist[i].str); + goto skip; + } domlist[print_domlist].str = opt; domlist[print_domlist].id_offset = ULONG_MAX; if (opt && (p = strchr (opt, ','))) @@ -746,7 +756,6 @@ main (int argc, char **argv) } *p = '\0'; } - domlist[print_domlist].domain = (c == 'd' || c == 'D'); domlist[print_domlist++].with_dom = (c == 'D' || c == 'L'); skip: break; |