1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 20:01:15 +02:00

* Move setuidCleanup() to libutil.

This commit is contained in:
Eelco Dolstra 2006-12-07 16:40:41 +00:00
parent f76fdb6d42
commit a82d80ddeb
5 changed files with 23 additions and 27 deletions

View file

@ -17,6 +17,9 @@
#include "util.hh"
extern char * * environ;
namespace nix {
@ -818,6 +821,19 @@ void quickExit(int status)
}
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();
}
}
//////////////////////////////////////////////////////////////////////