renice: fix numeric uid argument parsing
The following was inconflict with what usage() tells are valid option arguments. $ renice 1 -u 1000 renice: unknown user 1000 $ id uid=1000(kerolasa) ... Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
00b490f002
commit
80ca9e2039
|
@ -160,14 +160,17 @@ int main(int argc, char **argv)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (which == PRIO_USER) {
|
if (which == PRIO_USER) {
|
||||||
register struct passwd *pwd = getpwnam(*argv);
|
struct passwd *pwd = getpwnam(*argv);
|
||||||
|
|
||||||
if (pwd == NULL) {
|
if (pwd != NULL)
|
||||||
|
who = pwd->pw_uid;
|
||||||
|
else
|
||||||
|
who = strtol(*argv, &endptr, 10);
|
||||||
|
if (who < 0 || *endptr) {
|
||||||
warnx(_("unknown user %s"), *argv);
|
warnx(_("unknown user %s"), *argv);
|
||||||
errs = 1;
|
errs = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
who = pwd->pw_uid;
|
|
||||||
} else {
|
} else {
|
||||||
who = strtol(*argv, &endptr, 10);
|
who = strtol(*argv, &endptr, 10);
|
||||||
if (who < 0 || *endptr) {
|
if (who < 0 || *endptr) {
|
||||||
|
@ -180,4 +183,3 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
return errs != 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
return errs != 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue