/[pkgs]/devel/dhcp/dhcp-4.1.0-CLOEXEC.patch
ViewVC logotype

Contents of /devel/dhcp/dhcp-4.1.0-CLOEXEC.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Tue Jan 6 23:46:50 2009 UTC (10 months, 2 weeks ago) by dcantrel
Branch: MAIN
CVS Tags: F-12-split, dhcp-4_1_0-3_fc11, dhcp-4_1_0-2_fc11, dhcp-4_1_0-22_fc12, dhcp-4_1_0-1_fc11, dhcp-4_1_0-20_fc12, dhcp-4_1_0p1-5_fc12, dhcp-4_1_0-16_fc11, dhcp-4_1_0p1-13_fc13, dhcp-4_1_0-11_fc11, dhcp-4_1_0p1-11_fc12, dhcp-4_1_0-10_fc11, dhcp-4_1_0-15_fc11, dhcp-4_1_0-12_fc11, dhcp-4_1_0-14_fc11, F-11-split, dhcp-4_1_0p1-6_fc12, dhcp-4_1_0p1-7_fc12, dhcp-4_1_0p1-8_fc12, dhcp-4_1_0-4_fc11, dhcp-4_1_0p1-4_fc12, dhcp-4_1_0-13_fc11, dhcp-4_1_0-18_fc12, dhcp-4_1_0p1-14_fc13, dhcp-4_1_0-23_fc12, dhcp-4_1_0-6_fc11, dhcp-4_1_0-17_fc12, dhcp-4_1_0-19_fc12, dhcp-4_1_0p1-1_fc12, dhcp-4_1_0p1-3_fc12, dhcp-4_1_0p1-9_fc12, dhcp-4_1_0-9_fc11, dhcp-4_1_0p1-12_fc13, dhcp-4_1_0-26_fc12, dhcp-4_1_0p1-10_fc12, dhcp-4_1_0-8_fc11, dhcp-4_1_0-5_fc11, dhcp-4_1_0-25_fc12, dhcp-4_1_0-24_fc12, dhcp-4_1_0-7_fc11, dhcp-4_1_0-27_fc12, dhcp-4_1_0-21_fc12, dhcp-4_1_0p1-2_fc12, HEAD
File MIME type: text/x-patch
* Tue Jan 06 2009 David Cantrell <dcantrell@redhat.com> - 12:4.1.0-1
- Upgraded to ISC dhcp-4.1.0
- Had to rename the -T option to -timeout as ISC is now using -T
- Allow package rebuilders to easily enable DHCPv6 support with:
      rpmbuild --with DHCPv6 dhcp.spec
  Note that Fedora is still using the 'dhcpv6' package, but some
  users may want to experiment with the ISC DHCPv6 implementation
  locally.
1 diff -up dhcp-4.1.0/client/clparse.c.cloexec dhcp-4.1.0/client/clparse.c
2 --- dhcp-4.1.0/client/clparse.c.cloexec 2009-01-06 11:56:11.000000000 -1000
3 +++ dhcp-4.1.0/client/clparse.c 2009-01-06 12:04:48.000000000 -1000
4 @@ -226,7 +226,7 @@ int read_client_conf_file (const char *n
5 int token;
6 isc_result_t status;
7
8 - if ((file = open (name, O_RDONLY)) < 0)
9 + if ((file = open (name, O_RDONLY | O_CLOEXEC)) < 0)
10 return uerr2isc (errno);
11
12 cfile = NULL;
13 @@ -263,7 +263,7 @@ void read_client_leases ()
14
15 /* Open the lease file. If we can't open it, just return -
16 we can safely trust the server to remember our state. */
17 - if ((file = open (path_dhclient_db, O_RDONLY)) < 0)
18 + if ((file = open (path_dhclient_db, O_RDONLY | O_CLOEXEC)) < 0)
19 return;
20
21 cfile = NULL;
22 diff -up dhcp-4.1.0/client/dhclient.c.cloexec dhcp-4.1.0/client/dhclient.c
23 --- dhcp-4.1.0/client/dhclient.c.cloexec 2009-01-06 11:56:10.000000000 -1000
24 +++ dhcp-4.1.0/client/dhclient.c 2009-01-06 12:04:01.000000000 -1000
25 @@ -135,11 +135,11 @@ main(int argc, char **argv) {
26 /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
27 2 (stderr) are open. To do this, we assume that when we
28 open a file the lowest available file descriptor is used. */
29 - fd = open("/dev/null", O_RDWR);
30 + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
31 if (fd == 0)
32 - fd = open("/dev/null", O_RDWR);
33 + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
34 if (fd == 1)
35 - fd = open("/dev/null", O_RDWR);
36 + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
37 if (fd == 2)
38 log_perror = 0; /* No sense logging to /dev/null. */
39 else if (fd != -1)
40 @@ -465,7 +465,7 @@ main(int argc, char **argv) {
41 int e;
42
43 oldpid = 0;
44 - if ((pidfd = fopen(path_dhclient_pid, "r")) != NULL) {
45 + if ((pidfd = fopen(path_dhclient_pid, "re")) != NULL) {
46 e = fscanf(pidfd, "%ld\n", &temp);
47 oldpid = (pid_t)temp;
48
49 @@ -507,7 +507,7 @@ main(int argc, char **argv) {
50 strncpy(new_path_dhclient_pid, path_dhclient_pid, pfx);
51 sprintf(new_path_dhclient_pid + pfx, "-%s.pid", ip->name);
52
53 - if ((pidfd = fopen(new_path_dhclient_pid, "r")) != NULL) {
54 + if ((pidfd = fopen(new_path_dhclient_pid, "re")) != NULL) {
55 e = fscanf(pidfd, "%ld\n", &temp);
56 oldpid = (pid_t)temp;
57
58 @@ -532,7 +532,7 @@ main(int argc, char **argv) {
59 int dhc_running = 0;
60 char procfn[256] = "";
61
62 - if ((pidfp = fopen(path_dhclient_pid, "r")) != NULL) {
63 + if ((pidfp = fopen(path_dhclient_pid, "re")) != NULL) {
64 if ((fscanf(pidfp, "%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) {
65 snprintf(procfn,256,"/proc/%u",dhcpid);
66 dhc_running = (access(procfn, F_OK) == 0);
67 @@ -2908,7 +2908,7 @@ void rewrite_client_leases ()
68
69 if (leaseFile != NULL)
70 fclose (leaseFile);
71 - leaseFile = fopen (path_dhclient_db, "w");
72 + leaseFile = fopen (path_dhclient_db, "we");
73 if (leaseFile == NULL) {
74 log_error ("can't create %s: %m", path_dhclient_db);
75 return;
76 @@ -3012,7 +3012,7 @@ write_duid(struct data_string *duid)
77 return ISC_R_INVALIDARG;
78
79 if (leaseFile == NULL) { /* XXX? */
80 - leaseFile = fopen(path_dhclient_db, "w");
81 + leaseFile = fopen(path_dhclient_db, "we");
82 if (leaseFile == NULL) {
83 log_error("can't create %s: %m", path_dhclient_db);
84 return ISC_R_IOERROR;
85 @@ -3192,7 +3192,7 @@ int write_client_lease (client, lease, r
86 return 1;
87
88 if (leaseFile == NULL) { /* XXX */
89 - leaseFile = fopen (path_dhclient_db, "w");
90 + leaseFile = fopen (path_dhclient_db, "we");
91 if (leaseFile == NULL) {
92 log_error ("can't create %s: %m", path_dhclient_db);
93 return 0;
94 @@ -3638,9 +3638,9 @@ void go_daemon ()
95 close(2);
96
97 /* Reopen them on /dev/null. */
98 - open("/dev/null", O_RDWR);
99 - open("/dev/null", O_RDWR);
100 - open("/dev/null", O_RDWR);
101 + open("/dev/null", O_RDWR | O_CLOEXEC);
102 + open("/dev/null", O_RDWR | O_CLOEXEC);
103 + open("/dev/null", O_RDWR | O_CLOEXEC);
104
105 write_client_pid_file ();
106
107 @@ -3652,14 +3652,14 @@ void write_client_pid_file ()
108 FILE *pf;
109 int pfdesc;
110
111 - pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY, 0644);
112 + pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
113
114 if (pfdesc < 0) {
115 log_error ("Can't create %s: %m", path_dhclient_pid);
116 return;
117 }
118
119 - pf = fdopen (pfdesc, "w");
120 + pf = fdopen (pfdesc, "we");
121 if (!pf)
122 log_error ("Can't fdopen %s: %m", path_dhclient_pid);
123 else {
124 diff -up dhcp-4.1.0/common/bpf.c.cloexec dhcp-4.1.0/common/bpf.c
125 --- dhcp-4.1.0/common/bpf.c.cloexec 2009-01-06 11:56:11.000000000 -1000
126 +++ dhcp-4.1.0/common/bpf.c 2009-01-06 11:56:11.000000000 -1000
127 @@ -94,7 +94,7 @@ int if_register_bpf (info)
128 for (b = 0; 1; b++) {
129 /* %Audit% 31 bytes max. %2004.06.17,Safe% */
130 sprintf(filename, BPF_FORMAT, b);
131 - sock = open (filename, O_RDWR, 0);
132 + sock = open (filename, O_RDWR | O_CLOEXEC, 0);
133 if (sock < 0) {
134 if (errno == EBUSY) {
135 continue;
136 diff -up dhcp-4.1.0/common/discover.c.cloexec dhcp-4.1.0/common/discover.c
137 --- dhcp-4.1.0/common/discover.c.cloexec 2008-08-29 07:48:57.000000000 -1000
138 +++ dhcp-4.1.0/common/discover.c 2009-01-06 11:56:11.000000000 -1000
139 @@ -409,7 +409,7 @@ begin_iface_scan(struct iface_conf_list
140 int len;
141 int i;
142
143 - ifaces->fp = fopen("/proc/net/dev", "r");
144 + ifaces->fp = fopen("/proc/net/dev", "re");
145 if (ifaces->fp == NULL) {
146 log_error("Error opening '/proc/net/dev' to list interfaces");
147 return 0;
148 @@ -443,7 +443,7 @@ begin_iface_scan(struct iface_conf_list
149 }
150
151 #ifdef DHCPv6
152 - ifaces->fp6 = fopen("/proc/net/if_inet6", "r");
153 + ifaces->fp6 = fopen("/proc/net/if_inet6", "re");
154 if (ifaces->fp6 == NULL) {
155 log_error("Error opening '/proc/net/if_inet6' to "
156 "list IPv6 interfaces; %m");
157 diff -up dhcp-4.1.0/common/dlpi.c.cloexec dhcp-4.1.0/common/dlpi.c
158 --- dhcp-4.1.0/common/dlpi.c.cloexec 2009-01-06 11:56:11.000000000 -1000
159 +++ dhcp-4.1.0/common/dlpi.c 2009-01-06 11:56:11.000000000 -1000
160 @@ -795,7 +795,7 @@ dlpiopen(const char *ifname) {
161 }
162 *dp = '\0';
163
164 - return open (devname, O_RDWR, 0);
165 + return open (devname, O_RDWR | O_CLOEXEC, 0);
166 }
167
168 /*
169 diff -up dhcp-4.1.0/common/nit.c.cloexec dhcp-4.1.0/common/nit.c
170 --- dhcp-4.1.0/common/nit.c.cloexec 2009-01-06 11:56:11.000000000 -1000
171 +++ dhcp-4.1.0/common/nit.c 2009-01-06 11:56:11.000000000 -1000
172 @@ -81,7 +81,7 @@ int if_register_nit (info)
173 struct strioctl sio;
174
175 /* Open a NIT device */
176 - sock = open ("/dev/nit", O_RDWR);
177 + sock = open ("/dev/nit", O_RDWR | O_CLOEXEC);
178 if (sock < 0)
179 log_fatal ("Can't open NIT device for %s: %m", info -> name);
180
181 diff -up dhcp-4.1.0/common/resolv.c.cloexec dhcp-4.1.0/common/resolv.c
182 --- dhcp-4.1.0/common/resolv.c.cloexec 2008-03-07 10:12:44.000000000 -1000
183 +++ dhcp-4.1.0/common/resolv.c 2009-01-06 12:05:17.000000000 -1000
184 @@ -49,7 +49,7 @@ void read_resolv_conf (parse_time)
185 struct domain_search_list *dp, *dl, *nd;
186 isc_result_t status;
187
188 - if ((file = open (path_resolv_conf, O_RDONLY)) < 0) {
189 + if ((file = open (path_resolv_conf, O_RDONLY | O_CLOEXEC)) < 0) {
190 log_error ("Can't open %s: %m", path_resolv_conf);
191 return;
192 }
193 diff -up dhcp-4.1.0/common/upf.c.cloexec dhcp-4.1.0/common/upf.c
194 --- dhcp-4.1.0/common/upf.c.cloexec 2009-01-06 11:56:11.000000000 -1000
195 +++ dhcp-4.1.0/common/upf.c 2009-01-06 11:56:11.000000000 -1000
196 @@ -77,7 +77,7 @@ int if_register_upf (info)
197 /* %Audit% Cannot exceed 36 bytes. %2004.06.17,Safe% */
198 sprintf(filename, "/dev/pf/pfilt%d", b);
199
200 - sock = open (filename, O_RDWR, 0);
201 + sock = open (filename, O_RDWR | O_CLOEXEC, 0);
202 if (sock < 0) {
203 if (errno == EBUSY) {
204 continue;
205 diff -up dhcp-4.1.0/dst/dst_api.c.cloexec dhcp-4.1.0/dst/dst_api.c
206 --- dhcp-4.1.0/dst/dst_api.c.cloexec 2007-11-30 11:51:43.000000000 -1000
207 +++ dhcp-4.1.0/dst/dst_api.c 2009-01-06 11:56:11.000000000 -1000
208 @@ -436,7 +436,7 @@ dst_s_write_private_key(const DST_KEY *k
209 PRIVATE_KEY, PATH_MAX);
210
211 /* Do not overwrite an existing file */
212 - if ((fp = dst_s_fopen(file, "w", 0600)) != NULL) {
213 + if ((fp = dst_s_fopen(file, "we", 0600)) != NULL) {
214 int nn;
215 if ((nn = fwrite(encoded_block, 1, len, fp)) != len) {
216 EREPORT(("dst_write_private_key(): Write failure on %s %d != %d errno=%d\n",
217 @@ -493,7 +493,7 @@ dst_s_read_public_key(const char *in_nam
218 * flags, proto, alg stored as decimal (or hex numbers FIXME).
219 * (FIXME: handle parentheses for line continuation.)
220 */
221 - if ((fp = dst_s_fopen(name, "r", 0)) == NULL) {
222 + if ((fp = dst_s_fopen(name, "re", 0)) == NULL) {
223 EREPORT(("dst_read_public_key(): Public Key not found %s\n",
224 name));
225 return (NULL);
226 @@ -615,7 +615,7 @@ dst_s_write_public_key(const DST_KEY *ke
227 return (0);
228 }
229 /* create public key file */
230 - if ((fp = dst_s_fopen(filename, "w+", 0644)) == NULL) {
231 + if ((fp = dst_s_fopen(filename, "w+e", 0644)) == NULL) {
232 EREPORT(("DST_write_public_key: open of file:%s failed (errno=%d)\n",
233 filename, errno));
234 return (0);
235 @@ -849,7 +849,7 @@ dst_s_read_private_key_file(char *name,
236 return (0);
237 }
238 /* first check if we can find the key file */
239 - if ((fp = dst_s_fopen(filename, "r", 0)) == NULL) {
240 + if ((fp = dst_s_fopen(filename, "re", 0)) == NULL) {
241 EREPORT(("dst_s_read_private_key_file: Could not open file %s in directory %s\n",
242 filename, dst_path[0] ? dst_path :
243 (char *) getcwd(NULL, PATH_MAX - 1)));
244 diff -up dhcp-4.1.0/dst/prandom.c.cloexec dhcp-4.1.0/dst/prandom.c
245 --- dhcp-4.1.0/dst/prandom.c.cloexec 2007-11-30 11:51:43.000000000 -1000
246 +++ dhcp-4.1.0/dst/prandom.c 2009-01-06 11:56:11.000000000 -1000
247 @@ -267,7 +267,7 @@ get_dev_random(u_char *output, unsigned
248
249 s = stat("/dev/random", &st);
250 if (s == 0 && S_ISCHR(st.st_mode)) {
251 - if ((fd = open("/dev/random", O_RDONLY | O_NONBLOCK)) != -1) {
252 + if ((fd = open("/dev/random", O_RDONLY | O_NONBLOCK | O_CLOEXEC)) != -1) {
253 if ((n = read(fd, output, size)) < 0)
254 n = 0;
255 close(fd);
256 @@ -478,7 +478,7 @@ digest_file(dst_work *work)
257 work->file_digest = dst_free_key(work->file_digest);
258 return (0);
259 }
260 - if ((fp = fopen(name, "r")) == NULL)
261 + if ((fp = fopen(name, "re")) == NULL)
262 return (0);
263 for (no = 0; (i = fread(buf, sizeof(*buf), sizeof(buf), fp)) > 0;
264 no += i)
265 diff -up dhcp-4.1.0/minires/res_init.c.cloexec dhcp-4.1.0/minires/res_init.c
266 --- dhcp-4.1.0/minires/res_init.c.cloexec 2008-02-28 11:21:56.000000000 -1000
267 +++ dhcp-4.1.0/minires/res_init.c 2009-01-06 11:56:11.000000000 -1000
268 @@ -233,7 +233,7 @@ minires_vinit(res_state statp, int prein
269 (line[sizeof(name) - 1] == ' ' || \
270 line[sizeof(name) - 1] == '\t'))
271
272 - if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
273 + if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) {
274 /* read the config file */
275 while (fgets(buf, sizeof(buf), fp) != NULL) {
276 /* skip comments */
277 diff -up dhcp-4.1.0/minires/res_query.c.cloexec dhcp-4.1.0/minires/res_query.c
278 --- dhcp-4.1.0/minires/res_query.c.cloexec 2008-02-28 11:21:56.000000000 -1000
279 +++ dhcp-4.1.0/minires/res_query.c 2009-01-06 11:56:11.000000000 -1000
280 @@ -379,7 +379,7 @@ res_hostalias(const res_state statp, con
281 if (statp->options & RES_NOALIASES)
282 return (NULL);
283 file = getenv("HOSTALIASES");
284 - if (file == NULL || (fp = fopen(file, "r")) == NULL)
285 + if (file == NULL || (fp = fopen(file, "re")) == NULL)
286 return (NULL);
287 setbuf(fp, NULL);
288 buf[sizeof(buf) - 1] = '\0';
289 diff -up dhcp-4.1.0/omapip/trace.c.cloexec dhcp-4.1.0/omapip/trace.c
290 --- dhcp-4.1.0/omapip/trace.c.cloexec 2007-07-12 20:43:42.000000000 -1000
291 +++ dhcp-4.1.0/omapip/trace.c 2009-01-06 11:56:11.000000000 -1000
292 @@ -140,10 +140,10 @@ isc_result_t trace_begin (const char *fi
293 return ISC_R_INVALIDARG;
294 }
295
296 - traceoutfile = open (filename, O_CREAT | O_WRONLY | O_EXCL, 0600);
297 + traceoutfile = open (filename, O_CREAT | O_WRONLY | O_EXCL | O_CLOEXEC, 0600);
298 if (traceoutfile < 0 && errno == EEXIST) {
299 log_error ("WARNING: Overwriting trace file \"%s\"", filename);
300 - traceoutfile = open (filename, O_WRONLY | O_EXCL, 0600);
301 + traceoutfile = open (filename, O_WRONLY | O_EXCL | O_CLOEXEC, 0600);
302 }
303
304 if (traceoutfile < 0) {
305 @@ -429,7 +429,7 @@ void trace_file_replay (const char *file
306 isc_result_t result;
307 int len;
308
309 - traceinfile = fopen (filename, "r");
310 + traceinfile = fopen (filename, "re");
311 if (!traceinfile) {
312 log_error ("Can't open tracefile %s: %m", filename);
313 return;
314 diff -up dhcp-4.1.0/relay/dhcrelay.c.cloexec dhcp-4.1.0/relay/dhcrelay.c
315 --- dhcp-4.1.0/relay/dhcrelay.c.cloexec 2008-11-12 13:22:14.000000000 -1000
316 +++ dhcp-4.1.0/relay/dhcrelay.c 2009-01-06 12:06:23.000000000 -1000
317 @@ -174,11 +174,11 @@ main(int argc, char **argv) {
318 /* Make sure that file descriptors 0(stdin), 1,(stdout), and
319 2(stderr) are open. To do this, we assume that when we
320 open a file the lowest available file descriptor is used. */
321 - fd = open("/dev/null", O_RDWR);
322 + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
323 if (fd == 0)
324 - fd = open("/dev/null", O_RDWR);
325 + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
326 if (fd == 1)
327 - fd = open("/dev/null", O_RDWR);
328 + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
329 if (fd == 2)
330 log_perror = 0; /* No sense logging to /dev/null. */
331 else if (fd != -1)
332 @@ -511,12 +511,12 @@ main(int argc, char **argv) {
333 exit(0);
334
335 pfdesc = open(path_dhcrelay_pid,
336 - O_CREAT | O_TRUNC | O_WRONLY, 0644);
337 + O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
338
339 if (pfdesc < 0) {
340 log_error("Can't create %s: %m", path_dhcrelay_pid);
341 } else {
342 - pf = fdopen(pfdesc, "w");
343 + pf = fdopen(pfdesc, "we");
344 if (!pf)
345 log_error("Can't fdopen %s: %m",
346 path_dhcrelay_pid);
347 diff -up dhcp-4.1.0/server/confpars.c.cloexec dhcp-4.1.0/server/confpars.c
348 --- dhcp-4.1.0/server/confpars.c.cloexec 2009-01-06 11:56:10.000000000 -1000
349 +++ dhcp-4.1.0/server/confpars.c 2009-01-06 11:56:11.000000000 -1000
350 @@ -116,7 +116,7 @@ isc_result_t read_conf_file (const char
351 }
352 #endif
353
354 - if ((file = open (filename, O_RDONLY)) < 0) {
355 + if ((file = open (filename, O_RDONLY | O_CLOEXEC)) < 0) {
356 if (leasep) {
357 log_error ("Can't open lease database %s: %m --",
358 path_dhcpd_db);
359 diff -up dhcp-4.1.0/server/db.c.cloexec dhcp-4.1.0/server/db.c
360 --- dhcp-4.1.0/server/db.c.cloexec 2008-03-31 03:49:45.000000000 -1000
361 +++ dhcp-4.1.0/server/db.c 2009-01-06 11:56:11.000000000 -1000
362 @@ -1021,7 +1021,7 @@ void db_startup (testp)
363 }
364 #endif
365 if (!testp) {
366 - db_file = fopen (path_dhcpd_db, "a");
367 + db_file = fopen (path_dhcpd_db, "ae");
368 if (!db_file)
369 log_fatal ("Can't open %s for append.", path_dhcpd_db);
370 expire_all_pools ();
371 @@ -1069,12 +1069,12 @@ int new_lease_file ()
372 path_dhcpd_db, (int)t) >= sizeof newfname)
373 log_fatal("new_lease_file: lease file path too long");
374
375 - db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT, 0664);
376 + db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0664);
377 if (db_fd < 0) {
378 log_error ("Can't create new lease file: %m");
379 return 0;
380 }
381 - if ((new_db_file = fdopen(db_fd, "w")) == NULL) {
382 + if ((new_db_file = fdopen(db_fd, "we")) == NULL) {
383 log_error("Can't fdopen new lease file: %m");
384 close(db_fd);
385 goto fdfail;
386 diff -up dhcp-4.1.0/server/dhcpd.c.cloexec dhcp-4.1.0/server/dhcpd.c
387 --- dhcp-4.1.0/server/dhcpd.c.cloexec 2009-01-06 11:56:09.000000000 -1000
388 +++ dhcp-4.1.0/server/dhcpd.c 2009-01-06 12:06:49.000000000 -1000
389 @@ -266,11 +266,11 @@ main(int argc, char **argv) {
390 /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
391 2 (stderr) are open. To do this, we assume that when we
392 open a file the lowest available file descriptor is used. */
393 - fd = open("/dev/null", O_RDWR);
394 + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
395 if (fd == 0)
396 - fd = open("/dev/null", O_RDWR);
397 + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
398 if (fd == 1)
399 - fd = open("/dev/null", O_RDWR);
400 + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
401 if (fd == 2)
402 log_perror = 0; /* No sense logging to /dev/null. */
403 else if (fd != -1)
404 @@ -779,7 +779,7 @@ main(int argc, char **argv) {
405 #endif /* PARANOIA */
406
407 /* Read previous pid file. */
408 - if ((i = open (path_dhcpd_pid, O_RDONLY)) >= 0) {
409 + if ((i = open (path_dhcpd_pid, O_RDONLY | O_CLOEXEC)) >= 0) {
410 status = read(i, pbuf, (sizeof pbuf) - 1);
411 close (i);
412 if (status > 0) {
413 @@ -797,7 +797,7 @@ main(int argc, char **argv) {
414 }
415
416 /* Write new pid file. */
417 - if ((i = open(path_dhcpd_pid, O_WRONLY|O_CREAT|O_TRUNC, 0644)) >= 0) {
418 + if ((i = open(path_dhcpd_pid, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0644)) >= 0) {
419 sprintf(pbuf, "%d\n", (int) getpid());
420 write(i, pbuf, strlen(pbuf));
421 close(i);
422 @@ -823,9 +823,9 @@ main(int argc, char **argv) {
423 close(2);
424
425 /* Reopen them on /dev/null. */
426 - open("/dev/null", O_RDWR);
427 - open("/dev/null", O_RDWR);
428 - open("/dev/null", O_RDWR);
429 + open("/dev/null", O_RDWR | O_CLOEXEC);
430 + open("/dev/null", O_RDWR | O_CLOEXEC);
431 + open("/dev/null", O_RDWR | O_CLOEXEC);
432 log_perror = 0; /* No sense logging to /dev/null. */
433
434 chdir("/");
435 diff -up dhcp-4.1.0/server/ldap.c.cloexec dhcp-4.1.0/server/ldap.c
436 --- dhcp-4.1.0/server/ldap.c.cloexec 2009-01-06 11:56:09.000000000 -1000
437 +++ dhcp-4.1.0/server/ldap.c 2009-01-06 11:56:11.000000000 -1000
438 @@ -685,7 +685,7 @@ ldap_start (void)
439
440 if (ldap_debug_file != NULL && ldap_debug_fd == -1)
441 {
442 - if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY,
443 + if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC,
444 S_IRUSR | S_IWUSR)) < 0)
445 log_error ("Error opening debug LDAP log file %s: %s", ldap_debug_file,
446 strerror (errno));

admin@fedoraproject.org
ViewVC Help
Powered by ViewVC 1.1.2