1 Index: DHCP/configure |
|
2 =================================================================== |
|
3 RCS file: /proj/cvs/prod/DHCP/configure,v |
|
4 retrieving revision 1.119 |
|
5 retrieving revision 1.119.6.1 |
|
6 diff -u -c -r1.119 -r1.119.6.1 |
|
7 *** DHCP/configure 18 Feb 2011 18:48:44 -0000 1.119 |
|
8 --- DHCP/configure 11 Apr 2011 21:12:20 -0000 1.119.6.1 |
|
9 *************** |
|
10 *** 1328,1333 **** |
|
11 --- 1328,1336 ---- |
|
12 --with-relay-pid-file=PATH |
|
13 File for dhcrelay process information (default is |
|
14 LOCALSTATEDIR/run/dhcrelay.pid) |
|
15 + --with-relay6-pid-file=PATH |
|
16 + File for dhcrelay6 process information (default is |
|
17 + LOCALSTATEDIR/run/dhcrelay6.pid) |
|
18 |
|
19 Some influential environment variables: |
|
20 CC C compiler command |
|
21 *************** |
|
22 *** 5062,5067 **** |
|
23 --- 5065,5080 ---- |
|
24 fi |
|
25 |
|
26 |
|
27 + # Check whether --with-relay6-pid-file was given. |
|
28 + if test "${with_relay6_pid_file+set}" = set; then |
|
29 + withval=$with_relay6_pid_file; |
|
30 + cat >>confdefs.h <<_ACEOF |
|
31 + #define _PATH_DHCRELAY6_PID "$withval" |
|
32 + _ACEOF |
|
33 + |
|
34 + fi |
|
35 + |
|
36 + |
|
37 # Check basic types. |
|
38 |
|
39 { echo "$as_me:$LINENO: checking for int8_t" >&5 |
|
40 Index: DHCP/configure.ac |
|
41 =================================================================== |
|
42 RCS file: /proj/cvs/prod/DHCP/configure.ac,v |
|
43 retrieving revision 1.47 |
|
44 retrieving revision 1.47.6.1 |
|
45 diff -u -c -r1.47 -r1.47.6.1 |
|
46 *** DHCP/configure.ac 18 Feb 2011 18:41:25 -0000 1.47 |
|
47 --- DHCP/configure.ac 9 Apr 2011 00:03:51 -0000 1.47.6.1 |
|
48 *************** |
|
49 *** 317,322 **** |
|
50 --- 317,328 ---- |
|
51 (default is LOCALSTATEDIR/run/dhcrelay.pid)]), |
|
52 AC_DEFINE_UNQUOTED([_PATH_DHCRELAY_PID], ["$withval"], |
|
53 [File for dhcrelay process information.])) |
|
54 + AC_ARG_WITH(relay6-pid-file, |
|
55 + AC_HELP_STRING([--with-relay6-pid-file=PATH], |
|
56 + [File for dhcrelay6 process information |
|
57 + (default is LOCALSTATEDIR/run/dhcrelay6.pid)]), |
|
58 + AC_DEFINE_UNQUOTED([_PATH_DHCRELAY6_PID], ["$withval"], |
|
59 + [File for dhcrelay6 process information.])) |
|
60 |
|
61 # Check basic types. |
|
62 AC_TYPE_INT8_T |
|
63 Index: DHCP/client/dhclient.8 |
|
64 =================================================================== |
|
65 RCS file: /proj/cvs/prod/DHCP/client/dhclient.8,v |
|
66 retrieving revision 1.35 |
|
67 retrieving revision 1.35.56.2 |
|
68 diff -u -c -r1.35 -r1.35.56.2 |
|
69 *** DHCP/client/dhclient.8 14 Jul 2010 20:01:14 -0000 1.35 |
|
70 --- DHCP/client/dhclient.8 12 Apr 2011 20:47:25 -0000 1.35.56.2 |
|
71 *************** |
|
72 *** 90,95 **** |
|
73 --- 90,98 ---- |
|
74 .I pid-file |
|
75 ] |
|
76 [ |
|
77 + .B --no-pid |
|
78 + ] |
|
79 + [ |
|
80 .B -cf |
|
81 .I config-file |
|
82 ] |
|
83 *************** |
|
84 *** 99,105 **** |
|
85 ] |
|
86 [ |
|
87 .B -s |
|
88 ! .I server |
|
89 ] |
|
90 [ |
|
91 .B -g |
|
92 --- 102,108 ---- |
|
93 ] |
|
94 [ |
|
95 .B -s |
|
96 ! .I server-addr |
|
97 ] |
|
98 [ |
|
99 .B -g |
|
100 *************** |
|
101 *** 305,311 **** |
|
102 transmit, the client will also use a different destination port - |
|
103 one less than the specified port. |
|
104 .TP |
|
105 ! .BI \-s \ server |
|
106 Specify the server IP address or fully qualified domain name to use as |
|
107 a destination for DHCP protocol messages before |
|
108 .B dhclient |
|
109 --- 308,314 ---- |
|
110 transmit, the client will also use a different destination port - |
|
111 one less than the specified port. |
|
112 .TP |
|
113 ! .BI \-s \ server-addr |
|
114 Specify the server IP address or fully qualified domain name to use as |
|
115 a destination for DHCP protocol messages before |
|
116 .B dhclient |
|
117 *************** |
|
118 *** 381,386 **** |
|
119 --- 384,395 ---- |
|
120 .B RUNDIR/dhclient.pid |
|
121 is used. |
|
122 .TP |
|
123 + .BI \--no-pid |
|
124 + Option to disable writing pid files. By default the program |
|
125 + will write a pid file. If the program is invoked with this |
|
126 + option it will not attempt to kill any existing client processes |
|
127 + even if invoked with \fB-r\fR or \fB-x\fR. |
|
128 + .TP |
|
129 .BI \-sf \ script-file |
|
130 Path to the network configuration script invoked by |
|
131 .B dhclient |
|
132 Index: DHCP/client/dhclient.c |
|
133 =================================================================== |
|
134 RCS file: /proj/cvs/prod/DHCP/client/dhclient.c,v |
|
135 retrieving revision 1.178 |
|
136 retrieving revision 1.178.2.2 |
|
137 diff -u -c -r1.178 -r1.178.2.2 |
|
138 *** DHCP/client/dhclient.c 24 Mar 2011 21:11:00 -0000 1.178 |
|
139 --- DHCP/client/dhclient.c 12 Apr 2011 20:47:25 -0000 1.178.2.2 |
|
140 *************** |
|
141 *** 48,53 **** |
|
142 --- 48,56 ---- |
|
143 static char path_dhclient_script_array[] = _PATH_DHCLIENT_SCRIPT; |
|
144 char *path_dhclient_script = path_dhclient_script_array; |
|
145 |
|
146 + /* False (default) => we write and use a pid file */ |
|
147 + isc_boolean_t no_pid_file = ISC_FALSE; |
|
148 + |
|
149 int dhcp_max_agent_option_packet_length = 0; |
|
150 |
|
151 int interfaces_requested = 0; |
|
152 *************** |
|
153 *** 196,201 **** |
|
154 --- 199,206 ---- |
|
155 usage(); |
|
156 path_dhclient_pid = argv[i]; |
|
157 no_dhclient_pid = 1; |
|
158 + } else if (!strcmp(argv[i], "--no-pid")) { |
|
159 + no_pid_file = ISC_TRUE; |
|
160 } else if (!strcmp(argv[i], "-cf")) { |
|
161 if (++i == argc) |
|
162 usage(); |
|
163 *************** |
|
164 *** 385,392 **** |
|
165 log_fatal("%s: %s", path, strerror(errno)); |
|
166 } |
|
167 |
|
168 ! /* first kill off any currently running client */ |
|
169 ! if (release_mode || exit_mode) { |
|
170 FILE *pidfd; |
|
171 pid_t oldpid; |
|
172 long temp; |
|
173 --- 390,402 ---- |
|
174 log_fatal("%s: %s", path, strerror(errno)); |
|
175 } |
|
176 |
|
177 ! /* |
|
178 ! * See if we should kill off any currently running client |
|
179 ! * we don't try to kill it off if the user told us not |
|
180 ! * to write a pid file - we assume they are controlling |
|
181 ! * the process in some other fashion. |
|
182 ! */ |
|
183 ! if ((release_mode || exit_mode) && (no_pid_file == ISC_FALSE)) { |
|
184 FILE *pidfd; |
|
185 pid_t oldpid; |
|
186 long temp; |
|
187 *************** |
|
188 *** 677,692 **** |
|
189 log_info(arr); |
|
190 log_info(url); |
|
191 |
|
192 ! log_error("Usage: dhclient %s %s", |
|
193 #ifdef DHCPv6 |
|
194 ! "[-4|-6] [-SNTP1dvrx] [-nw] [-p <port>]", |
|
195 #else /* DHCPv6 */ |
|
196 ! "[-1dvrx] [-nw] [-p <port>]", |
|
197 #endif /* DHCPv6 */ |
|
198 ! "[-s server]"); |
|
199 ! log_error(" [-cf config-file] [-lf lease-file]%s", |
|
200 ! "[-pf pid-file] [-e VAR=val]"); |
|
201 ! log_fatal(" [-sf script-file] [interface]"); |
|
202 } |
|
203 |
|
204 void run_stateless(int exit_mode) |
|
205 --- 687,703 ---- |
|
206 log_info(arr); |
|
207 log_info(url); |
|
208 |
|
209 ! |
|
210 ! log_fatal("Usage: dhclient " |
|
211 #ifdef DHCPv6 |
|
212 ! "[-4|-6] [-SNTP1dvrx] [-nw] [-p <port>]\n" |
|
213 #else /* DHCPv6 */ |
|
214 ! "[-1dvrx] [-nw] [-p <port>]\n" |
|
215 #endif /* DHCPv6 */ |
|
216 ! " [-s server-addr] [-cf config-file] " |
|
217 ! "[-lf lease-file]\n" |
|
218 ! " [-pf pid-file] [--no-pid] [-e VAR=val]\n" |
|
219 ! " [-sf script-file] [interface]"); |
|
220 } |
|
221 |
|
222 void run_stateless(int exit_mode) |
|
223 *************** |
|
224 *** 3369,3374 **** |
|
225 --- 3380,3390 ---- |
|
226 FILE *pf; |
|
227 int pfdesc; |
|
228 |
|
229 + /* nothing to do if the user doesn't want a pid file */ |
|
230 + if (no_pid_file == ISC_TRUE) { |
|
231 + return; |
|
232 + } |
|
233 + |
|
234 pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY, 0644); |
|
235 |
|
236 if (pfdesc < 0) { |
|
237 Index: DHCP/includes/config.h.in |
|
238 =================================================================== |
|
239 RCS file: /proj/cvs/prod/DHCP/includes/config.h.in,v |
|
240 retrieving revision 1.60 |
|
241 retrieving revision 1.60.6.1 |
|
242 diff -u -c -r1.60 -r1.60.6.1 |
|
243 *** DHCP/includes/config.h.in 18 Feb 2011 18:48:15 -0000 1.60 |
|
244 --- DHCP/includes/config.h.in 11 Apr 2011 21:12:03 -0000 1.60.6.1 |
|
245 *************** |
|
246 *** 175,180 **** |
|
247 --- 175,183 ---- |
|
248 /* File for dhcpd process information. */ |
|
249 #undef _PATH_DHCPD_PID |
|
250 |
|
251 + /* File for dhcrelay6 process information. */ |
|
252 + #undef _PATH_DHCRELAY6_PID |
|
253 + |
|
254 /* File for dhcrelay process information. */ |
|
255 #undef _PATH_DHCRELAY_PID |
|
256 |
|
257 Index: DHCP/relay/dhcrelay.8 |
|
258 =================================================================== |
|
259 RCS file: /proj/cvs/prod/DHCP/relay/dhcrelay.8,v |
|
260 retrieving revision 1.18 |
|
261 retrieving revision 1.18.58.2 |
|
262 diff -u -c -r1.18 -r1.18.58.2 |
|
263 *** DHCP/relay/dhcrelay.8 2 Jul 2010 23:09:14 -0000 1.18 |
|
264 --- DHCP/relay/dhcrelay.8 12 Apr 2011 20:47:26 -0000 1.18.58.2 |
|
265 *************** |
|
266 *** 54,59 **** |
|
267 --- 54,66 ---- |
|
268 .I length |
|
269 ] |
|
270 [ |
|
271 + .B -pf |
|
272 + .I pid-file |
|
273 + ] |
|
274 + [ |
|
275 + .B --no-pid |
|
276 + ] |
|
277 + [ |
|
278 .B -m |
|
279 .I append |
|
280 | |
|
281 *************** |
|
282 *** 89,94 **** |
|
283 --- 96,108 ---- |
|
284 .B -c |
|
285 .I count |
|
286 ] |
|
287 + [ |
|
288 + .B -pf |
|
289 + .I pid-file |
|
290 + ] |
|
291 + [ |
|
292 + .B --no-pid |
|
293 + ] |
|
294 .B -l |
|
295 .I lower0 |
|
296 [ |
|
297 *************** |
|
298 *** 150,155 **** |
|
299 --- 164,176 ---- |
|
300 -q |
|
301 Quiet mode. Prevents dhcrelay6 from printing its network configuration |
|
302 on startup. |
|
303 + .TP |
|
304 + -pf pid-file |
|
305 + Path to alternate pid file. |
|
306 + .TP |
|
307 + --no-pid |
|
308 + Option to disable writing pid files. By default the program |
|
309 + will write a pid file. |
|
310 .PP |
|
311 \fIOptions available in DHCPv4 mode only:\fR |
|
312 .TP |
|
313 Index: DHCP/relay/dhcrelay.c |
|
314 =================================================================== |
|
315 RCS file: /proj/cvs/prod/DHCP/relay/dhcrelay.c,v |
|
316 retrieving revision 1.79 |
|
317 retrieving revision 1.79.106.2 |
|
318 diff -u -c -r1.79 -r1.79.106.2 |
|
319 *** DHCP/relay/dhcrelay.c 2 Feb 2010 19:58:18 -0000 1.79 |
|
320 --- DHCP/relay/dhcrelay.c 12 Apr 2011 20:47:26 -0000 1.79.106.2 |
|
321 *************** |
|
322 *** 49,54 **** |
|
323 --- 49,57 ---- |
|
324 char *tlname; |
|
325 |
|
326 const char *path_dhcrelay_pid = _PATH_DHCRELAY_PID; |
|
327 + isc_boolean_t no_dhcrelay_pid = ISC_FALSE; |
|
328 + /* False (default) => we write and use a pid file */ |
|
329 + isc_boolean_t no_pid_file = ISC_FALSE; |
|
330 |
|
331 int bogus_agent_drops = 0; /* Packets dropped because agent option |
|
332 field was specified and we're not relaying |
|
333 *************** |
|
334 *** 138,147 **** |
|
335 --- 141,152 ---- |
|
336 #define DHCRELAY_USAGE \ |
|
337 "Usage: dhcrelay [-4] [-d] [-q] [-a] [-D]\n"\ |
|
338 " [-A <length>] [-c <hops>] [-p <port>]\n" \ |
|
339 + " [-pf <pid-file>] [--no-pid]\n"\ |
|
340 " [-m append|replace|forward|discard]\n" \ |
|
341 " [-i interface0 [ ... -i interfaceN]\n" \ |
|
342 " server0 [ ... serverN]\n\n" \ |
|
343 " dhcrelay -6 [-d] [-q] [-I] [-c <hops>] [-p <port>]\n" \ |
|
344 + " [-pf <pid-file>] [--no-pid]\n"\ |
|
345 " -l lower0 [ ... -l lowerN]\n" \ |
|
346 " -u upper0 [ ... -u upperN]\n" \ |
|
347 " lower (client link): [address%%]interface[#index]\n" \ |
|
348 *************** |
|
349 *** 149,154 **** |
|
350 --- 154,160 ---- |
|
351 #else |
|
352 #define DHCRELAY_USAGE \ |
|
353 "Usage: dhcrelay [-d] [-q] [-a] [-D] [-A <length>] [-c <hops>] [-p <port>]\n" \ |
|
354 + " [-pf <pid-file>] [--no-pid]\n"\ |
|
355 " [-m append|replace|forward|discard]\n" \ |
|
356 " [-i interface0 [ ... -i interfaceN]\n" \ |
|
357 " server0 [ ... serverN]\n\n" |
|
358 *************** |
|
359 *** 350,355 **** |
|
360 --- 356,368 ---- |
|
361 sl->next = upstreams; |
|
362 upstreams = sl; |
|
363 #endif |
|
364 + } else if (!strcmp(argv[i], "-pf")) { |
|
365 + if (++i == argc) |
|
366 + usage(); |
|
367 + path_dhcrelay_pid = argv[i]; |
|
368 + no_dhcrelay_pid = ISC_TRUE; |
|
369 + } else if (!strcmp(argv[i], "--no-pid")) { |
|
370 + no_pid_file = ISC_TRUE; |
|
371 } else if (!strcmp(argv[i], "--version")) { |
|
372 log_info("isc-dhcrelay-%s", PACKAGE_VERSION); |
|
373 exit(0); |
|
374 *************** |
|
375 *** 394,411 **** |
|
376 } |
|
377 } |
|
378 |
|
379 ! if (local_family == AF_INET) { |
|
380 ! path_dhcrelay_pid = getenv("PATH_DHCRELAY_PID"); |
|
381 ! if (path_dhcrelay_pid == NULL) |
|
382 ! path_dhcrelay_pid = _PATH_DHCRELAY_PID; |
|
383 ! } |
|
384 #ifdef DHCPv6 |
|
385 ! else { |
|
386 ! path_dhcrelay_pid = getenv("PATH_DHCRELAY6_PID"); |
|
387 ! if (path_dhcrelay_pid == NULL) |
|
388 ! path_dhcrelay_pid = _PATH_DHCRELAY6_PID; |
|
389 ! } |
|
390 #endif |
|
391 |
|
392 if (!quiet) { |
|
393 log_info("%s %s", message, PACKAGE_VERSION); |
|
394 --- 407,430 ---- |
|
395 } |
|
396 } |
|
397 |
|
398 ! /* |
|
399 ! * If the user didn't specify a pid file directly |
|
400 ! * find one from environment variables or defaults |
|
401 ! */ |
|
402 ! if (no_dhcrelay_pid == ISC_FALSE) { |
|
403 ! if (local_family == AF_INET) { |
|
404 ! path_dhcrelay_pid = getenv("PATH_DHCRELAY_PID"); |
|
405 ! if (path_dhcrelay_pid == NULL) |
|
406 ! path_dhcrelay_pid = _PATH_DHCRELAY_PID; |
|
407 ! } |
|
408 #ifdef DHCPv6 |
|
409 ! else { |
|
410 ! path_dhcrelay_pid = getenv("PATH_DHCRELAY6_PID"); |
|
411 ! if (path_dhcrelay_pid == NULL) |
|
412 ! path_dhcrelay_pid = _PATH_DHCRELAY6_PID; |
|
413 ! } |
|
414 #endif |
|
415 + } |
|
416 |
|
417 if (!quiet) { |
|
418 log_info("%s %s", message, PACKAGE_VERSION); |
|
419 *************** |
|
420 *** 519,538 **** |
|
421 else if (pid) |
|
422 exit(0); |
|
423 |
|
424 ! pfdesc = open(path_dhcrelay_pid, |
|
425 ! O_CREAT | O_TRUNC | O_WRONLY, 0644); |
|
426 ! |
|
427 ! if (pfdesc < 0) { |
|
428 ! log_error("Can't create %s: %m", path_dhcrelay_pid); |
|
429 ! } else { |
|
430 ! pf = fdopen(pfdesc, "w"); |
|
431 ! if (!pf) |
|
432 ! log_error("Can't fdopen %s: %m", |
|
433 ! path_dhcrelay_pid); |
|
434 ! else { |
|
435 ! fprintf(pf, "%ld\n",(long)getpid()); |
|
436 ! fclose(pf); |
|
437 ! } |
|
438 } |
|
439 |
|
440 close(0); |
|
441 --- 538,560 ---- |
|
442 else if (pid) |
|
443 exit(0); |
|
444 |
|
445 ! if (no_pid_file == ISC_FALSE) { |
|
446 ! pfdesc = open(path_dhcrelay_pid, |
|
447 ! O_CREAT | O_TRUNC | O_WRONLY, 0644); |
|
448 ! |
|
449 ! if (pfdesc < 0) { |
|
450 ! log_error("Can't create %s: %m", |
|
451 ! path_dhcrelay_pid); |
|
452 ! } else { |
|
453 ! pf = fdopen(pfdesc, "w"); |
|
454 ! if (!pf) |
|
455 ! log_error("Can't fdopen %s: %m", |
|
456 ! path_dhcrelay_pid); |
|
457 ! else { |
|
458 ! fprintf(pf, "%ld\n",(long)getpid()); |
|
459 ! fclose(pf); |
|
460 ! } |
|
461 ! } |
|
462 } |
|
463 |
|
464 close(0); |
|
465 Index: DHCP/server/dhcpd.8 |
|
466 =================================================================== |
|
467 RCS file: /proj/cvs/prod/DHCP/server/dhcpd.8,v |
|
468 retrieving revision 1.33 |
|
469 retrieving revision 1.33.56.2 |
|
470 diff -u -c -r1.33 -r1.33.56.2 |
|
471 *** DHCP/server/dhcpd.8 14 Jul 2010 20:01:14 -0000 1.33 |
|
472 --- DHCP/server/dhcpd.8 12 Apr 2011 20:47:26 -0000 1.33.56.2 |
|
473 *************** |
|
474 *** 75,80 **** |
|
475 --- 75,83 ---- |
|
476 .I pid-file |
|
477 ] |
|
478 [ |
|
479 + .B --no-pid |
|
480 + ] |
|
481 + [ |
|
482 .B -tf |
|
483 .I trace-output-file |
|
484 ] |
|
485 *************** |
|
486 *** 283,288 **** |
|
487 --- 286,296 ---- |
|
488 .TP |
|
489 .BI \-pf \ pid-file |
|
490 Path to alternate pid file. |
|
491 + .TP |
|
492 + .BI \--no-pid |
|
493 + Option to disable writing pid files. By default the program |
|
494 + will write a pid file. If the program is invoked with this |
|
495 + option it will not check for an existing server process. |
|
496 .PP |
|
497 .SH CONFIGURATION |
|
498 The syntax of the dhcpd.conf(5) file is discussed separately. This |
|
499 Index: DHCP/server/dhcpd.c |
|
500 =================================================================== |
|
501 RCS file: /proj/cvs/prod/DHCP/server/dhcpd.c,v |
|
502 retrieving revision 1.156 |
|
503 retrieving revision 1.156.42.2 |
|
504 diff -u -c -r1.156 -r1.156.42.2 |
|
505 *** DHCP/server/dhcpd.c 8 Sep 2010 22:13:05 -0000 1.156 |
|
506 --- DHCP/server/dhcpd.c 12 Apr 2011 20:47:26 -0000 1.156.42.2 |
|
507 *************** |
|
508 *** 160,165 **** |
|
509 --- 160,167 ---- |
|
510 const char *path_dhcpd_conf = _PATH_DHCPD_CONF; |
|
511 const char *path_dhcpd_db = _PATH_DHCPD_DB; |
|
512 const char *path_dhcpd_pid = _PATH_DHCPD_PID; |
|
513 + /* False (default) => we write and use a pid file */ |
|
514 + isc_boolean_t no_pid_file = ISC_FALSE; |
|
515 |
|
516 int dhcp_max_agent_option_packet_length = DHCP_MTU_MAX; |
|
517 |
|
518 *************** |
|
519 *** 351,356 **** |
|
520 --- 353,360 ---- |
|
521 usage (); |
|
522 path_dhcpd_pid = argv [i]; |
|
523 no_dhcpd_pid = 1; |
|
524 + } else if (!strcmp(argv[i], "--no-pid")) { |
|
525 + no_pid_file = ISC_TRUE; |
|
526 } else if (!strcmp (argv [i], "-t")) { |
|
527 /* test configurations only */ |
|
528 #ifndef DEBUG |
|
529 *************** |
|
530 *** 783,815 **** |
|
531 } |
|
532 #endif /* PARANOIA */ |
|
533 |
|
534 ! /* Read previous pid file. */ |
|
535 ! if ((i = open (path_dhcpd_pid, O_RDONLY)) >= 0) { |
|
536 ! status = read(i, pbuf, (sizeof pbuf) - 1); |
|
537 ! close (i); |
|
538 ! if (status > 0) { |
|
539 ! pbuf[status] = 0; |
|
540 ! pid = atoi(pbuf); |
|
541 ! |
|
542 ! /* |
|
543 ! * If there was a previous server process and it's |
|
544 ! * is still running, abort |
|
545 ! */ |
|
546 ! if (!pid || (pid != getpid() && kill(pid, 0) == 0)) |
|
547 ! log_fatal("There's already a " |
|
548 ! "DHCP server running."); |
|
549 } |
|
550 - } |
|
551 - |
|
552 - /* Write new pid file. */ |
|
553 - if ((i = open(path_dhcpd_pid, O_WRONLY|O_CREAT|O_TRUNC, 0644)) >= 0) { |
|
554 - sprintf(pbuf, "%d\n", (int) getpid()); |
|
555 - IGNORE_RET (write(i, pbuf, strlen(pbuf))); |
|
556 - close(i); |
|
557 - } else { |
|
558 - log_error("Can't create PID file %s: %m.", path_dhcpd_pid); |
|
559 - } |
|
560 |
|
561 |
|
562 /* If we were requested to log to stdout on the command line, |
|
563 keep doing so; otherwise, stop. */ |
|
564 --- 787,827 ---- |
|
565 } |
|
566 #endif /* PARANOIA */ |
|
567 |
|
568 ! /* |
|
569 ! * Deal with pid files. If the user told us |
|
570 ! * not to write a file we don't read one either |
|
571 ! */ |
|
572 ! if (no_pid_file == ISC_FALSE) { |
|
573 ! /*Read previous pid file. */ |
|
574 ! if ((i = open (path_dhcpd_pid, O_RDONLY)) >= 0) { |
|
575 ! status = read(i, pbuf, (sizeof pbuf) - 1); |
|
576 ! close (i); |
|
577 ! if (status > 0) { |
|
578 ! pbuf[status] = 0; |
|
579 ! pid = atoi(pbuf); |
|
580 ! |
|
581 ! /* |
|
582 ! * If there was a previous server process and |
|
583 ! * it is still running, abort |
|
584 ! */ |
|
585 ! if (!pid || |
|
586 ! (pid != getpid() && kill(pid, 0) == 0)) |
|
587 ! log_fatal("There's already a " |
|
588 ! "DHCP server running."); |
|
589 ! } |
|
590 } |
|
591 |
|
592 + /* Write new pid file. */ |
|
593 + i = open(path_dhcpd_pid, O_WRONLY|O_CREAT|O_TRUNC, 0644); |
|
594 + if (i >= 0) { |
|
595 + sprintf(pbuf, "%d\n", (int) getpid()); |
|
596 + IGNORE_RET (write(i, pbuf, strlen(pbuf))); |
|
597 + close(i); |
|
598 + } else { |
|
599 + log_error("Can't create PID file %s: %m.", |
|
600 + path_dhcpd_pid); |
|
601 + } |
|
602 + } |
|
603 |
|
604 /* If we were requested to log to stdout on the command line, |
|
605 keep doing so; otherwise, stop. */ |
|
606 *************** |
|
607 *** 902,908 **** |
|
608 &global_scope, oc, MDL)) { |
|
609 s = dmalloc (db.len + 1, MDL); |
|
610 if (!s) |
|
611 ! log_fatal ("no memory for lease db filename."); |
|
612 memcpy (s, db.data, db.len); |
|
613 s [db.len] = 0; |
|
614 data_string_forget (&db, MDL); |
|
615 --- 914,920 ---- |
|
616 &global_scope, oc, MDL)) { |
|
617 s = dmalloc (db.len + 1, MDL); |
|
618 if (!s) |
|
619 ! log_fatal ("no memory for pid filename."); |
|
620 memcpy (s, db.data, db.len); |
|
621 s [db.len] = 0; |
|
622 data_string_forget (&db, MDL); |
|
623 *************** |
|
624 *** 938,944 **** |
|
625 oc, MDL)) { |
|
626 s = dmalloc (db.len + 1, MDL); |
|
627 if (!s) |
|
628 ! log_fatal ("no memory for lease db filename."); |
|
629 memcpy (s, db.data, db.len); |
|
630 s [db.len] = 0; |
|
631 data_string_forget (&db, MDL); |
|
632 --- 950,956 ---- |
|
633 oc, MDL)) { |
|
634 s = dmalloc (db.len + 1, MDL); |
|
635 if (!s) |
|
636 ! log_fatal ("no memory for pid filename."); |
|
637 memcpy (s, db.data, db.len); |
|
638 s [db.len] = 0; |
|
639 data_string_forget (&db, MDL); |
|
640 *************** |
|
641 *** 1210,1216 **** |
|
642 " [-tf trace-output-file]\n" |
|
643 " [-play trace-input-file]\n" |
|
644 #endif /* TRACING */ |
|
645 ! " [-pf pid-file] [-s server] [if0 [...ifN]]"); |
|
646 } |
|
647 |
|
648 void lease_pinged (from, packet, length) |
|
649 --- 1222,1229 ---- |
|
650 " [-tf trace-output-file]\n" |
|
651 " [-play trace-input-file]\n" |
|
652 #endif /* TRACING */ |
|
653 ! " [-pf pid-file] [--no-pid] [-s server]\n" |
|
654 ! " [if0 [...ifN]]"); |
|
655 } |
|
656 |
|
657 void lease_pinged (from, packet, length) |
|