1 diff -urN ndyndns-2.1.orig/cfg.c ndyndns-2.1/cfg.c
2 --- ndyndns-2.1.orig/cfg.c 2011-01-26 17:02:05.762443700 +0100
3 +++ ndyndns-2.1/cfg.c 2011-01-26 17:03:43.334443683 +0100
8 - tmp = parse_line_string(point, "user");
12 - parse_warn(lnum, "user");
22 - tmp = parse_line_string(point, "group");
26 - parse_warn(lnum, "group");
36 tmp = parse_line_string(point, "interface");
39 diff -urN ndyndns-2.1.orig/chroot.c ndyndns-2.1/chroot.c
40 --- ndyndns-2.1.orig/chroot.c 2011-01-26 17:02:05.762443700 +0100
41 +++ ndyndns-2.1/chroot.c 2011-01-26 17:03:54.470442525 +0100
56 -void drop_root(uid_t uid, gid_t gid)
58 - if (uid == 0 || gid == 0) {
59 - log_line("FATAL - drop_root: attempt to drop root to root?\n");
63 - if (getgid() == 0) {
64 - if (setregid(gid, gid) == -1) {
65 - log_line("FATAL - drop_root: failed to drop real gid == root!\n");
70 - if (getuid() == 0) {
71 - if (setreuid(uid, uid) == -1) {
72 - log_line("FATAL - drop_root: failed to drop real uid == root!\n");
77 - /* be absolutely sure */
78 - if (getgid() == 0 || getuid() == 0) {
79 - log_line("FATAL - drop_root: tried to drop root, but still have root!\n");
84 diff -urN ndyndns-2.1.orig/Makefile.in ndyndns-2.1/Makefile.in
85 --- ndyndns-2.1.orig/Makefile.in 2011-01-26 17:02:05.766443748 +0100
86 +++ ndyndns-2.1/Makefile.in 2011-01-26 17:03:43.338443633 +0100
88 #CC = gcc -Wall -Wpointer-arith -Wstrict-prototypes -pedantic
91 objects = log.o nstrl.o util.o chroot.o pidfile.o signals.o strlist.o checkip.o $(PLATFORM).o cfg.o ndyndns.o
95 -CFLAGS = @CFLAGS@ -Wall -Wextra -pedantic $(CURLINC)
96 +CFLAGS += -Wall -Wpointer-arith -Wstrict-prototypes -pedantic
99 exec_prefix = @exec_prefix@
104 - $(CC) $(LDFLAGS) $(dnslib) $(CURLLIB) -o ndyndns $(objects)
105 + $(CC) $(LDFLAGS) $(CURLLIB) -o ndyndns $(objects)
107 ndyndns.o : log.h nstrl.h util.h chroot.h pidfile.h signals.h strlist.h checkip.h $(PLATFORM).h cfg.h
108 $(CC) $(CFLAGS) -c -o $@ ndyndns.c
109 diff -urN ndyndns-2.1.orig/ndyndns.c ndyndns-2.1/ndyndns.c
110 --- ndyndns-2.1.orig/ndyndns.c 2011-01-26 17:02:05.766443748 +0100
111 +++ ndyndns-2.1/ndyndns.c 2011-01-26 17:04:15.526443092 +0100
122 strlcpy(pidfile, pidfname, sizeof pidfile);
125 -void cfg_set_user(char *username)
129 - struct passwd *pws;
131 - t = (unsigned int) strtol(username, &p, 10);
133 - pws = getpwnam(username);
135 - cfg_uid = (int)pws->pw_uid;
137 - cfg_gid = (int)pws->pw_gid;
138 - } else suicide("FATAL - Invalid uid specified.\n");
143 -void cfg_set_group(char *groupname)
149 - t = (unsigned int) strtol(groupname, &p, 10);
151 - grp = getgrnam(groupname);
153 - cfg_gid = (int)grp->gr_gid;
154 - } else suicide("FATAL - Invalid gid specified.\n");
159 void cfg_set_interface(char *interface)
161 strlcpy(ifname, interface, sizeof ifname);
163 {"disable-chroot", 0, 0, 'x'},
165 {"cfg-stdin", 0, 0, 'F'},
166 - {"user", 1, 0, 'u'},
167 - {"group", 1, 0, 'g'},
168 {"interface", 1, 0, 'i'},
169 {"remote", 0, 0, 'r'},
175 - c = getopt_long(argc, argv, "rdnp:qc:xf:Fu:g:i:hv", long_options, &option_index);
176 + c = getopt_long(argc, argv, "rdnp:qc:xf:i:hv", long_options, &option_index);
181 " -F, --cfg-stdin read configuration file from standard input\n"
182 " -p, --pidfile pidfile path\n");
184 - " -u, --user user name that ndyndns should run as\n"
185 - " -g, --group group name that ndyndns should run as\n"
186 " -i, --interface interface ip to check (default: ppp0)\n"
187 " -r, --remote get ip from remote dyndns host (overrides -i)\n"
188 " -h, --help print this help and exit\n"
189 @@ -1060,14 +1020,6 @@
190 cfg_set_pidfile(optarg);
194 - cfg_set_user(optarg);
198 - cfg_set_group(optarg);
202 cfg_set_interface(optarg);
204 @@ -1095,7 +1047,6 @@
206 /* Note that failure cases are handled by called fns. */
207 imprison(get_chroot());
208 - drop_root(cfg_uid, cfg_gid);
210 /* Cover our tracks... */