1 /*- 2 * Copyright (c) 1999-2001 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 #include <sys/param.h> 30 #include <sys/socket.h> 31 #include <sys/un.h> 32 #include <netinet/in.h> 33 #include <arpa/inet.h> 34 #include <netdb.h> 35 #include <netgraph.h> 36 #include <net/ethernet.h> 37 #include <netinet/in_systm.h> 38 #include <netinet/ip.h> 39 #include <netgraph/ng_ether.h> 40 #include <netgraph/ng_message.h> 41 #include <netgraph/ng_pppoe.h> 42 #include <netgraph/ng_socket.h> 43 44 #include <errno.h> 45 #include <paths.h> 46 #include <signal.h> 47 #include <stdio.h> 48 #include <stdarg.h> 49 #include <stdlib.h> 50 #include <string.h> 51 #include <sysexits.h> 52 #include <sys/fcntl.h> 53 #ifndef NOKLDLOAD 54 #include <sys/linker.h> 55 #include <sys/module.h> 56 #endif 57 #include <sys/uio.h> 58 #include <sys/wait.h> 59 #include <syslog.h> 60 #include <termios.h> 61 #include <unistd.h> 62 63 64 #define DEFAULT_EXEC_PREFIX "exec /usr/sbin/ppp -direct " 65 66 static int ReceivedSignal; 67 68 static int 69 usage(const char *prog) 70 { 71 fprintf(stderr, "Usage: %s [-Fd] [-P pidfile] [-a name] [-e exec | -l label]" 72 " [-p provider] interface\n", prog); 73 return EX_USAGE; 74 } 75 76 static void 77 Farewell(int sig) 78 { 79 ReceivedSignal = sig; 80 } 81 82 static int 83 ConfigureNode(const char *prog, const char *iface, const char *provider, 84 int cs, int ds, int debug, struct ngm_connect *ngc) 85 { 86 /* 87 * We're going to do this with the passed `ds' & `cs' descriptors: 88 * 89 * .---------. 90 * | ether | 91 * | <iface> | 92 * `---------' 93 * (orphan) ds cs 94 * | | | 95 * | | | 96 * (ethernet) | | 97 * .---------. .-----------. 98 * | pppoe | | socket | 99 * | <iface> |(pppoe-<pid>)<---->(pppoe-<pid>)| <unnamed> | 100 * `--------- `-----------' 101 * (exec-<pid>) 102 * ^ .-----------. .-------------. 103 * | | socket | | ppp -direct | 104 * `--->(exec-<pid>)| <unnamed> |--fd--| provider | 105 * `-----------' `-------------' 106 * 107 * where there are potentially many ppp processes running off of the 108 * same PPPoE node. 109 * The exec-<pid> hook isn't made 'till we Spawn(). 110 */ 111 112 char *epath, *spath; 113 struct ngpppoe_init_data *data; 114 const struct hooklist *hlist; 115 const struct nodeinfo *ninfo; 116 const struct linkinfo *nlink; 117 struct ngm_mkpeer mkp; 118 struct ng_mesg *resp; 119 u_char rbuf[2048]; 120 int f, plen; 121 122 /* 123 * Ask for a list of hooks attached to the "ether" node. This node should 124 * magically exist as a way of hooking stuff onto an ethernet device 125 */ 126 epath = (char *)alloca(strlen(iface) + 2); 127 sprintf(epath, "%s:", iface); 128 129 if (debug) 130 fprintf(stderr, "Sending NGM_LISTHOOKS to %s\n", epath); 131 132 if (NgSendMsg(cs, epath, NGM_GENERIC_COOKIE, NGM_LISTHOOKS, NULL, 0) < 0) { 133 if (errno == ENOENT) 134 fprintf(stderr, "%s Cannot send a netgraph message: Invalid interface\n", 135 epath); 136 else 137 fprintf(stderr, "%s Cannot send a netgraph message: %s\n", 138 epath, strerror(errno)); 139 return EX_UNAVAILABLE; 140 } 141 142 /* Get our list back */ 143 resp = (struct ng_mesg *)rbuf; 144 if (NgRecvMsg(cs, resp, sizeof rbuf, NULL) <= 0) { 145 perror("Cannot get netgraph response"); 146 return EX_UNAVAILABLE; 147 } 148 149 hlist = (const struct hooklist *)resp->data; 150 ninfo = &hlist->nodeinfo; 151 152 if (debug) 153 fprintf(stderr, "Got reply from id [%x]: Type %s with %d hooks\n", 154 ninfo->id, ninfo->type, ninfo->hooks); 155 156 /* Make sure we've got the right type of node */ 157 if (strncmp(ninfo->type, NG_ETHER_NODE_TYPE, sizeof NG_ETHER_NODE_TYPE - 1)) { 158 fprintf(stderr, "%s Unexpected node type ``%s'' (wanted ``" 159 NG_ETHER_NODE_TYPE "'')\n", epath, ninfo->type); 160 return EX_DATAERR; 161 } 162 163 /* look for a hook already attached. */ 164 for (f = 0; f < ninfo->hooks; f++) { 165 nlink = &hlist->link[f]; 166 167 if (debug) 168 fprintf(stderr, " Got [%x]:%s -> [%x]:%s\n", ninfo->id, 169 nlink->ourhook, nlink->nodeinfo.id, nlink->peerhook); 170 171 if (!strcmp(nlink->ourhook, NG_ETHER_HOOK_ORPHAN) || 172 !strcmp(nlink->ourhook, NG_ETHER_HOOK_DIVERT)) { 173 /* 174 * Something is using the data coming out of this `ether' node. 175 * If it's a PPPoE node, we use that node, otherwise we complain that 176 * someone else is using the node. 177 */ 178 if (strcmp(nlink->nodeinfo.type, NG_PPPOE_NODE_TYPE)) { 179 fprintf(stderr, "%s Node type %s is currently active\n", 180 epath, nlink->nodeinfo.type); 181 return EX_UNAVAILABLE; 182 } 183 break; 184 } 185 } 186 187 if (f == ninfo->hooks) { 188 /* 189 * Create a new PPPoE node connected to the `ether' node using 190 * the magic `orphan' and `ethernet' hooks 191 */ 192 snprintf(mkp.type, sizeof mkp.type, "%s", NG_PPPOE_NODE_TYPE); 193 snprintf(mkp.ourhook, sizeof mkp.ourhook, "%s", NG_ETHER_HOOK_ORPHAN); 194 snprintf(mkp.peerhook, sizeof mkp.peerhook, "%s", NG_PPPOE_HOOK_ETHERNET); 195 196 if (debug) 197 fprintf(stderr, "Send MKPEER: %s%s -> [type %s]:%s\n", epath, 198 mkp.ourhook, mkp.type, mkp.peerhook); 199 200 if (NgSendMsg(cs, epath, NGM_GENERIC_COOKIE, 201 NGM_MKPEER, &mkp, sizeof mkp) < 0) { 202 fprintf(stderr, "%s Cannot create a peer PPPoE node: %s\n", 203 epath, strerror(errno)); 204 return EX_OSERR; 205 } 206 } 207 208 /* Connect the PPPoE node to our socket node. */ 209 snprintf(ngc->path, sizeof ngc->path, "%s%s", epath, NG_ETHER_HOOK_ORPHAN); 210 snprintf(ngc->ourhook, sizeof ngc->ourhook, "pppoe-%ld", (long)getpid()); 211 memcpy(ngc->peerhook, ngc->ourhook, sizeof ngc->peerhook); 212 213 if (NgSendMsg(cs, ".:", NGM_GENERIC_COOKIE, 214 NGM_CONNECT, ngc, sizeof *ngc) < 0) { 215 perror("Cannot CONNECT PPPoE and socket nodes"); 216 return EX_OSERR; 217 } 218 219 plen = strlen(provider); 220 221 data = (struct ngpppoe_init_data *)alloca(sizeof *data + plen); 222 snprintf(data->hook, sizeof data->hook, "%s", ngc->peerhook); 223 memcpy(data->data, provider, plen); 224 data->data_len = plen; 225 226 spath = (char *)alloca(strlen(ngc->peerhook) + 3); 227 strcpy(spath, ".:"); 228 strcpy(spath + 2, ngc->ourhook); 229 230 if (debug) { 231 if (provider) 232 fprintf(stderr, "Sending PPPOE_LISTEN to %s, provider %s\n", 233 spath, provider); 234 else 235 fprintf(stderr, "Sending PPPOE_LISTEN to %s\n", spath); 236 } 237 238 if (NgSendMsg(cs, spath, NGM_PPPOE_COOKIE, NGM_PPPOE_LISTEN, 239 data, sizeof *data + plen) == -1) { 240 fprintf(stderr, "%s: Cannot LISTEN on netgraph node: %s\n", 241 spath, strerror(errno)); 242 return EX_OSERR; 243 } 244 245 return 0; 246 } 247 248 static void 249 Spawn(const char *prog, const char *acname, const char *provider, 250 const char *exec, 251 struct ngm_connect ngc, int cs, int ds, void *request, int sz, 252 int debug) 253 { 254 char msgbuf[sizeof(struct ng_mesg) + sizeof(struct ngpppoe_sts)]; 255 struct ng_mesg *rep = (struct ng_mesg *)msgbuf; 256 struct ngpppoe_sts *sts = (struct ngpppoe_sts *)(msgbuf + sizeof *rep); 257 struct ngpppoe_init_data *data; 258 char unknown[14], *path; 259 const char *msg; 260 int ret, slen; 261 262 switch ((ret = fork())) { 263 case -1: 264 syslog(LOG_ERR, "fork: %m"); 265 break; 266 267 case 0: 268 switch (fork()) { 269 case 0: 270 break; 271 case -1: 272 _exit(errno); 273 default: 274 _exit(0); 275 } 276 close(cs); 277 close(ds); 278 279 /* Create a new socket node */ 280 if (debug) 281 syslog(LOG_INFO, "Creating a new socket node"); 282 283 if (NgMkSockNode(NULL, &cs, &ds) == -1) { 284 syslog(LOG_ERR, "Cannot create netgraph socket node: %m"); 285 _exit(EX_CANTCREAT); 286 } 287 288 /* Connect the PPPoE node to our new socket node. */ 289 snprintf(ngc.ourhook, sizeof ngc.ourhook, "exec-%ld", (long)getpid()); 290 memcpy(ngc.peerhook, ngc.ourhook, sizeof ngc.peerhook); 291 292 if (debug) 293 syslog(LOG_INFO, "Sending CONNECT from .:%s -> %s.%s", 294 ngc.ourhook, ngc.path, ngc.peerhook); 295 if (NgSendMsg(cs, ".:", NGM_GENERIC_COOKIE, 296 NGM_CONNECT, &ngc, sizeof ngc) < 0) { 297 syslog(LOG_ERR, "Cannot CONNECT PPPoE and socket nodes: %m"); 298 _exit(EX_OSERR); 299 } 300 301 /* 302 * If we tell the socket node not to LINGER, it will go away when 303 * the last hook is removed. 304 */ 305 if (debug) 306 syslog(LOG_INFO, "Sending NGM_SOCK_CMD_NOLINGER to socket"); 307 if (NgSendMsg(cs, ".:", NGM_SOCKET_COOKIE, 308 NGM_SOCK_CMD_NOLINGER, NULL, 0) < 0) { 309 syslog(LOG_ERR, "Cannot send NGM_SOCK_CMD_NOLINGER: %m"); 310 _exit(EX_OSERR); 311 } 312 313 /* Put the PPPoE node into OFFER mode */ 314 slen = strlen(acname); 315 data = (struct ngpppoe_init_data *)alloca(sizeof *data + slen); 316 snprintf(data->hook, sizeof data->hook, "%s", ngc.ourhook); 317 memcpy(data->data, acname, slen); 318 data->data_len = slen; 319 320 path = (char *)alloca(strlen(ngc.ourhook) + 3); 321 strcpy(path, ".:"); 322 strcpy(path + 2, ngc.ourhook); 323 324 syslog(LOG_INFO, "Offering to %s as access concentrator %s", 325 path, acname); 326 if (NgSendMsg(cs, path, NGM_PPPOE_COOKIE, NGM_PPPOE_OFFER, 327 data, sizeof *data + slen) == -1) { 328 syslog(LOG_INFO, "%s: Cannot OFFER on netgraph node: %m", path); 329 _exit(EX_OSERR); 330 } 331 /* If we have a provider code, set it */ 332 if (provider) { 333 slen = strlen(provider); 334 data = (struct ngpppoe_init_data *)alloca(sizeof *data + slen); 335 snprintf(data->hook, sizeof data->hook, "%s", ngc.ourhook); 336 memcpy(data->data, provider, slen); 337 data->data_len = slen; 338 339 syslog(LOG_INFO, "adding to %s as offered service %s", 340 path, acname); 341 if (NgSendMsg(cs, path, NGM_PPPOE_COOKIE, NGM_PPPOE_SERVICE, 342 data, sizeof *data + slen) == -1) { 343 syslog(LOG_INFO, "%s: Cannot add service on netgraph node: %m", path); 344 _exit(EX_OSERR); 345 } 346 } 347 348 /* And send our request data to the waiting node */ 349 if (debug) 350 syslog(LOG_INFO, "Sending original request to %s (%d bytes)", path, sz); 351 if (NgSendData(ds, ngc.ourhook, request, sz) == -1) { 352 syslog(LOG_ERR, "Cannot send original request to %s: %m", path); 353 _exit(EX_OSERR); 354 } 355 356 /* Then wait for a success indication */ 357 358 if (debug) 359 syslog(LOG_INFO, "Waiting for a SUCCESS reply %s", path); 360 361 do { 362 if ((ret = NgRecvMsg(cs, rep, sizeof msgbuf, NULL) < 0)) { 363 syslog(LOG_ERR, "%s: Cannot receive a message: %m", path); 364 _exit(EX_OSERR); 365 } 366 367 if (ret == 0) { 368 /* The socket has been closed */ 369 syslog(LOG_INFO, "%s: Client timed out", path); 370 _exit(EX_TEMPFAIL); 371 } 372 373 if (rep->header.version != NG_VERSION) { 374 syslog(LOG_ERR, "%ld: Unexpected netgraph version, expected %ld", 375 (long)rep->header.version, (long)NG_VERSION); 376 _exit(EX_PROTOCOL); 377 } 378 379 if (rep->header.typecookie != NGM_PPPOE_COOKIE) { 380 syslog(LOG_INFO, "%ld: Unexpected netgraph cookie, expected %ld", 381 (long)rep->header.typecookie, (long)NGM_PPPOE_COOKIE); 382 continue; 383 } 384 385 switch (rep->header.cmd) { 386 case NGM_PPPOE_SET_FLAG: msg = "SET_FLAG"; break; 387 case NGM_PPPOE_CONNECT: msg = "CONNECT"; break; 388 case NGM_PPPOE_LISTEN: msg = "LISTEN"; break; 389 case NGM_PPPOE_OFFER: msg = "OFFER"; break; 390 case NGM_PPPOE_SUCCESS: msg = "SUCCESS"; break; 391 case NGM_PPPOE_FAIL: msg = "FAIL"; break; 392 case NGM_PPPOE_CLOSE: msg = "CLOSE"; break; 393 case NGM_PPPOE_GET_STATUS: msg = "GET_STATUS"; break; 394 default: 395 snprintf(unknown, sizeof unknown, "<%d>", (int)rep->header.cmd); 396 msg = unknown; 397 break; 398 } 399 400 switch (rep->header.cmd) { 401 case NGM_PPPOE_FAIL: 402 case NGM_PPPOE_CLOSE: 403 syslog(LOG_ERR, "Received NGM_PPPOE_%s (hook \"%s\")", 404 msg, sts->hook); 405 _exit(0); 406 } 407 408 syslog(LOG_INFO, "Received NGM_PPPOE_%s (hook \"%s\")", msg, sts->hook); 409 } while (rep->header.cmd != NGM_PPPOE_SUCCESS); 410 411 dup2(ds, STDIN_FILENO); 412 dup2(ds, STDOUT_FILENO); 413 close(ds); 414 close(cs); 415 416 setsid(); 417 syslog(LOG_INFO, "Executing: %s", exec); 418 execlp(_PATH_BSHELL, _PATH_BSHELL, "-c", exec, (char *)NULL); 419 syslog(LOG_ERR, "execlp failed: %m"); 420 _exit(EX_OSFILE); 421 422 default: 423 wait(&ret); 424 errno = ret; 425 if (errno) 426 syslog(LOG_ERR, "Second fork failed: %m"); 427 break; 428 } 429 } 430 431 #ifndef NOKLDLOAD 432 static int 433 LoadModules(void) 434 { 435 const char *module[] = { "netgraph", "ng_socket", "ng_ether", "ng_pppoe" }; 436 int f; 437 438 for (f = 0; f < sizeof module / sizeof *module; f++) 439 if (modfind(module[f]) == -1 && kldload(module[f]) == -1) { 440 fprintf(stderr, "kldload: %s: %s\n", module[f], strerror(errno)); 441 return 0; 442 } 443 444 return 1; 445 } 446 #endif 447 448 static void 449 nglog(const char *fmt, ...) 450 { 451 char nfmt[256]; 452 va_list ap; 453 454 snprintf(nfmt, sizeof nfmt, "%s: %s", fmt, strerror(errno)); 455 va_start(ap, fmt); 456 vsyslog(LOG_INFO, nfmt, ap); 457 va_end(ap); 458 } 459 460 static void 461 nglogx(const char *fmt, ...) 462 { 463 va_list ap; 464 465 va_start(ap, fmt); 466 vsyslog(LOG_INFO, fmt, ap); 467 va_end(ap); 468 } 469 470 int 471 main(int argc, char **argv) 472 { 473 char hostname[MAXHOSTNAMELEN], *exec, rhook[NG_HOOKLEN + 1]; 474 unsigned char response[1024]; 475 const char *label, *prog, *provider, *acname; 476 struct ngm_connect ngc; 477 struct sigaction act; 478 int ch, cs, ds, ret, optF, optd, optn, sz, f; 479 const char *pidfile; 480 481 prog = strrchr(argv[0], '/'); 482 prog = prog ? prog + 1 : argv[0]; 483 pidfile = NULL; 484 exec = NULL; 485 label = NULL; 486 acname = NULL; 487 provider = ""; 488 optF = optd = optn = 0; 489 490 while ((ch = getopt(argc, argv, "FP:a:de:l:n:p:")) != -1) { 491 switch (ch) { 492 case 'F': 493 optF = 1; 494 break; 495 496 case 'P': 497 pidfile = optarg; 498 break; 499 500 case 'a': 501 acname = optarg; 502 break; 503 504 case 'd': 505 optd = 1; 506 break; 507 508 case 'e': 509 exec = optarg; 510 break; 511 512 case 'l': 513 label = optarg; 514 break; 515 516 case 'n': 517 optn = 1; 518 NgSetDebug(atoi(optarg)); 519 break; 520 521 case 'p': 522 provider = optarg; 523 break; 524 525 default: 526 return usage(prog); 527 } 528 } 529 530 if (optind >= argc || optind + 2 < argc) 531 return usage(prog); 532 533 if (exec != NULL && label != NULL) 534 return usage(prog); 535 536 if (exec == NULL) { 537 if (label == NULL) 538 label = provider; 539 if (label == NULL) { 540 fprintf(stderr, "%s: Either a provider, a label or an exec command" 541 " must be given\n", prog); 542 return usage(prog); 543 } 544 exec = (char *)alloca(sizeof DEFAULT_EXEC_PREFIX + strlen(label)); 545 if (exec == NULL) { 546 fprintf(stderr, "%s: Cannot allocate %d bytes\n", prog, 547 (int)(sizeof DEFAULT_EXEC_PREFIX) + strlen(label)); 548 return EX_OSERR; 549 } 550 strcpy(exec, DEFAULT_EXEC_PREFIX); 551 strcpy(exec + sizeof DEFAULT_EXEC_PREFIX - 1, label); 552 } 553 554 if (acname == NULL) { 555 char *dot; 556 557 if (gethostname(hostname, sizeof hostname)) 558 strcpy(hostname, "localhost"); 559 else if ((dot = strchr(hostname, '.'))) 560 *dot = '\0'; 561 562 acname = hostname; 563 } 564 565 #ifndef NOKLDLOAD 566 if (!LoadModules()) 567 return EX_UNAVAILABLE; 568 #endif 569 570 /* Create a socket node */ 571 if (NgMkSockNode(NULL, &cs, &ds) == -1) { 572 perror("Cannot create netgraph socket node"); 573 return EX_CANTCREAT; 574 } 575 576 /* Connect it up (and fill in `ngc') */ 577 if ((ret = ConfigureNode(prog, argv[optind], provider, cs, ds, 578 optd, &ngc)) != 0) { 579 close(cs); 580 close(ds); 581 return ret; 582 } 583 584 if (!optF && daemon(1, 0) == -1) { 585 perror("daemon()"); 586 close(cs); 587 close(ds); 588 return EX_OSERR; 589 } 590 591 592 if (pidfile != NULL) { 593 FILE *fp; 594 595 if ((fp = fopen(pidfile, "w")) == NULL) { 596 perror(pidfile); 597 close(cs); 598 close(ds); 599 return EX_CANTCREAT; 600 } else { 601 fprintf(fp, "%d\n", (int)getpid()); 602 fclose(fp); 603 } 604 } 605 606 openlog(prog, LOG_PID | (optF ? LOG_PERROR : 0), LOG_DAEMON); 607 if (!optF && optn) 608 NgSetErrLog(nglog, nglogx); 609 610 memset(&act, '\0', sizeof act); 611 act.sa_handler = Farewell; 612 act.sa_flags = 0; 613 sigemptyset(&act.sa_mask); 614 sigaction(SIGHUP, &act, NULL); 615 sigaction(SIGINT, &act, NULL); 616 sigaction(SIGQUIT, &act, NULL); 617 sigaction(SIGTERM, &act, NULL); 618 619 while (!ReceivedSignal) { 620 if (*provider) 621 syslog(LOG_INFO, "Listening as provider %s", provider); 622 else 623 syslog(LOG_INFO, "Listening"); 624 625 switch (sz = NgRecvData(ds, response, sizeof response, rhook)) { 626 case -1: 627 syslog(LOG_INFO, "NgRecvData: %m"); 628 break; 629 case 0: 630 syslog(LOG_INFO, "NgRecvData: socket closed"); 631 break; 632 default: 633 if (optd) { 634 char *dbuf, *ptr; 635 636 ptr = dbuf = alloca(sz * 2 + 1); 637 for (f = 0; f < sz; f++, ptr += 2) 638 sprintf(ptr, "%02x", (u_char)response[f]); 639 *ptr = '\0'; 640 syslog(LOG_INFO, "Got %d bytes of data: %s", sz, dbuf); 641 } 642 } 643 if (sz <= 0) { 644 ret = EX_UNAVAILABLE; 645 break; 646 } 647 Spawn(prog, acname, provider, exec, ngc, cs, ds, response, sz, optd); 648 } 649 650 if (pidfile) 651 remove(pidfile); 652 653 if (ReceivedSignal) { 654 syslog(LOG_INFO, "Received signal %d, exiting", ReceivedSignal); 655 656 signal(ReceivedSignal, SIG_DFL); 657 raise(ReceivedSignal); 658 659 /* NOTREACHED */ 660 661 ret = -ReceivedSignal; 662 } 663 664 return ret; 665 } 666