Resort unprivileged uid with privileged socket after unprivileged uid

with privileged socket in test runs.

If running unprivileged and instructed to use unprivileged sockets,
don't try and use raw sockets.
This commit is contained in:
Robert Watson 2004-10-11 19:12:40 +00:00
parent cdeeed7a38
commit a1626faabe

View File

@ -682,6 +682,8 @@ testsuite(int priv)
*/
if (getuid() != 0 && socktype == SOCK_RAW)
continue;
if (geteuid() != 0 && !priv && socktype == SOCK_RAW)
continue;
/*
* XXXRW: On 5.3, this seems not to work for SOCK_RAW.
@ -822,14 +824,14 @@ main(int argc, char *argv[])
testsuite(PRIV_ASIS);
if (seteuid(65534) != 0)
err(-1, "seteuid(65534)");
fprintf(stderr,
"Running tests with ruid %d euid %d sock uid 0\n",
getuid(), geteuid());
testsuite(PRIV_GETROOT);
fprintf(stderr,
"Running tests with ruid %d euid %d sock uid 65534\n",
getuid(), geteuid());
testsuite(PRIV_ASIS);
fprintf(stderr,
"Running tests with ruid %d euid %d sock uid 0\n",
getuid(), geteuid());
testsuite(PRIV_GETROOT);
}
fprintf(stderr, "PASS\n");
exit(0);