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
5 #CC = gcc -Wall -Wpointer-arith -Wstrict-prototypes -pedantic
8 objects = log.o nstrl.o util.o chroot.o pidfile.o signals.o strlist.o checkip.o $(PLATFORM).o cfg.o ndyndns.o
12 -CFLAGS = @CFLAGS@ -Wall -Wpointer-arith -Wstrict-prototypes -pedantic $(CURLINC)
13 +CFLAGS += -Wall -Wpointer-arith -Wstrict-prototypes -pedantic
16 exec_prefix = @exec_prefix@
21 - $(CC) $(LDFLAGS) $(dnslib) $(CURLLIB) -o ndyndns $(objects)
22 + $(CC) $(LDFLAGS) $(CURLLIB) -o ndyndns $(objects)
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
39 log_line("Failed to chdir(%s). Not invoking job.", path);
45 - log_line("Failed to chroot(%s). Not invoking job.", path);
50 -void drop_root(uid_t uid, gid_t gid)
52 - if (uid == 0 || gid == 0) {
53 - log_line("FATAL - drop_root: attempt to drop root to root?\n");
57 - if (setregid(gid, gid) == -1 || setreuid(uid, uid) == -1) {
58 - log_line("FATAL - drop_root: failed to drop root!\n");
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
78 int main(int argc, char** argv) {
79 - int c, t, uid = 0, gid = 0;
81 char pidfile[MAX_PATH_LENGTH] = PID_FILE_DEFAULT;
82 char conffile[MAX_PATH_LENGTH] = CONF_FILE_DEFAULT;
91 {"chroot", 1, 0, 'c'},
93 - {"user", 1, 0, 'u'},
94 - {"group", 1, 0, 'g'},
95 {"interface", 1, 0, 'i'},
96 {"remote", 0, 0, 'r'},
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);
108 " -f, --file configuration file\n"
109 " -p, --pidfile pidfile path\n");
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);
121 - t = (unsigned int) strtol(optarg, &p, 10);
123 - pws = getpwnam(optarg);
125 - uid = (int)pws->pw_uid;
127 - gid = (int)pws->pw_gid;
128 - } else suicide("FATAL - Invalid uid specified.\n");
134 - t = (unsigned int) strtol(optarg, &p, 10);
136 - grp = getgrnam(optarg);
138 - gid = (int)grp->gr_gid;
139 - } else suicide("FATAL - Invalid gid specified.\n");
145 strlcpy(ifname, optarg, sizeof ifname);
151 - suicide("FATAL - I need root for chroot!\n");
155 suicide("FATAL - detaching fork failed\n");
158 /* Note that failure cases are handled by called fns. */
159 imprison(get_chroot());
160 - drop_root(uid, gid);
162 /* Cover our tracks... */