djbdnscurve6 53
djbdnscurve6
Loading...
Searching...
No Matches
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
7void droproot(const char *server)
8{
9 char *x;
10 unsigned long id;
11
12 x = env_get("ROOT");
13 if (!x)
14 logmsg(server,111,ERROR,"$ROOT not set");
15 if (chdir(x) == -1)
16 logmsg(server,111,FATAL,B("unable to chdir to: ",x));
17 if (chroot(".") == -1)
18 logmsg(server,111,FATAL,B("unable to chroot to: ",x));
19
20 x = env_get("GID");
21 if (!x)
22 logmsg(server,111,FATAL,"$GID not set");
23 scan_dnum(x,&id);
24 if (prot_gid((int) id) == -1)
25 logmsg(server,111,FATAL,"unable to setgid");
26
27 x = env_get("UID");
28 if (!x)
29 logmsg(server,111,FATAL,"$UID not set");
30 scan_dnum(x,&id);
31 if (prot_uid((int) id) == -1)
32 logmsg(server,111,FATAL,"unable to setuid");
33}
struct line * x
void droproot(const char *server)
Definition: droproot.c:7
const char * server
Definition: rbldns.c:17