mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
. Correct order of checking name and id for --uid and --gid.
This commit is contained in:
parent
7ef872fd6a
commit
45ac8883e0
@ -982,14 +982,11 @@ static void parse_commandline(const int argc, char *argv[])
|
||||
struct passwd *p;
|
||||
int num;
|
||||
if (++i >= argc) errx(1, "missing uid after --uid");
|
||||
if (!str_to_num(argv[i], &num))
|
||||
p = getpwnam(argv[i]);
|
||||
else
|
||||
if ((p == NULL) && (str_to_num(argv[i], &num)))
|
||||
p = getpwuid( (uid_t)num );
|
||||
|
||||
if (p == NULL)
|
||||
errx(1, "no such uid: `%s'", argv[i]);
|
||||
else
|
||||
if (p == NULL) errx(1, "no such uid: `%s'", argv[i]);
|
||||
drop_uid = p->pw_uid;
|
||||
}
|
||||
else if (strcmp(argv[i], "--gid") == 0)
|
||||
@ -997,14 +994,11 @@ static void parse_commandline(const int argc, char *argv[])
|
||||
struct group *g;
|
||||
int num;
|
||||
if (++i >= argc) errx(1, "missing gid after --gid");
|
||||
if (!str_to_num(argv[i], &num))
|
||||
g = getgrnam(argv[i]);
|
||||
else
|
||||
if ((g == NULL) && (str_to_num(argv[i], &num)))
|
||||
g = getgrgid( (gid_t)num );
|
||||
|
||||
if (g == NULL)
|
||||
errx(1, "no such gid: `%s'", argv[i]);
|
||||
else
|
||||
if (g == NULL) errx(1, "no such gid: `%s'", argv[i]);
|
||||
drop_gid = g->gr_gid;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user