djbdnscurve6  38
djbdnscurve6
droproot.c
Go to the documentation of this file.
1 #include <unistd.h>
2 #include "env.h"
3 #include "scan.h"
4 #include "prot.h"
5 #include "logmsg.h"
6 
7 
8 void droproot(const char *fatal)
9 {
10  char *x;
11  unsigned long id;
12 
13  x = env_get("ROOT");
14  if (!x)
15  logmsg(fatal,111,ERROR,"$ROOT not set");
16  if (chdir(x) == -1)
17  logmsg(fatal,111,FATAL,B("unable to chdir to: ",x));
18  if (chroot(".") == -1)
19  logmsg(fatal,111,FATAL,B("unable to chroot to: ",x));
20 
21  x = env_get("GID");
22  if (!x)
23  logmsg(fatal,111,FATAL,"$GID not set");
24  scan_ulong(x,&id);
25  if (prot_gid((int) id) == -1)
26  logmsg(fatal,111,FATAL,"unable to setgid");
27 
28  x = env_get("UID");
29  if (!x)
30  logmsg(fatal,111,FATAL,"$UID not set");
31  scan_ulong(x,&id);
32  if (prot_uid((int) id) == -1)
33  logmsg(fatal,111,FATAL,"unable to setuid");
34 }
struct line * x
void droproot(const char *fatal)
Definition: droproot.c:8
const char * fatal
Definition: rbldns.c:16