Port of the dyndns.com update client ndyndns.
[openwrt/svn-archive/archive.git] / net / ndyndns / patches / ndyndns.patch
1 diff -Naur old/Makefile.in new/Makefile.in
2 --- old/Makefile.in 2007-09-13 10:56:00.000000000 -0700
3 +++ new/Makefile.in 2008-02-03 04:07:13.000000000 -0800
4 @@ -1,11 +1,9 @@
5 #CC = gcc -Wall -Wpointer-arith -Wstrict-prototypes -pedantic
6 CC = @CC@
7 -dnslib = -lnss_dns
8 objects = log.o nstrl.o util.o chroot.o pidfile.o signals.o strlist.o checkip.o $(PLATFORM).o cfg.o ndyndns.o
9 -CURLINC = @CURLINC@
10 CURLLIB = @CURLLIB@
11 VERSION = @VERSION@
12 -CFLAGS = @CFLAGS@ -Wall -Wpointer-arith -Wstrict-prototypes -pedantic $(CURLINC)
13 +CFLAGS += -Wall -Wpointer-arith -Wstrict-prototypes -pedantic
14 PLATFORM = @PLATFORM@
15 prefix = @prefix@
16 exec_prefix = @exec_prefix@
17 @@ -16,7 +14,7 @@
18 all: ndyndns
19
20 ndyndns : $(objects)
21 - $(CC) $(LDFLAGS) $(dnslib) $(CURLLIB) -o ndyndns $(objects)
22 + $(CC) $(LDFLAGS) $(CURLLIB) -o ndyndns $(objects)
23
24 ndyndns.o : log.h nstrl.h util.h chroot.h pidfile.h signals.h strlist.h checkip.h $(PLATFORM).h cfg.h
25 $(CC) $(CFLAGS) -c -o $@ ndyndns.c
26 diff -Naur old/chroot.c new/chroot.c
27 --- old/chroot.c 2007-03-13 15:54:12.000000000 -0700
28 +++ new/chroot.c 2008-02-03 04:10:21.000000000 -0800
29 @@ -18,8 +18,6 @@
30 #include <unistd.h>
31 #include <stdlib.h>
32 #include <string.h>
33 -#include <pwd.h>
34 -#include <grp.h>
35
36 #include "defines.h"
37 #include "log.h"
38 @@ -60,24 +58,4 @@
39 log_line("Failed to chdir(%s). Not invoking job.", path);
40 exit(EXIT_FAILURE);
41 }
42 -
43 - ret = chroot(path);
44 - if (ret) {
45 - log_line("Failed to chroot(%s). Not invoking job.", path);
46 - exit(EXIT_FAILURE);
47 - }
48 }
49 -
50 -void drop_root(uid_t uid, gid_t gid)
51 -{
52 - if (uid == 0 || gid == 0) {
53 - log_line("FATAL - drop_root: attempt to drop root to root?\n");
54 - exit(EXIT_FAILURE);
55 - }
56 -
57 - if (setregid(gid, gid) == -1 || setreuid(uid, uid) == -1) {
58 - log_line("FATAL - drop_root: failed to drop root!\n");
59 - exit(EXIT_FAILURE);
60 - }
61 -}
62 -
63 diff -Naur old/ndyndns.c new/ndyndns.c
64 --- old/ndyndns.c 2007-09-19 00:04:13.000000000 -0700
65 +++ new/ndyndns.c 2008-02-03 04:10:21.000000000 -0800
66 @@ -32,8 +32,6 @@
67 #include <net/if.h>
68 #include <ctype.h>
69 #include <time.h>
70 -#include <pwd.h>
71 -#include <grp.h>
72
73 #include <signal.h>
74 #include <errno.h>
75 @@ -728,12 +726,9 @@
76 }
77
78 int main(int argc, char** argv) {
79 - int c, t, uid = 0, gid = 0;
80 + int c, t;
81 char pidfile[MAX_PATH_LENGTH] = PID_FILE_DEFAULT;
82 char conffile[MAX_PATH_LENGTH] = CONF_FILE_DEFAULT;
83 - char *p;
84 - struct passwd *pws;
85 - struct group *grp;
86
87
88 while (1) {
89 @@ -745,8 +740,6 @@
90 {"quiet", 0, 0, 'q'},
91 {"chroot", 1, 0, 'c'},
92 {"file", 1, 0, 'f'},
93 - {"user", 1, 0, 'u'},
94 - {"group", 1, 0, 'g'},
95 {"interface", 1, 0, 'i'},
96 {"remote", 0, 0, 'r'},
97 {"help", 0, 0, 'h'},
98 @@ -754,7 +747,7 @@
99 {0, 0, 0, 0}
100 };
101
102 - c = getopt_long (argc, argv, "rdnp:qc:f:u:g:i:hv", long_options, &option_index);
103 + c = getopt_long (argc, argv, "rdnp:qc:f:i:hv", long_options, &option_index);
104 if (c == -1) break;
105
106 switch (c) {
107 @@ -771,8 +764,6 @@
108 " -f, --file configuration file\n"
109 " -p, --pidfile pidfile path\n");
110 printf(
111 -" -u, --user user name that ndyndns should run as\n"
112 -" -g, --group group name that ndyndns should run as\n"
113 " -i, --interface interface ip to check (default: ppp0)\n"
114 " -r, --remote get ip from remote dyndns host (overrides -i)\n"
115 " -h, --help print this help and exit\n"
116 @@ -817,39 +808,12 @@
117 strlcpy(pidfile, optarg, sizeof pidfile);
118 break;
119
120 - case 'u':
121 - t = (unsigned int) strtol(optarg, &p, 10);
122 - if (*p != '\0') {
123 - pws = getpwnam(optarg);
124 - if (pws) {
125 - uid = (int)pws->pw_uid;
126 - if (!gid)
127 - gid = (int)pws->pw_gid;
128 - } else suicide("FATAL - Invalid uid specified.\n");
129 - } else
130 - uid = t;
131 - break;
132 -
133 - case 'g':
134 - t = (unsigned int) strtol(optarg, &p, 10);
135 - if (*p != '\0') {
136 - grp = getgrnam(optarg);
137 - if (grp) {
138 - gid = (int)grp->gr_gid;
139 - } else suicide("FATAL - Invalid gid specified.\n");
140 - } else
141 - gid = t;
142 - break;
143 -
144 case 'i':
145 strlcpy(ifname, optarg, sizeof ifname);
146 break;
147 }
148 }
149
150 - if (getuid())
151 - suicide("FATAL - I need root for chroot!\n");
152 -
153 if (gflags_detach)
154 if (daemon(0,0))
155 suicide("FATAL - detaching fork failed\n");
156 @@ -870,7 +834,6 @@
157
158 /* Note that failure cases are handled by called fns. */
159 imprison(get_chroot());
160 - drop_root(uid, gid);
161
162 /* Cover our tracks... */
163 wipe_chroot();