1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * dhcpcd - DHCP client daemon 4 * Copyright (c) 2006-2020 Roy Marples <roy@marples.name> 5 * All rights reserved 6 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #include <sys/stat.h> 30 #include <sys/uio.h> 31 #include <sys/wait.h> 32 33 #include <netinet/in.h> 34 #include <arpa/inet.h> 35 36 #include <assert.h> 37 #include <ctype.h> 38 #include <errno.h> 39 #include <pwd.h> 40 #include <signal.h> 41 #include <spawn.h> 42 #include <stdarg.h> 43 #include <stdlib.h> 44 #include <string.h> 45 #include <unistd.h> 46 47 #include "config.h" 48 #include "common.h" 49 #include "dhcp.h" 50 #include "dhcp6.h" 51 #include "eloop.h" 52 #include "if.h" 53 #include "if-options.h" 54 #include "ipv4ll.h" 55 #include "ipv6nd.h" 56 #include "logerr.h" 57 #include "privsep.h" 58 #include "script.h" 59 60 #define DEFAULT_PATH "/usr/bin:/usr/sbin:/bin:/sbin" 61 62 static const char * const if_params[] = { 63 "interface", 64 "protocol", 65 "reason", 66 "pid", 67 "ifcarrier", 68 "ifmetric", 69 "ifwireless", 70 "ifflags", 71 "ssid", 72 "profile", 73 "interface_order", 74 NULL 75 }; 76 77 void 78 if_printoptions(void) 79 { 80 const char * const *p; 81 82 for (p = if_params; *p; p++) 83 printf(" - %s\n", *p); 84 } 85 86 pid_t 87 script_exec(char *const *argv, char *const *env) 88 { 89 pid_t pid = 0; 90 posix_spawnattr_t attr; 91 int r; 92 #ifdef USE_SIGNALS 93 size_t i; 94 short flags; 95 sigset_t defsigs; 96 #else 97 UNUSED(ctx); 98 #endif 99 100 /* posix_spawn is a safe way of executing another image 101 * and changing signals back to how they should be. */ 102 if (posix_spawnattr_init(&attr) == -1) 103 return -1; 104 #ifdef USE_SIGNALS 105 flags = POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF; 106 posix_spawnattr_setflags(&attr, flags); 107 sigemptyset(&defsigs); 108 posix_spawnattr_setsigmask(&attr, &defsigs); 109 for (i = 0; i < dhcpcd_signals_len; i++) 110 sigaddset(&defsigs, dhcpcd_signals[i]); 111 for (i = 0; i < dhcpcd_signals_ignore_len; i++) 112 sigaddset(&defsigs, dhcpcd_signals_ignore[i]); 113 posix_spawnattr_setsigdefault(&attr, &defsigs); 114 #endif 115 errno = 0; 116 r = posix_spawn(&pid, argv[0], NULL, &attr, argv, env); 117 posix_spawnattr_destroy(&attr); 118 if (r) { 119 errno = r; 120 return -1; 121 } 122 return pid; 123 } 124 125 #ifdef INET 126 static int 127 append_config(FILE *fp, const char *prefix, const char *const *config) 128 { 129 size_t i; 130 131 if (config == NULL) 132 return 0; 133 134 /* Do we need to replace existing config rather than append? */ 135 for (i = 0; config[i] != NULL; i++) { 136 if (efprintf(fp, "%s_%s", prefix, config[i]) == -1) 137 return -1; 138 } 139 return 1; 140 } 141 142 #endif 143 144 #define PROTO_LINK 0 145 #define PROTO_DHCP 1 146 #define PROTO_IPV4LL 2 147 #define PROTO_RA 3 148 #define PROTO_DHCP6 4 149 #define PROTO_STATIC6 5 150 static const char *protocols[] = { 151 "link", 152 "dhcp", 153 "ipv4ll", 154 "ra", 155 "dhcp6", 156 "static6" 157 }; 158 159 int 160 efprintf(FILE *fp, const char *fmt, ...) 161 { 162 va_list args; 163 int r; 164 165 va_start(args, fmt); 166 r = vfprintf(fp, fmt, args); 167 va_end(args); 168 if (r == -1) 169 return -1; 170 /* Write a trailing NULL so we can easily create env strings. */ 171 if (fputc('\0', fp) == EOF) 172 return -1; 173 return r; 174 } 175 176 char ** 177 script_buftoenv(struct dhcpcd_ctx *ctx, char *buf, size_t len) 178 { 179 char **env, **envp, *bufp, *endp; 180 size_t nenv; 181 182 /* Count the terminated env strings. 183 * Assert that the terminations are correct. */ 184 nenv = 0; 185 endp = buf + len; 186 for (bufp = buf; bufp < endp; bufp++) { 187 if (*bufp == '\0') { 188 #ifndef NDEBUG 189 if (bufp + 1 < endp) 190 assert(*(bufp + 1) != '\0'); 191 #endif 192 nenv++; 193 } 194 } 195 assert(*(bufp - 1) == '\0'); 196 if (nenv == 0) 197 return NULL; 198 199 if (ctx->script_envlen < nenv) { 200 env = reallocarray(ctx->script_env, nenv + 1, sizeof(*env)); 201 if (env == NULL) 202 return NULL; 203 ctx->script_env = env; 204 ctx->script_envlen = nenv; 205 } 206 207 bufp = buf; 208 envp = ctx->script_env; 209 *envp++ = bufp++; 210 endp--; /* Avoid setting the last \0 to an invalid pointer */ 211 for (; bufp < endp; bufp++) { 212 if (*bufp == '\0') 213 *envp++ = bufp + 1; 214 } 215 *envp = NULL; 216 217 return ctx->script_env; 218 } 219 220 static long 221 make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp, 222 const char *reason) 223 { 224 FILE *fp; 225 long buf_pos, i; 226 char *path; 227 int protocol = PROTO_LINK; 228 const struct if_options *ifo; 229 const struct interface *ifp2; 230 int af; 231 #ifdef INET 232 const struct dhcp_state *state; 233 #ifdef IPV4LL 234 const struct ipv4ll_state *istate; 235 #endif 236 #endif 237 #ifdef DHCP6 238 const struct dhcp6_state *d6_state; 239 #endif 240 bool is_stdin = ifp->name[0] == '\0'; 241 242 #ifdef HAVE_OPEN_MEMSTREAM 243 if (ctx->script_fp == NULL) { 244 fp = open_memstream(&ctx->script_buf, &ctx->script_buflen); 245 if (fp == NULL) 246 goto eexit; 247 ctx->script_fp = fp; 248 } else { 249 fp = ctx->script_fp; 250 rewind(fp); 251 } 252 #else 253 char tmpfile[] = "/tmp/dhcpcd-script-env-XXXXXX"; 254 int tmpfd; 255 256 fp = NULL; 257 tmpfd = mkstemp(tmpfile); 258 if (tmpfd == -1) { 259 logerr("%s: mkstemp", __func__); 260 return -1; 261 } 262 unlink(tmpfile); 263 fp = fdopen(tmpfd, "w+"); 264 if (fp == NULL) { 265 close(tmpfd); 266 goto eexit; 267 } 268 #endif 269 270 if (!(ifp->ctx->options & DHCPCD_DUMPLEASE)) { 271 /* Needed for scripts */ 272 path = getenv("PATH"); 273 if (efprintf(fp, "PATH=%s", 274 path == NULL ? DEFAULT_PATH : path) == -1) 275 goto eexit; 276 if (efprintf(fp, "pid=%d", getpid()) == -1) 277 goto eexit; 278 } 279 if (!is_stdin) { 280 if (efprintf(fp, "reason=%s", reason) == -1) 281 goto eexit; 282 } 283 284 ifo = ifp->options; 285 #ifdef INET 286 state = D_STATE(ifp); 287 #ifdef IPV4LL 288 istate = IPV4LL_CSTATE(ifp); 289 #endif 290 #endif 291 #ifdef DHCP6 292 d6_state = D6_CSTATE(ifp); 293 #endif 294 if (strcmp(reason, "TEST") == 0) { 295 if (1 == 2) { 296 /* This space left intentionally blank 297 * as all the below statements are optional. */ 298 } 299 #ifdef INET6 300 #ifdef DHCP6 301 else if (d6_state && d6_state->new) 302 protocol = PROTO_DHCP6; 303 #endif 304 else if (ipv6nd_hasra(ifp)) 305 protocol = PROTO_RA; 306 #endif 307 #ifdef INET 308 #ifdef IPV4LL 309 else if (istate && istate->addr != NULL) 310 protocol = PROTO_IPV4LL; 311 #endif 312 else 313 protocol = PROTO_DHCP; 314 #endif 315 } 316 #ifdef INET6 317 else if (strcmp(reason, "STATIC6") == 0) 318 protocol = PROTO_STATIC6; 319 #ifdef DHCP6 320 else if (reason[strlen(reason) - 1] == '6') 321 protocol = PROTO_DHCP6; 322 #endif 323 else if (strcmp(reason, "ROUTERADVERT") == 0) 324 protocol = PROTO_RA; 325 #endif 326 else if (strcmp(reason, "PREINIT") == 0 || 327 strcmp(reason, "CARRIER") == 0 || 328 strcmp(reason, "NOCARRIER") == 0 || 329 strcmp(reason, "UNKNOWN") == 0 || 330 strcmp(reason, "DEPARTED") == 0 || 331 strcmp(reason, "STOPPED") == 0) 332 protocol = PROTO_LINK; 333 #ifdef INET 334 #ifdef IPV4LL 335 else if (strcmp(reason, "IPV4LL") == 0) 336 protocol = PROTO_IPV4LL; 337 #endif 338 else 339 protocol = PROTO_DHCP; 340 #endif 341 342 if (!is_stdin) { 343 if (efprintf(fp, "interface=%s", ifp->name) == -1) 344 goto eexit; 345 } 346 if (ifp->ctx->options & DHCPCD_DUMPLEASE) 347 goto dumplease; 348 if (efprintf(fp, "ifcarrier=%s", 349 ifp->carrier == LINK_UNKNOWN ? "unknown" : 350 ifp->carrier == LINK_UP ? "up" : "down") == -1) 351 goto eexit; 352 if (efprintf(fp, "ifmetric=%d", ifp->metric) == -1) 353 goto eexit; 354 if (efprintf(fp, "ifwireless=%d", ifp->wireless) == -1) 355 goto eexit; 356 if (efprintf(fp, "ifflags=%u", ifp->flags) == -1) 357 goto eexit; 358 if (efprintf(fp, "ifmtu=%d", if_getmtu(ifp)) == -1) 359 goto eexit; 360 361 if (fprintf(fp, "interface_order=") == -1) 362 goto eexit; 363 TAILQ_FOREACH(ifp2, ifp->ctx->ifaces, next) { 364 if (ifp2 != TAILQ_FIRST(ifp->ctx->ifaces)) { 365 if (fputc(' ', fp) == EOF) 366 return -1; 367 } 368 if (fprintf(fp, "%s", ifp2->name) == -1) 369 return -1; 370 } 371 if (fputc('\0', fp) == EOF) 372 return -1; 373 374 if (strcmp(reason, "STOPPED") == 0) { 375 if (efprintf(fp, "if_up=false") == -1) 376 goto eexit; 377 if (efprintf(fp, "if_down=%s", 378 ifo->options & DHCPCD_RELEASE ? "true" : "false") == -1) 379 goto eexit; 380 } else if (strcmp(reason, "TEST") == 0 || 381 strcmp(reason, "PREINIT") == 0 || 382 strcmp(reason, "CARRIER") == 0 || 383 strcmp(reason, "UNKNOWN") == 0) 384 { 385 if (efprintf(fp, "if_up=false") == -1) 386 goto eexit; 387 if (efprintf(fp, "if_down=false") == -1) 388 goto eexit; 389 } else if (1 == 2 /* appease ifdefs */ 390 #ifdef INET 391 || (protocol == PROTO_DHCP && state && state->new) 392 #ifdef IPV4LL 393 || (protocol == PROTO_IPV4LL && IPV4LL_STATE_RUNNING(ifp)) 394 #endif 395 #endif 396 #ifdef INET6 397 || (protocol == PROTO_STATIC6 && IPV6_STATE_RUNNING(ifp)) 398 #ifdef DHCP6 399 || (protocol == PROTO_DHCP6 && d6_state && d6_state->new) 400 #endif 401 || (protocol == PROTO_RA && ipv6nd_hasra(ifp)) 402 #endif 403 ) 404 { 405 if (efprintf(fp, "if_up=true") == -1) 406 goto eexit; 407 if (efprintf(fp, "if_down=false") == -1) 408 goto eexit; 409 } else { 410 if (efprintf(fp, "if_up=false") == -1) 411 goto eexit; 412 if (efprintf(fp, "if_down=true") == -1) 413 goto eexit; 414 } 415 if (protocols[protocol] != NULL) { 416 if (efprintf(fp, "protocol=%s", protocols[protocol]) == -1) 417 goto eexit; 418 } 419 if ((af = dhcpcd_ifafwaiting(ifp)) != AF_MAX) { 420 if (efprintf(fp, "if_afwaiting=%d", af) == -1) 421 goto eexit; 422 } 423 if ((af = dhcpcd_afwaiting(ifp->ctx)) != AF_MAX) { 424 TAILQ_FOREACH(ifp2, ifp->ctx->ifaces, next) { 425 if ((af = dhcpcd_ifafwaiting(ifp2)) != AF_MAX) 426 break; 427 } 428 } 429 if (af != AF_MAX) { 430 if (efprintf(fp, "af_waiting=%d", af) == -1) 431 goto eexit; 432 } 433 if (ifo->options & DHCPCD_DEBUG) { 434 if (efprintf(fp, "syslog_debug=true") == -1) 435 goto eexit; 436 } 437 if (*ifp->profile != '\0') { 438 if (efprintf(fp, "profile=%s", ifp->profile) == -1) 439 goto eexit; 440 } 441 if (ifp->wireless) { 442 char pssid[IF_SSIDLEN * 4]; 443 444 if (print_string(pssid, sizeof(pssid), OT_ESCSTRING, 445 ifp->ssid, ifp->ssid_len) != -1) 446 { 447 if (efprintf(fp, "ifssid=%s", pssid) == -1) 448 goto eexit; 449 } 450 } 451 #ifdef INET 452 if (protocol == PROTO_DHCP && state && state->old) { 453 if (dhcp_env(fp, "old", ifp, 454 state->old, state->old_len) == -1) 455 goto eexit; 456 if (append_config(fp, "old", 457 (const char *const *)ifo->config) == -1) 458 goto eexit; 459 } 460 #endif 461 #ifdef DHCP6 462 if (protocol == PROTO_DHCP6 && d6_state && d6_state->old) { 463 if (dhcp6_env(fp, "old", ifp, 464 d6_state->old, d6_state->old_len) == -1) 465 goto eexit; 466 } 467 #endif 468 469 dumplease: 470 #ifdef INET 471 #ifdef IPV4LL 472 if (protocol == PROTO_IPV4LL && istate) { 473 if (ipv4ll_env(fp, istate->down ? "old" : "new", ifp) == -1) 474 goto eexit; 475 } 476 #endif 477 if (protocol == PROTO_DHCP && state && state->new) { 478 if (dhcp_env(fp, "new", ifp, 479 state->new, state->new_len) == -1) 480 goto eexit; 481 if (append_config(fp, "new", 482 (const char *const *)ifo->config) == -1) 483 goto eexit; 484 } 485 #endif 486 #ifdef INET6 487 if (protocol == PROTO_STATIC6) { 488 if (ipv6_env(fp, "new", ifp) == -1) 489 goto eexit; 490 } 491 #ifdef DHCP6 492 if (protocol == PROTO_DHCP6 && D6_STATE_RUNNING(ifp)) { 493 if (dhcp6_env(fp, "new", ifp, 494 d6_state->new, d6_state->new_len) == -1) 495 goto eexit; 496 } 497 #endif 498 if (protocol == PROTO_RA) { 499 if (ipv6nd_env(fp, ifp) == -1) 500 goto eexit; 501 } 502 #endif 503 504 /* Add our base environment */ 505 if (ifo->environ) { 506 for (i = 0; ifo->environ[i] != NULL; i++) 507 if (efprintf(fp, "%s", ifo->environ[i]) == -1) 508 goto eexit; 509 } 510 511 /* Convert buffer to argv */ 512 fflush(fp); 513 514 buf_pos = ftell(fp); 515 if (buf_pos == -1) { 516 logerr(__func__); 517 goto eexit; 518 } 519 520 #ifndef HAVE_OPEN_MEMSTREAM 521 size_t buf_len = (size_t)buf_pos; 522 if (ctx->script_buflen < buf_len) { 523 char *buf = realloc(ctx->script_buf, buf_len); 524 if (buf == NULL) 525 goto eexit; 526 ctx->script_buf = buf; 527 ctx->script_buflen = buf_len; 528 } 529 rewind(fp); 530 if (fread(ctx->script_buf, sizeof(char), buf_len, fp) != buf_len) 531 goto eexit; 532 fclose(fp); 533 fp = NULL; 534 #endif 535 536 if (is_stdin) 537 return buf_pos; 538 539 if (script_buftoenv(ctx, ctx->script_buf, (size_t)buf_pos) == NULL) 540 goto eexit; 541 542 return buf_pos; 543 544 eexit: 545 logerr(__func__); 546 #ifndef HAVE_OPEN_MEMSTREAM 547 if (fp != NULL) 548 fclose(fp); 549 #endif 550 return -1; 551 } 552 553 static int 554 send_interface1(struct fd_list *fd, const struct interface *ifp, 555 const char *reason) 556 { 557 struct dhcpcd_ctx *ctx = ifp->ctx; 558 long len; 559 560 len = make_env(ifp->ctx, ifp, reason); 561 if (len == -1) 562 return -1; 563 return control_queue(fd, ctx->script_buf, (size_t)len); 564 } 565 566 int 567 send_interface(struct fd_list *fd, const struct interface *ifp, int af) 568 { 569 int retval = 0; 570 #ifdef INET 571 const struct dhcp_state *d; 572 #endif 573 #ifdef DHCP6 574 const struct dhcp6_state *d6; 575 #endif 576 577 #ifndef AF_LINK 578 #define AF_LINK AF_PACKET 579 #endif 580 581 if (af == AF_UNSPEC || af == AF_LINK) { 582 const char *reason; 583 584 switch (ifp->carrier) { 585 case LINK_UP: 586 reason = "CARRIER"; 587 break; 588 case LINK_DOWN: 589 case LINK_DOWN_IFFUP: 590 reason = "NOCARRIER"; 591 break; 592 default: 593 reason = "UNKNOWN"; 594 break; 595 } 596 if (fd != NULL) { 597 if (send_interface1(fd, ifp, reason) == -1) 598 retval = -1; 599 } else 600 retval++; 601 } 602 603 #ifdef INET 604 if (af == AF_UNSPEC || af == AF_INET) { 605 if (D_STATE_RUNNING(ifp)) { 606 d = D_CSTATE(ifp); 607 if (fd != NULL) { 608 if (send_interface1(fd, ifp, d->reason) == -1) 609 retval = -1; 610 } else 611 retval++; 612 } 613 #ifdef IPV4LL 614 if (IPV4LL_STATE_RUNNING(ifp)) { 615 if (fd != NULL) { 616 if (send_interface1(fd, ifp, "IPV4LL") == -1) 617 retval = -1; 618 } else 619 retval++; 620 } 621 #endif 622 } 623 #endif 624 625 #ifdef INET6 626 if (af == AF_UNSPEC || af == AF_INET6) { 627 if (IPV6_STATE_RUNNING(ifp)) { 628 if (fd != NULL) { 629 if (send_interface1(fd, ifp, "STATIC6") == -1) 630 retval = -1; 631 } else 632 retval++; 633 } 634 if (RS_STATE_RUNNING(ifp)) { 635 if (fd != NULL) { 636 if (send_interface1(fd, ifp, 637 "ROUTERADVERT") == -1) 638 retval = -1; 639 } else 640 retval++; 641 } 642 #ifdef DHCP6 643 if (D6_STATE_RUNNING(ifp)) { 644 d6 = D6_CSTATE(ifp); 645 if (fd != NULL) { 646 if (send_interface1(fd, ifp, d6->reason) == -1) 647 retval = -1; 648 } else 649 retval++; 650 } 651 #endif 652 } 653 #endif 654 655 return retval; 656 } 657 658 static int 659 script_run(struct dhcpcd_ctx *ctx, char **argv) 660 { 661 pid_t pid; 662 int status = 0; 663 664 pid = script_exec(argv, ctx->script_env); 665 if (pid == -1) 666 logerr("%s: %s", __func__, argv[0]); 667 else if (pid != 0) { 668 /* Wait for the script to finish */ 669 while (waitpid(pid, &status, 0) == -1) { 670 if (errno != EINTR) { 671 logerr("%s: waitpid", __func__); 672 status = 0; 673 break; 674 } 675 } 676 if (WIFEXITED(status)) { 677 if (WEXITSTATUS(status)) 678 logerrx("%s: %s: WEXITSTATUS %d", 679 __func__, argv[0], WEXITSTATUS(status)); 680 } else if (WIFSIGNALED(status)) 681 logerrx("%s: %s: %s", 682 __func__, argv[0], strsignal(WTERMSIG(status))); 683 } 684 685 return WEXITSTATUS(status); 686 } 687 688 int 689 script_dump(const char *env, size_t len) 690 { 691 const char *ep = env + len; 692 693 if (len == 0) 694 return 0; 695 696 if (*(ep - 1) != '\0') { 697 errno = EINVAL; 698 return -1; 699 } 700 701 for (; env < ep; env += strlen(env) + 1) { 702 if (strncmp(env, "new_", 4) == 0) 703 env += 4; 704 printf("%s\n", env); 705 } 706 return 0; 707 } 708 709 int 710 script_runreason(const struct interface *ifp, const char *reason) 711 { 712 struct dhcpcd_ctx *ctx = ifp->ctx; 713 char *argv[2]; 714 int status = 0; 715 struct fd_list *fd; 716 long buflen; 717 718 if (ctx->script == NULL && 719 TAILQ_FIRST(&ifp->ctx->control_fds) == NULL) 720 return 0; 721 722 /* Make our env */ 723 if ((buflen = make_env(ifp->ctx, ifp, reason)) == -1) { 724 logerr(__func__); 725 return -1; 726 } 727 728 if (strncmp(reason, "DUMP", 4) == 0) 729 return script_dump(ctx->script_buf, (size_t)buflen); 730 731 if (ctx->script == NULL) 732 goto send_listeners; 733 734 argv[0] = ctx->script; 735 argv[1] = NULL; 736 logdebugx("%s: executing `%s' %s", ifp->name, argv[0], reason); 737 738 #ifdef PRIVSEP 739 if (ctx->options & DHCPCD_PRIVSEP) { 740 if (ps_root_script(ctx, 741 ctx->script_buf, ctx->script_buflen) == -1) 742 logerr(__func__); 743 goto send_listeners; 744 } 745 #endif 746 747 script_run(ctx, argv); 748 749 send_listeners: 750 /* Send to our listeners */ 751 status = 0; 752 TAILQ_FOREACH(fd, &ctx->control_fds, next) { 753 if (!(fd->flags & FD_LISTEN)) 754 continue; 755 if (control_queue(fd, ctx->script_buf, ctx->script_buflen)== -1) 756 logerr("%s: control_queue", __func__); 757 else 758 status = 1; 759 } 760 761 return status; 762 } 763