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,30 +982,24 @@ static void parse_commandline(const int argc, char *argv[])
|
|||||||
struct passwd *p;
|
struct passwd *p;
|
||||||
int num;
|
int num;
|
||||||
if (++i >= argc) errx(1, "missing uid after --uid");
|
if (++i >= argc) errx(1, "missing uid after --uid");
|
||||||
if (!str_to_num(argv[i], &num))
|
p = getpwnam(argv[i]);
|
||||||
p = getpwnam(argv[i]);
|
if ((p == NULL) && (str_to_num(argv[i], &num)))
|
||||||
else
|
|
||||||
p = getpwuid( (uid_t)num );
|
p = getpwuid( (uid_t)num );
|
||||||
|
|
||||||
if (p == NULL)
|
if (p == NULL) errx(1, "no such uid: `%s'", argv[i]);
|
||||||
errx(1, "no such uid: `%s'", argv[i]);
|
drop_uid = p->pw_uid;
|
||||||
else
|
|
||||||
drop_uid = p->pw_uid;
|
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], "--gid") == 0)
|
else if (strcmp(argv[i], "--gid") == 0)
|
||||||
{
|
{
|
||||||
struct group *g;
|
struct group *g;
|
||||||
int num;
|
int num;
|
||||||
if (++i >= argc) errx(1, "missing gid after --gid");
|
if (++i >= argc) errx(1, "missing gid after --gid");
|
||||||
if (!str_to_num(argv[i], &num))
|
g = getgrnam(argv[i]);
|
||||||
g = getgrnam(argv[i]);
|
if ((g == NULL) && (str_to_num(argv[i], &num)))
|
||||||
else
|
|
||||||
g = getgrgid( (gid_t)num );
|
g = getgrgid( (gid_t)num );
|
||||||
|
|
||||||
if (g == NULL)
|
if (g == NULL) errx(1, "no such gid: `%s'", argv[i]);
|
||||||
errx(1, "no such gid: `%s'", argv[i]);
|
drop_gid = g->gr_gid;
|
||||||
else
|
|
||||||
drop_gid = g->gr_gid;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
errx(1, "unknown argument `%s'", argv[i]);
|
errx(1, "unknown argument `%s'", argv[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user