release
[hcoop/zz_old/debian/djbdns.git] / tinydns-conf.c
CommitLineData
dc0d77d7
CE
1#include <unistd.h>
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
10void usage(void)
11{
12 strerr_die1x(100,"tinydns-conf: usage: tinydns-conf acct logacct /tinydns myip");
13}
14
15char *dir;
16char *user;
17char *loguser;
18struct passwd *pw;
19char *myip;
20
21int main(int argc,char **argv)
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
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
47 start("run");
48 outs("#!/bin/sh\nexec 2>&1\nexec envuidgid "); outs(user);
49 outs(" envdir ./env softlimit -d300000 ");
50 outs(auto_home); outs("/bin/tinydns\n");
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}