mirror of
https://github.com/Interlisp/maiko.git
synced 2026-01-13 15:18:14 +00:00
Drop setuid privilege correctly. (#401)
This commit is contained in:
parent
c39b751f42
commit
19688bc314
@ -742,7 +742,7 @@ static int check_filter(u_char *buffer)
|
||||
static void init_uid() {
|
||||
int rid;
|
||||
rid = getuid();
|
||||
seteuid(rid);
|
||||
setuid(rid);
|
||||
}
|
||||
#endif /* MAIKO_ENABLE_ETHERNET */
|
||||
|
||||
@ -830,7 +830,7 @@ void init_ether() {
|
||||
/* JDS 991228 remove perror("Can't open network; XNS unavailable.\n"); */
|
||||
ether_fd = -1;
|
||||
}
|
||||
seteuid(getuid());
|
||||
setuid(getuid());
|
||||
}
|
||||
#elif defined(USE_NIT)
|
||||
#ifndef OS4
|
||||
@ -952,7 +952,7 @@ void init_ether() {
|
||||
perror("Can't open network; XNS unavailable.\n");
|
||||
ether_fd = -1;
|
||||
}
|
||||
seteuid(getuid());
|
||||
setuid(getuid());
|
||||
}
|
||||
|
||||
#endif /* OS4 */
|
||||
|
||||
@ -214,7 +214,7 @@ int main(int argc, char *argv[]) {
|
||||
ether_fd = -1;
|
||||
/* exit(); */
|
||||
}
|
||||
seteuid(getuid());
|
||||
setuid(getuid());
|
||||
}
|
||||
|
||||
/* OK, right here do other stuff like scan args */
|
||||
|
||||
@ -486,9 +486,9 @@ int main(int argc, char *argv[])
|
||||
probemouse(); /* See if the mouse is connected. */
|
||||
#else
|
||||
if (getuid() != geteuid()) {
|
||||
fprintf(stderr, "Effective user is not real user. Setting euid to uid.\n");
|
||||
if (seteuid(getuid()) == -1) {
|
||||
fprintf(stderr, "Unable to reset effective user id to real user id\n");
|
||||
fprintf(stderr, "Effective user is not real user. Resetting uid\n");
|
||||
if (setuid(getuid()) == -1) {
|
||||
fprintf(stderr, "Unable to reset user id to real user id\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user