fc5070c600
Provide a central function to change the user id of the calling process. This is mostly used by programs to become the none user, followed by a call to newns().
21 lines
261 B
C
21 lines
261 B
C
#include <u.h>
|
|
#include <libc.h>
|
|
#include <auth.h>
|
|
|
|
int
|
|
procsetuser(char *user)
|
|
{
|
|
int fd, n;
|
|
|
|
fd = open("#c/user", OWRITE|OCEXEC);
|
|
if(fd < 0)
|
|
return -1;
|
|
n = strlen(user);
|
|
if(write(fd, user, n) != n){
|
|
close(fd);
|
|
return -1;
|
|
}
|
|
close(fd);
|
|
return 0;
|
|
}
|