Commit | Line | Data |
---|---|---|
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 "axfrdns-conf: fatal: " | |
9 | ||
10 | void usage(void) | |
11 | { | |
12 | strerr_die1x(100,"axfrdns-conf: usage: axfrdns-conf acct logacct /axfrdns /tinydns myip"); | |
13 | } | |
14 | ||
15 | char *dir; | |
16 | char *user; | |
17 | char *loguser; | |
18 | struct passwd *pw; | |
19 | char *myip; | |
20 | char *tinydns; | |
21 | ||
22 | int main(int argc,char **argv) | |
23 | { | |
24 | user = argv[1]; | |
25 | if (!user) usage(); | |
26 | loguser = argv[2]; | |
27 | if (!loguser) usage(); | |
28 | dir = argv[3]; | |
29 | if (!dir) usage(); | |
30 | if (dir[0] != '/') usage(); | |
31 | tinydns = argv[4]; | |
32 | if (!tinydns) usage(); | |
33 | if (tinydns[0] != '/') usage(); | |
34 | myip = argv[5]; | |
35 | if (!myip) usage(); | |
36 | ||
37 | pw = getpwnam(loguser); | |
38 | if (!pw) | |
39 | strerr_die3x(111,FATAL,"unknown account ",loguser); | |
40 | ||
41 | init(dir,FATAL); | |
42 | makelog(loguser,pw->pw_uid,pw->pw_gid); | |
43 | ||
44 | makedir("env"); | |
45 | perm(02755); | |
46 | start("env/ROOT"); outs(tinydns); outs("/root\n"); finish(); | |
47 | perm(0644); | |
48 | start("env/IP"); outs(myip); outs("\n"); finish(); | |
49 | perm(0644); | |
50 | ||
51 | start("run"); | |
52 | outs("#!/bin/sh\nexec 2>&1\nexec envdir ./env sh -c '\n exec envuidgid "); outs(user); | |
53 | outs(" softlimit -d300000 tcpserver -vDRHl0 -x tcp.cdb -- \"$IP\" 53 "); | |
54 | outs(auto_home); outs("/bin/axfrdns\n'\n"); | |
55 | finish(); | |
56 | perm(0755); | |
57 | ||
58 | start("Makefile"); | |
59 | outs("tcp.cdb: tcp\n"); | |
60 | outs("\ttcprules tcp.cdb tcp.tmp < tcp\n"); | |
61 | finish(); | |
62 | perm(0644); | |
63 | ||
64 | start("tcp"); | |
65 | outs("# sample line: 1.2.3.4:allow,AXFR=\"heaven.af.mil/3.2.1.in-addr.arpa\"\n"); | |
66 | outs(":deny\n"); | |
67 | finish(); | |
68 | perm(0644); | |
69 | ||
70 | _exit(0); | |
71 | } |