31 lines
517 B
C
31 lines
517 B
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
|
|
const char *chroot_path = "/mnt/nfs/chroots/ff-build";
|
|
|
|
int main (int argc, char **argv) {
|
|
uid_t user = getuid ();
|
|
char *cwd = getcwd (NULL, 0);
|
|
if (chroot (chroot_path) != 0) {
|
|
perror ("chroot");
|
|
return errno;
|
|
}
|
|
|
|
if (seteuid (user) != 0) {
|
|
perror ("seteuid");
|
|
return errno;
|
|
}
|
|
|
|
if (chdir (cwd) != 0) {
|
|
perror ("chdir");
|
|
chdir ("/");
|
|
}
|
|
|
|
free (cwd);
|
|
|
|
execvp (argv [0], &argv [0]);
|
|
perror ("execvp");
|
|
return errno;
|
|
}
|