Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 99 lines (81 sloc) 2.149 kb
df36440 import djbdns 1.03
D. J. Bernstein authored
1 #include <unistd.h>
3e25c70 import dnscache 1.00
D. J. Bernstein authored
2 #include <pwd.h>
3 #include "strerr.h"
4 #include "exit.h"
5 #include "auto_home.h"
6 #include "generic-conf.h"
7
8 #define FATAL "tinydns-conf: fatal: "
9
10 void usage(void)
11 {
12 strerr_die1x(100,"tinydns-conf: usage: tinydns-conf acct logacct /tinydns myip");
13 }
14
15 char *dir;
16 char *user;
17 char *loguser;
18 struct passwd *pw;
19 char *myip;
20
df36440 import djbdns 1.03
D. J. Bernstein authored
21 int main(int argc,char **argv)
3e25c70 import dnscache 1.00
D. J. Bernstein authored
22 {
23 user = argv[1];
24 if (!user) usage();
25 loguser = argv[2];
26 if (!loguser) usage();
27 dir = argv[3];
28 if (!dir) usage();
29 if (dir[0] != '/') usage();
30 myip = argv[4];
31 if (!myip) usage();
32
33 pw = getpwnam(loguser);
34 if (!pw)
35 strerr_die3x(111,FATAL,"unknown account ",loguser);
36
37 init(dir,FATAL);
38 makelog(loguser,pw->pw_uid,pw->pw_gid);
39
a33f38d import djbdns 1.01
D. J. Bernstein authored
40 makedir("env");
41 perm(02755);
42 start("env/ROOT"); outs(dir); outs("/root\n"); finish();
43 perm(0644);
44 start("env/IP"); outs(myip); outs("\n"); finish();
45 perm(0644);
46
3e25c70 import dnscache 1.00
D. J. Bernstein authored
47 start("run");
a33f38d import djbdns 1.01
D. J. Bernstein authored
48 outs("#!/bin/sh\nexec 2>&1\nexec envuidgid "); outs(user);
df36440 import djbdns 1.03
D. J. Bernstein authored
49 outs(" envdir ./env softlimit -d300000 ");
a33f38d import djbdns 1.01
D. J. Bernstein authored
50 outs(auto_home); outs("/bin/tinydns\n");
3e25c70 import dnscache 1.00
D. J. Bernstein authored
51 finish();
52 perm(0755);
53
54 makedir("root");
55 perm(02755);
56
57 start("root/data");
58 finish();
59 perm(0644);
60
61 start("root/add-ns");
62 outs("#!/bin/sh\nexec ");
63 outs(auto_home); outs("/bin/tinydns-edit data data.new add ns ${1+\"$@\"}\n");
64 finish();
65 perm(0755);
66
67 start("root/add-childns");
68 outs("#!/bin/sh\nexec ");
69 outs(auto_home); outs("/bin/tinydns-edit data data.new add childns ${1+\"$@\"}\n");
70 finish();
71 perm(0755);
72
73 start("root/add-host");
74 outs("#!/bin/sh\nexec ");
75 outs(auto_home); outs("/bin/tinydns-edit data data.new add host ${1+\"$@\"}\n");
76 finish();
77 perm(0755);
78
79 start("root/add-alias");
80 outs("#!/bin/sh\nexec ");
81 outs(auto_home); outs("/bin/tinydns-edit data data.new add alias ${1+\"$@\"}\n");
82 finish();
83 perm(0755);
84
85 start("root/add-mx");
86 outs("#!/bin/sh\nexec ");
87 outs(auto_home); outs("/bin/tinydns-edit data data.new add mx ${1+\"$@\"}\n");
88 finish();
89 perm(0755);
90
91 start("root/Makefile");
92 outs("data.cdb: data\n");
93 outs("\t"); outs(auto_home); outs("/bin/tinydns-data\n");
94 finish();
95 perm(0644);
96
97 _exit(0);
98 }
Something went wrong with that request. Please try again.