add packages_10.03.2 in preparation for the 10.03.2 interim release
[10.03/packages.git] / net / ndyndns / patches / 020-ndyndns.patch
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
4 @@ -804,34 +804,6 @@
5              continue;
6          }
7  
8 -        tmp = parse_line_string(point, "user");
9 -        if (tmp) {
10 -            switch (prs) {
11 -                default:
12 -                    parse_warn(lnum, "user");
13 -                    break;
14 -                case PRS_CONFIG:
15 -                    cfg_set_user(tmp);
16 -                    break;
17 -            }
18 -            free(tmp);
19 -            continue;
20 -        }
21 -
22 -        tmp = parse_line_string(point, "group");
23 -        if (tmp) {
24 -            switch (prs) {
25 -                default:
26 -                    parse_warn(lnum, "group");
27 -                    break;
28 -                case PRS_CONFIG:
29 -                    cfg_set_group(tmp);
30 -                    break;
31 -            }
32 -            free(tmp);
33 -            continue;
34 -        }
35 -
36          tmp = parse_line_string(point, "interface");
37          if (tmp) {
38              switch (prs) {
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
42 @@ -19,8 +19,6 @@
43  #include <unistd.h>
44  #include <stdlib.h>
45  #include <string.h>
46 -#include <pwd.h>
47 -#include <grp.h>
48  
49  #include "defines.h"
50  #include "log.h"
51 @@ -82,32 +80,3 @@
52          }
53      }
54  }
55 -
56 -void drop_root(uid_t uid, gid_t gid)
57 -{
58 -    if (uid == 0 || gid == 0) {
59 -        log_line("FATAL - drop_root: attempt to drop root to root?\n");
60 -        exit(EXIT_FAILURE);
61 -    }
62 -
63 -    if (getgid() == 0) {
64 -        if (setregid(gid, gid) == -1) {
65 -            log_line("FATAL - drop_root: failed to drop real gid == root!\n");
66 -            exit(EXIT_FAILURE);
67 -        }
68 -    }
69 -
70 -    if (getuid() == 0) {
71 -        if (setreuid(uid, uid) == -1) {
72 -            log_line("FATAL - drop_root: failed to drop real uid == root!\n");
73 -            exit(EXIT_FAILURE);
74 -        }
75 -    }
76 -
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");
80 -        exit(EXIT_FAILURE);
81 -    }
82 -}
83 -
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
87 @@ -1,11 +1,9 @@
88  #CC = gcc -Wall -Wpointer-arith -Wstrict-prototypes -pedantic
89  CC = @CC@
90 -dnslib = -lnss_dns
91  objects = log.o nstrl.o util.o chroot.o pidfile.o signals.o strlist.o checkip.o $(PLATFORM).o cfg.o ndyndns.o
92 -CURLINC = @CURLINC@
93  CURLLIB = @CURLLIB@
94  VERSION = @VERSION@
95 -CFLAGS = @CFLAGS@ -Wall -Wextra -pedantic $(CURLINC)
96 +CFLAGS += -Wall -Wpointer-arith -Wstrict-prototypes -pedantic
97  PLATFORM = @PLATFORM@
98  prefix = @prefix@
99  exec_prefix = @exec_prefix@
100 @@ -16,7 +14,7 @@
101  all: ndyndns
102  
103  ndyndns : $(objects)
104 -       $(CC) $(LDFLAGS) $(dnslib) $(CURLLIB) -o ndyndns $(objects)
105 +       $(CC) $(LDFLAGS) $(CURLLIB) -o ndyndns $(objects)
106  
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
112 @@ -32,8 +32,6 @@
113  #include <net/if.h>
114  #include <ctype.h>
115  #include <time.h>
116 -#include <pwd.h>
117 -#include <grp.h>
118  
119  #include <signal.h>
120  #include <errno.h>
121 @@ -897,40 +895,6 @@
122      strlcpy(pidfile, pidfname, sizeof pidfile);
123  }
124  
125 -void cfg_set_user(char *username)
126 -{
127 -    int t;
128 -    char *p;
129 -    struct passwd *pws;
130 -
131 -    t = (unsigned int) strtol(username, &p, 10);
132 -    if (*p != '\0') {
133 -        pws = getpwnam(username);
134 -        if (pws) {
135 -            cfg_uid = (int)pws->pw_uid;
136 -            if (!cfg_gid)
137 -                cfg_gid = (int)pws->pw_gid;
138 -        } else suicide("FATAL - Invalid uid specified.\n");
139 -    } else
140 -        cfg_uid = t;
141 -}
142 -
143 -void cfg_set_group(char *groupname)
144 -{
145 -    int t;
146 -    char *p;
147 -    struct group *grp;
148 -
149 -    t = (unsigned int) strtol(groupname, &p, 10);
150 -    if (*p != '\0') {
151 -        grp = getgrnam(groupname);
152 -        if (grp) {
153 -            cfg_gid = (int)grp->gr_gid;
154 -        } else suicide("FATAL - Invalid gid specified.\n");
155 -    } else
156 -        cfg_gid = t;
157 -}
158 -
159  void cfg_set_interface(char *interface)
160  {
161      strlcpy(ifname, interface, sizeof ifname);
162 @@ -954,8 +918,6 @@
163              {"disable-chroot", 0, 0, 'x'},
164              {"file", 1, 0, 'f'},
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'},
170              {"help", 0, 0, 'h'},
171 @@ -963,7 +925,7 @@
172              {0, 0, 0, 0}
173          };
174  
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);
177          if (c == -1) break;
178  
179          switch (c) {
180 @@ -983,8 +945,6 @@
181                      "  -F, --cfg-stdin             read configuration file from standard input\n"
182                      "  -p, --pidfile               pidfile path\n");
183                  printf(
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);
191                  break;
192  
193 -            case 'u':
194 -                cfg_set_user(optarg);
195 -                break;
196 -
197 -            case 'g':
198 -                cfg_set_group(optarg);
199 -                break;
200 -
201              case 'i':
202                  cfg_set_interface(optarg);
203                  break;
204 @@ -1095,7 +1047,6 @@
205  
206      /* Note that failure cases are handled by called fns. */
207      imprison(get_chroot());
208 -    drop_root(cfg_uid, cfg_gid);
209  
210      /* Cover our tracks... */
211      wipe_chroot();