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 | |
parent | f9519bcd1a6dbf9246d8ea02dcaf47b7b4a017c7 (diff) |
* mkgroup.c (main): Fix test for duplicate domain/machine request.
* mkpasswd.c (main): Ditto.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/utils/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/utils/mkgroup.c | 19 | ||||
-rw-r--r-- | winsup/utils/mkpasswd.c | 17 |
3 files changed, 32 insertions, 9 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index f014a2809..105c19f35 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,5 +1,10 @@ 2008-07-23 Corinna Vinschen <corinna@vinschen.de> + * mkgroup.c (main): Fix test for duplicate domain/machine request. + * mkpasswd.c (main): Ditto. + +2008-07-23 Corinna Vinschen <corinna@vinschen.de> + * mkgroup.c: Rework to allow per-domain/per-machine id_offset. Add -b option to skip builtin groups. (main): Simplify code. diff --git a/winsup/utils/mkgroup.c b/winsup/utils/mkgroup.c index b267b13ed..ea9af72f5 100644 --- a/winsup/utils/mkgroup.c +++ b/winsup/utils/mkgroup.c @@ -750,12 +750,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; + } if (!(domlist[print_domlist].str = opt)) print_system = 1; domlist[print_domlist].id_offset = ULONG_MAX; @@ -772,9 +782,8 @@ 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: +skip: break; case 'S': sep_char = optarg; 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; |