Deleted Added
full compact
rbootd.c (68894) rbootd.c (90377)
1/*
2 * Copyright (c) 1988, 1992 The University of Utah and the Center
3 * for Software Science (CSS).
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the Center for Software Science of the University of Utah Computer
9 * Science Department. CSS requests users of this software to return
10 * to css-dist@cs.utah.edu any improvements that they make and grant
11 * CSS redistribution rights.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 * from: @(#)rbootd.c 8.1 (Berkeley) 6/4/93
42 *
43 * From: Utah Hdr: rbootd.c 3.1 92/07/06
44 * Author: Jeff Forys, University of Utah CSS
45 */
46
47#ifndef lint
48static const char copyright[] =
49"@(#) Copyright (c) 1992, 1993\n\
50 The Regents of the University of California. All rights reserved.\n";
51#endif /* not lint */
52
53#ifndef lint
54#if 0
55static const char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";
56#endif
57static const char rcsid[] =
1/*
2 * Copyright (c) 1988, 1992 The University of Utah and the Center
3 * for Software Science (CSS).
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the Center for Software Science of the University of Utah Computer
9 * Science Department. CSS requests users of this software to return
10 * to css-dist@cs.utah.edu any improvements that they make and grant
11 * CSS redistribution rights.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 * from: @(#)rbootd.c 8.1 (Berkeley) 6/4/93
42 *
43 * From: Utah Hdr: rbootd.c 3.1 92/07/06
44 * Author: Jeff Forys, University of Utah CSS
45 */
46
47#ifndef lint
48static const char copyright[] =
49"@(#) Copyright (c) 1992, 1993\n\
50 The Regents of the University of California. All rights reserved.\n";
51#endif /* not lint */
52
53#ifndef lint
54#if 0
55static const char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";
56#endif
57static const char rcsid[] =
58 "$FreeBSD: head/libexec/rbootd/rbootd.c 68894 2000-11-19 10:52:10Z kris $";
58 "$FreeBSD: head/libexec/rbootd/rbootd.c 90377 2002-02-07 23:57:01Z imp $";
59#endif /* not lint */
60
61#include <sys/param.h>
62#include <sys/time.h>
63#include <ctype.h>
64#include <err.h>
65#include <errno.h>
66#include <fcntl.h>
67#include <signal.h>
68#include <stdio.h>
69#include <stdlib.h>
70#include <string.h>
71#include <syslog.h>
72#include <unistd.h>
73#include "defs.h"
74
59#endif /* not lint */
60
61#include <sys/param.h>
62#include <sys/time.h>
63#include <ctype.h>
64#include <err.h>
65#include <errno.h>
66#include <fcntl.h>
67#include <signal.h>
68#include <stdio.h>
69#include <stdlib.h>
70#include <string.h>
71#include <syslog.h>
72#include <unistd.h>
73#include "defs.h"
74
75static void usage __P((void));
75static void usage(void);
76
77int
76
77int
78main(argc, argv)
79 int argc;
80 char *argv[];
78main(int argc, char *argv[])
81{
82 int c, fd, omask, maxfds;
83 fd_set rset;
84
85 /*
86 * Close any open file descriptors.
87 * Temporarily leave stdin & stdout open for `-d',
88 * and stderr open for any pre-syslog error messages.
89 */
90 {
91 int i, nfds = getdtablesize();
92
93 for (i = 0; i < nfds; i++)
94 if (i != fileno(stdin) && i != fileno(stdout) &&
95 i != fileno(stderr))
96 (void) close(i);
97 }
98
99 /*
100 * Parse any arguments.
101 */
102 while ((c = getopt(argc, argv, "adi:")) != -1)
103 switch(c) {
104 case 'a':
105 BootAny++;
106 break;
107 case 'd':
108 DebugFlg++;
109 break;
110 case 'i':
111 IntfName = optarg;
112 break;
113 default:
114 usage();
115 }
116 for (; optind < argc; optind++) {
117 if (ConfigFile == NULL)
118 ConfigFile = argv[optind];
119 else {
120 warnx("too many config files (`%s' ignored)",
121 argv[optind]);
122 }
123 }
124
125 if (ConfigFile == NULL) /* use default config file */
126 ConfigFile = DfltConfig;
127
128 if (DebugFlg) {
129 DbgFp = stdout; /* output to stdout */
130
131 (void) signal(SIGUSR1, SIG_IGN); /* dont muck w/DbgFp */
132 (void) signal(SIGUSR2, SIG_IGN);
133 (void) fclose(stderr); /* finished with it */
134 } else {
135 if (daemon(0, 0))
136 err(1, "can't detach from terminal");
137
138 (void) signal(SIGUSR1, DebugOn);
139 (void) signal(SIGUSR2, DebugOff);
140 }
141
142 openlog("rbootd", LOG_PID, LOG_DAEMON);
143
144 /*
145 * If no interface was specified, get one now.
146 *
147 * This is convoluted because we want to get the default interface
148 * name for the syslog("restarted") message. If BpfGetIntfName()
149 * runs into an error, it will return a syslog-able error message
150 * (in `errmsg') which will be displayed here.
151 */
152 if (IntfName == NULL) {
153 char *errmsg;
154
155 if ((IntfName = BpfGetIntfName(&errmsg)) == NULL) {
156 syslog(LOG_NOTICE, "restarted (??)");
157 /* BpfGetIntfName() returns safe names, using %m */
158 syslog(LOG_ERR, "%s", errmsg);
159 Exit(0);
160 }
161 }
162
163 syslog(LOG_NOTICE, "restarted (%s)", IntfName);
164
165 (void) signal(SIGHUP, ReConfig);
166 (void) signal(SIGINT, Exit);
167 (void) signal(SIGTERM, Exit);
168
169 /*
170 * Grab our host name and pid.
171 */
172 if (gethostname(MyHost, MAXHOSTNAMELEN - 1) < 0) {
173 syslog(LOG_ERR, "gethostname: %m");
174 Exit(0);
175 }
176 MyHost[MAXHOSTNAMELEN - 1] = '\0';
177
178 MyPid = getpid();
179
180 /*
181 * Write proc's pid to a file.
182 */
183 {
184 FILE *fp;
185
186 if ((fp = fopen(PidFile, "w")) != NULL) {
187 (void) fprintf(fp, "%d\n", (int) MyPid);
188 (void) fclose(fp);
189 } else {
190 syslog(LOG_WARNING, "fopen: failed (%s)", PidFile);
191 }
192 }
193
194 /*
195 * All boot files are relative to the boot directory, we might
196 * as well chdir() there to make life easier.
197 */
198 if (chdir(BootDir) < 0) {
199 syslog(LOG_ERR, "chdir: %m (%s)", BootDir);
200 Exit(0);
201 }
202
203 /*
204 * Initial configuration.
205 */
206 omask = sigblock(sigmask(SIGHUP)); /* prevent reconfig's */
207 if (GetBootFiles() == 0) /* get list of boot files */
208 Exit(0);
209 if (ParseConfig() == 0) /* parse config file */
210 Exit(0);
211
212 /*
213 * Open and initialize a BPF device for the appropriate interface.
214 * If an error is encountered, a message is displayed and Exit()
215 * is called.
216 */
217 fd = BpfOpen();
218
219 (void) sigsetmask(omask); /* allow reconfig's */
220
221 /*
222 * Main loop: receive a packet, determine where it came from,
223 * and if we service this host, call routine to handle request.
224 */
225 maxfds = fd + 1;
226 FD_ZERO(&rset);
227 FD_SET(fd, &rset);
228 for (;;) {
229 struct timeval timeout;
230 fd_set r;
231 int nsel;
232
233 r = rset;
234
235 if (RmpConns == NULL) { /* timeout isnt necessary */
236 nsel = select(maxfds, &r, NULL, NULL, NULL);
237 } else {
238 timeout.tv_sec = RMP_TIMEOUT;
239 timeout.tv_usec = 0;
240 nsel = select(maxfds, &r, NULL, NULL, &timeout);
241 }
242
243 if (nsel < 0) {
244 if (errno == EINTR)
245 continue;
246 syslog(LOG_ERR, "select: %m");
247 Exit(0);
248 } else if (nsel == 0) { /* timeout */
249 DoTimeout(); /* clear stale conns */
250 continue;
251 }
252
253 if (FD_ISSET(fd, &r)) {
254 RMPCONN rconn;
255 CLIENT *client, *FindClient();
256 int doread = 1;
257
258 while (BpfRead(&rconn, doread)) {
259 doread = 0;
260
261 if (DbgFp != NULL) /* display packet */
262 DispPkt(&rconn,DIR_RCVD);
263
264 omask = sigblock(sigmask(SIGHUP));
265
266 /*
267 * If we do not restrict service, set the
268 * client to NULL (ProcessPacket() handles
269 * this). Otherwise, check that we can
270 * service this host; if not, log a message
271 * and ignore the packet.
272 */
273 if (BootAny) {
274 client = NULL;
275 } else if ((client=FindClient(&rconn))==NULL) {
276 syslog(LOG_INFO,
277 "%s: boot packet ignored",
278 EnetStr(&rconn));
279 (void) sigsetmask(omask);
280 continue;
281 }
282
283 ProcessPacket(&rconn,client);
284
285 (void) sigsetmask(omask);
286 }
287 }
288 }
289}
290
291static void
79{
80 int c, fd, omask, maxfds;
81 fd_set rset;
82
83 /*
84 * Close any open file descriptors.
85 * Temporarily leave stdin & stdout open for `-d',
86 * and stderr open for any pre-syslog error messages.
87 */
88 {
89 int i, nfds = getdtablesize();
90
91 for (i = 0; i < nfds; i++)
92 if (i != fileno(stdin) && i != fileno(stdout) &&
93 i != fileno(stderr))
94 (void) close(i);
95 }
96
97 /*
98 * Parse any arguments.
99 */
100 while ((c = getopt(argc, argv, "adi:")) != -1)
101 switch(c) {
102 case 'a':
103 BootAny++;
104 break;
105 case 'd':
106 DebugFlg++;
107 break;
108 case 'i':
109 IntfName = optarg;
110 break;
111 default:
112 usage();
113 }
114 for (; optind < argc; optind++) {
115 if (ConfigFile == NULL)
116 ConfigFile = argv[optind];
117 else {
118 warnx("too many config files (`%s' ignored)",
119 argv[optind]);
120 }
121 }
122
123 if (ConfigFile == NULL) /* use default config file */
124 ConfigFile = DfltConfig;
125
126 if (DebugFlg) {
127 DbgFp = stdout; /* output to stdout */
128
129 (void) signal(SIGUSR1, SIG_IGN); /* dont muck w/DbgFp */
130 (void) signal(SIGUSR2, SIG_IGN);
131 (void) fclose(stderr); /* finished with it */
132 } else {
133 if (daemon(0, 0))
134 err(1, "can't detach from terminal");
135
136 (void) signal(SIGUSR1, DebugOn);
137 (void) signal(SIGUSR2, DebugOff);
138 }
139
140 openlog("rbootd", LOG_PID, LOG_DAEMON);
141
142 /*
143 * If no interface was specified, get one now.
144 *
145 * This is convoluted because we want to get the default interface
146 * name for the syslog("restarted") message. If BpfGetIntfName()
147 * runs into an error, it will return a syslog-able error message
148 * (in `errmsg') which will be displayed here.
149 */
150 if (IntfName == NULL) {
151 char *errmsg;
152
153 if ((IntfName = BpfGetIntfName(&errmsg)) == NULL) {
154 syslog(LOG_NOTICE, "restarted (??)");
155 /* BpfGetIntfName() returns safe names, using %m */
156 syslog(LOG_ERR, "%s", errmsg);
157 Exit(0);
158 }
159 }
160
161 syslog(LOG_NOTICE, "restarted (%s)", IntfName);
162
163 (void) signal(SIGHUP, ReConfig);
164 (void) signal(SIGINT, Exit);
165 (void) signal(SIGTERM, Exit);
166
167 /*
168 * Grab our host name and pid.
169 */
170 if (gethostname(MyHost, MAXHOSTNAMELEN - 1) < 0) {
171 syslog(LOG_ERR, "gethostname: %m");
172 Exit(0);
173 }
174 MyHost[MAXHOSTNAMELEN - 1] = '\0';
175
176 MyPid = getpid();
177
178 /*
179 * Write proc's pid to a file.
180 */
181 {
182 FILE *fp;
183
184 if ((fp = fopen(PidFile, "w")) != NULL) {
185 (void) fprintf(fp, "%d\n", (int) MyPid);
186 (void) fclose(fp);
187 } else {
188 syslog(LOG_WARNING, "fopen: failed (%s)", PidFile);
189 }
190 }
191
192 /*
193 * All boot files are relative to the boot directory, we might
194 * as well chdir() there to make life easier.
195 */
196 if (chdir(BootDir) < 0) {
197 syslog(LOG_ERR, "chdir: %m (%s)", BootDir);
198 Exit(0);
199 }
200
201 /*
202 * Initial configuration.
203 */
204 omask = sigblock(sigmask(SIGHUP)); /* prevent reconfig's */
205 if (GetBootFiles() == 0) /* get list of boot files */
206 Exit(0);
207 if (ParseConfig() == 0) /* parse config file */
208 Exit(0);
209
210 /*
211 * Open and initialize a BPF device for the appropriate interface.
212 * If an error is encountered, a message is displayed and Exit()
213 * is called.
214 */
215 fd = BpfOpen();
216
217 (void) sigsetmask(omask); /* allow reconfig's */
218
219 /*
220 * Main loop: receive a packet, determine where it came from,
221 * and if we service this host, call routine to handle request.
222 */
223 maxfds = fd + 1;
224 FD_ZERO(&rset);
225 FD_SET(fd, &rset);
226 for (;;) {
227 struct timeval timeout;
228 fd_set r;
229 int nsel;
230
231 r = rset;
232
233 if (RmpConns == NULL) { /* timeout isnt necessary */
234 nsel = select(maxfds, &r, NULL, NULL, NULL);
235 } else {
236 timeout.tv_sec = RMP_TIMEOUT;
237 timeout.tv_usec = 0;
238 nsel = select(maxfds, &r, NULL, NULL, &timeout);
239 }
240
241 if (nsel < 0) {
242 if (errno == EINTR)
243 continue;
244 syslog(LOG_ERR, "select: %m");
245 Exit(0);
246 } else if (nsel == 0) { /* timeout */
247 DoTimeout(); /* clear stale conns */
248 continue;
249 }
250
251 if (FD_ISSET(fd, &r)) {
252 RMPCONN rconn;
253 CLIENT *client, *FindClient();
254 int doread = 1;
255
256 while (BpfRead(&rconn, doread)) {
257 doread = 0;
258
259 if (DbgFp != NULL) /* display packet */
260 DispPkt(&rconn,DIR_RCVD);
261
262 omask = sigblock(sigmask(SIGHUP));
263
264 /*
265 * If we do not restrict service, set the
266 * client to NULL (ProcessPacket() handles
267 * this). Otherwise, check that we can
268 * service this host; if not, log a message
269 * and ignore the packet.
270 */
271 if (BootAny) {
272 client = NULL;
273 } else if ((client=FindClient(&rconn))==NULL) {
274 syslog(LOG_INFO,
275 "%s: boot packet ignored",
276 EnetStr(&rconn));
277 (void) sigsetmask(omask);
278 continue;
279 }
280
281 ProcessPacket(&rconn,client);
282
283 (void) sigsetmask(omask);
284 }
285 }
286 }
287}
288
289static void
292usage()
290usage(void)
293{
294 fprintf(stderr, "usage: rbootd [-ad] [-i interface] [config_file]\n");
295 exit (1);
296}
297
298/*
299** DoTimeout -- Free any connections that have timed out.
300**
301** Parameters:
302** None.
303**
304** Returns:
305** Nothing.
306**
307** Side Effects:
308** - Timed out connections in `RmpConns' will be freed.
309*/
310void
291{
292 fprintf(stderr, "usage: rbootd [-ad] [-i interface] [config_file]\n");
293 exit (1);
294}
295
296/*
297** DoTimeout -- Free any connections that have timed out.
298**
299** Parameters:
300** None.
301**
302** Returns:
303** Nothing.
304**
305** Side Effects:
306** - Timed out connections in `RmpConns' will be freed.
307*/
308void
311DoTimeout()
309DoTimeout(void)
312{
313 RMPCONN *rtmp;
314 struct timeval now;
315
316 (void) gettimeofday(&now, (struct timezone *)0);
317
318 /*
319 * For each active connection, if RMP_TIMEOUT seconds have passed
320 * since the last packet was sent, delete the connection.
321 */
322 for (rtmp = RmpConns; rtmp != NULL; rtmp = rtmp->next)
323 if ((rtmp->tstamp.tv_sec + RMP_TIMEOUT) < now.tv_sec) {
324 syslog(LOG_WARNING, "%s: connection timed out (%u)",
325 EnetStr(rtmp), rtmp->rmp.r_type);
326 RemoveConn(rtmp);
327 }
328}
329
330/*
331** FindClient -- Find client associated with a packet.
332**
333** Parameters:
334** rconn - the new packet.
335**
336** Returns:
337** Pointer to client info if found, NULL otherwise.
338**
339** Side Effects:
340** None.
341**
342** Warnings:
343** - This routine must be called with SIGHUP blocked since
344** a reconfigure can invalidate the information returned.
345*/
346
347CLIENT *
310{
311 RMPCONN *rtmp;
312 struct timeval now;
313
314 (void) gettimeofday(&now, (struct timezone *)0);
315
316 /*
317 * For each active connection, if RMP_TIMEOUT seconds have passed
318 * since the last packet was sent, delete the connection.
319 */
320 for (rtmp = RmpConns; rtmp != NULL; rtmp = rtmp->next)
321 if ((rtmp->tstamp.tv_sec + RMP_TIMEOUT) < now.tv_sec) {
322 syslog(LOG_WARNING, "%s: connection timed out (%u)",
323 EnetStr(rtmp), rtmp->rmp.r_type);
324 RemoveConn(rtmp);
325 }
326}
327
328/*
329** FindClient -- Find client associated with a packet.
330**
331** Parameters:
332** rconn - the new packet.
333**
334** Returns:
335** Pointer to client info if found, NULL otherwise.
336**
337** Side Effects:
338** None.
339**
340** Warnings:
341** - This routine must be called with SIGHUP blocked since
342** a reconfigure can invalidate the information returned.
343*/
344
345CLIENT *
348FindClient(rconn)
349 RMPCONN *rconn;
346FindClient(RMPCONN *rconn)
350{
351 CLIENT *ctmp;
352
353 for (ctmp = Clients; ctmp != NULL; ctmp = ctmp->next)
354 if (bcmp((char *)&rconn->rmp.hp_hdr.saddr[0],
355 (char *)&ctmp->addr[0], RMP_ADDRLEN) == 0)
356 break;
357
358 return(ctmp);
359}
360
361/*
362** Exit -- Log an error message and exit.
363**
364** Parameters:
365** sig - caught signal (or zero if not dying on a signal).
366**
367** Returns:
368** Does not return.
369**
370** Side Effects:
371** - This process ceases to exist.
372*/
373void
347{
348 CLIENT *ctmp;
349
350 for (ctmp = Clients; ctmp != NULL; ctmp = ctmp->next)
351 if (bcmp((char *)&rconn->rmp.hp_hdr.saddr[0],
352 (char *)&ctmp->addr[0], RMP_ADDRLEN) == 0)
353 break;
354
355 return(ctmp);
356}
357
358/*
359** Exit -- Log an error message and exit.
360**
361** Parameters:
362** sig - caught signal (or zero if not dying on a signal).
363**
364** Returns:
365** Does not return.
366**
367** Side Effects:
368** - This process ceases to exist.
369*/
370void
374Exit(sig)
375 int sig;
371Exit(int sig)
376{
377 if (sig > 0)
378 syslog(LOG_ERR, "going down on signal %d", sig);
379 else
380 syslog(LOG_ERR, "going down with fatal error");
381 BpfClose();
382 exit(1);
383}
384
385/*
386** ReConfig -- Get new list of boot files and reread config files.
387**
388** Parameters:
389** None.
390**
391** Returns:
392** Nothing.
393**
394** Side Effects:
395** - All active connections are dropped.
396** - List of boot-able files is changed.
397** - List of clients is changed.
398**
399** Warnings:
400** - This routine must be called with SIGHUP blocked.
401*/
402void
372{
373 if (sig > 0)
374 syslog(LOG_ERR, "going down on signal %d", sig);
375 else
376 syslog(LOG_ERR, "going down with fatal error");
377 BpfClose();
378 exit(1);
379}
380
381/*
382** ReConfig -- Get new list of boot files and reread config files.
383**
384** Parameters:
385** None.
386**
387** Returns:
388** Nothing.
389**
390** Side Effects:
391** - All active connections are dropped.
392** - List of boot-able files is changed.
393** - List of clients is changed.
394**
395** Warnings:
396** - This routine must be called with SIGHUP blocked.
397*/
398void
403ReConfig(signo)
404 int signo;
399ReConfig(int signo)
405{
406 syslog(LOG_NOTICE, "reconfiguring boot server");
407
408 FreeConns();
409
410 if (GetBootFiles() == 0)
411 Exit(0);
412
413 if (ParseConfig() == 0)
414 Exit(0);
415}
416
417/*
418** DebugOff -- Turn off debugging.
419**
420** Parameters:
421** None.
422**
423** Returns:
424** Nothing.
425**
426** Side Effects:
427** - Debug file is closed.
428*/
429void
400{
401 syslog(LOG_NOTICE, "reconfiguring boot server");
402
403 FreeConns();
404
405 if (GetBootFiles() == 0)
406 Exit(0);
407
408 if (ParseConfig() == 0)
409 Exit(0);
410}
411
412/*
413** DebugOff -- Turn off debugging.
414**
415** Parameters:
416** None.
417**
418** Returns:
419** Nothing.
420**
421** Side Effects:
422** - Debug file is closed.
423*/
424void
430DebugOff(signo)
431 int signo;
425DebugOff(int signo)
432{
433 if (DbgFp != NULL)
434 (void) fclose(DbgFp);
435
436 DbgFp = NULL;
437}
438
439/*
440** DebugOn -- Turn on debugging.
441**
442** Parameters:
443** None.
444**
445** Returns:
446** Nothing.
447**
448** Side Effects:
449** - Debug file is opened/truncated if not already opened,
450** otherwise do nothing.
451*/
452void
426{
427 if (DbgFp != NULL)
428 (void) fclose(DbgFp);
429
430 DbgFp = NULL;
431}
432
433/*
434** DebugOn -- Turn on debugging.
435**
436** Parameters:
437** None.
438**
439** Returns:
440** Nothing.
441**
442** Side Effects:
443** - Debug file is opened/truncated if not already opened,
444** otherwise do nothing.
445*/
446void
453DebugOn(signo)
454 int signo;
447DebugOn(int signo)
455{
456 if (DbgFp == NULL) {
457 if ((DbgFp = fopen(DbgFile, "w")) == NULL)
458 syslog(LOG_ERR, "can't open debug file (%s)", DbgFile);
459 }
460}
448{
449 if (DbgFp == NULL) {
450 if ((DbgFp = fopen(DbgFile, "w")) == NULL)
451 syslog(LOG_ERR, "can't open debug file (%s)", DbgFile);
452 }
453}