From: Sami Kerola Date: Fri, 5 Sep 2014 22:54:17 +0000 (+0100) Subject: renice: fix numeric uid argument parsing X-Git-Tag: v2.26-rc1~448^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=80ca9e2039fda0c5002d3729eab40d45ec23058c;p=thirdparty%2Futil-linux.git 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 Signed-off-by: Sami Kerola --- diff --git a/sys-utils/renice.c b/sys-utils/renice.c index d83fc4a17a..a123ed15f3 100644 --- a/sys-utils/renice.c +++ b/sys-utils/renice.c @@ -160,14 +160,17 @@ int main(int argc, char **argv) continue; } 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); errs = 1; continue; } - who = pwd->pw_uid; } else { who = strtol(*argv, &endptr, 10); if (who < 0 || *endptr) { @@ -180,4 +183,3 @@ int main(int argc, char **argv) } return errs != 0 ? EXIT_FAILURE : EXIT_SUCCESS; } -