aboutsummaryrefslogtreecommitdiff
path: root/src/libmain/setuid-common.hh
blob: a3e840996161da4e82206689fd705db13a4cec3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Code shared between libmain and nix-setuid-helper. */

extern char * * environ;


namespace nix {
    

void setuidCleanup()
{
    /* Don't trust the environment. */
    environ = 0;

    /* Make sure that file descriptors 0, 1, 2 are open. */
    for (int fd = 0; fd <= 2; ++fd) {
        struct stat st;
        if (fstat(fd, &st) == -1) abort();
    }
}

 
}