Lines Matching +full:un +full:- +full:approved

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
31 /*-
32 * SPDX-License-Identifier: BSD-2-Clause
34 * Copyright (c) 2018 Prodrive Technologies, https://prodrive-technologies.com/
60 * syslogd -- log system messages
75 * -u and -v by Harlan Stenn.
97 #include <sys/un.h>
150 (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
151 (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
152 (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
153 (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
209 * Queue of about-to-be dead processes we should watch out for.
253 #define MAXREPEAT (nitems(repeatinterval) - 1)
254 #define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount])
256 if (++(f)->f_repeatcount > MAXREPEAT) \
257 (f)->f_repeatcount = MAXREPEAT; \
308 static int mask_C1 = 1; /* mask characters from 0x80 - 0x9F */
373 switch (f->f_type) {
375 if (f->f_addr_fds != NULL) {
376 free(f->f_addrs);
377 for (size_t i = 0; i < f->f_num_addr_fds; ++i)
378 close(f->f_addr_fds[i]);
379 free(f->f_addr_fds);
380 f->f_addr_fds = NULL;
381 f->f_num_addr_fds = 0;
387 f->f_type = F_UNUSED;
390 if (f->f_procdesc != -1) {
395 (void)close(f->f_procdesc);
396 f->f_procdesc = -1;
401 if (f->f_dq != NULL) {
402 deadq_remove(f->f_dq);
403 f->f_dq = NULL;
410 if (f->f_file != -1)
411 (void)close(f->f_file);
412 f->f_file = -1;
421 pe->pe_name = name;
422 pe->pe_serv = serv;
423 pe->pe_mode = mode;
490 for (res = res0; res != NULL; res = res->ai_next) {
505 sl->sl_socket = fd;
506 sl->sl_recv = socklist_recv_file;
517 int ch, ppipe_w = -1, s;
525 != -1)
649 else if (strcmp(optarg, "rfc3164-strict") == 0)
678 if ((argc -= optind) != 0)
698 addsock(pe->pe_name, pe->pe_serv, pe->pe_mode);
708 /* Listen by default: *:514 if no -b flag. */
711 /* Listen by default: /var/run/log if no -p flag. */
714 /* Listen by default: /var/run/logpriv if no -S flag. */
719 consfile.f_file = -1;
720 (void)strlcpy(consfile.f_fname, _PATH_CONSOLE + sizeof(_PATH_DEV) - 1,
724 if (nulldesc == -1) {
738 if (kq == -1) {
744 if (sl->sl_recv == NULL)
746 EV_SET(&ev, sl->sl_socket, EVFILT_READ, EV_ADD, 0, 0, sl);
747 if (kevent(kq, &ev, 1, NULL, 0, NULL) == -1) {
763 if (kevent(kq, &ev, 1, NULL, 0, NULL) == -1) {
768 if (sigaction(sigcatch[i], &act, NULL) == -1) {
784 if (ppipe_w != -1) {
791 ppipe_w = -1;
794 if (kevent(kq, NULL, 0, &ev, 1, NULL) == -1) {
802 if (sl->sl_socket != -1 && sl->sl_recv != NULL)
803 sl->sl_recv(sl);
842 len = recvfrom(sl->sl_socket, line, sizeof(line) - 1, 0, sa, &sslen);
845 return (-1);
849 return (-1);
853 if (sl->sl_sa != NULL && sl->sl_family == AF_LOCAL)
860 return (-1);
876 sa->sa_family != AF_INET6 ||
877 sa->sa_len != sizeof(*sin6))
880 if (!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
885 .sin_port = sin6->sin6_port
887 memcpy(&sin.sin_addr, &sin6->sin6_addr.s6_addr[12],
901 "usage: syslogd [-468ACcdFHknosTuv] [-a allowed_peer]\n"
902 " [-b bind_address] [-f config_file]\n"
903 " [-l [mode:]path] [-M fwd_length]\n"
904 " [-m mark_interval] [-O format] [-P pid_file]\n"
905 " [-p log_socket] [-S logpriv_socket]\n");
911 * TODO: Permit UTF-8 strings that include a BOM per RFC 5424?
920 while ((c = (unsigned char)*in++) != '\0' && q < out + outlen - 4) {
924 *q++ = '-';
968 if (msg[0] == '-' && msg[1] == ' ') { \
971 } else if (msg[0] == '-' && msg[1] == '\0') { \
978 /* Parse RFC 3339-like timestamp. */
985 v = v * 10 + *msg++ - '0'; \
993 timestamp_remote.tm.tm_year -= 1900;
994 PARSE_CHAR("TIMESTAMP", '-');
996 --timestamp_remote.tm.tm_mon;
997 PARSE_CHAR("TIMESTAMP", '-');
1015 timestamp_remote.usec += (*msg++ - '0') * i;
1026 FAIL_IF("TIMESTAMP", *msg != '-' && *msg != '+');
1027 sign = *msg++ == '-' ? -1 : 1;
1047 msg[-1] = '\0'; \
1052 PARSE_STRING("APP-NAME", app_name);
1065 FAIL_IF("STRUCTURED-NAME", start == msg); \
1069 /* SD-ELEMENT. */
1072 /* SD-ID. */
1074 /* SD-PARAM. */
1077 /* PARAM-NAME. */
1079 PARSE_CHAR("STRUCTURED-NAME", '=');
1080 PARSE_CHAR("STRUCTURED-NAME", '"');
1082 FAIL_IF("STRUCTURED-NAME",
1085 FAIL_IF("STRUCTURED-NAME",
1092 PARSE_CHAR("STRUCTURED-NAME", ']');
1094 PARSE_CHAR("STRUCTURED-NAME", ' ');
1095 msg[-1] = '\0';
1126 "_-/");
1152 procid_begin == NULL ? 0 : procid_begin - msg;
1246 for (year = tm_now.tm_year + 1;; --year) {
1247 assert(year >= tm_now.tm_year - 1);
1250 timestamp_remote.tm.tm_isdst = -1;
1304 i = -1;
1352 i = read(sl->sl_socket, line + len, MAXLINE - 1 - len);
1358 close(sl->sl_socket);
1359 sl->sl_socket = -1;
1369 if (len >= MAXLINE - 1) {
1420 * Return a non-0 value if the message must be ignored
1434 case '-':
1449 prev = (s == spec ? ',' : *(s - 1));
1465 * Return a non-0 value if the message must be ignored
1472 const int exclude = ((filter->cmp_flags & FILT_FLAG_EXCLUDE) > 0);
1476 return (-1);
1478 if (filter->cmp_type == FILT_CMP_REGEX) {
1479 if (regexec(filter->pflt_re, value, 0, NULL, 0) == 0)
1488 if (filter->cmp_type == FILT_CMP_EQUAL &&
1489 valuelen != strlen(filter->pflt_strval))
1492 if (filter->cmp_flags & FILT_FLAG_ICASE)
1493 s = strcasestr(value, filter->pflt_strval);
1495 s = strstr(value, filter->pflt_strval);
1501 * valuelen == filter->pflt_strlen
1506 switch (filter->cmp_type) {
1523 return (-1);
1600 app_name == NULL ? "-" : app_name, procid == NULL ? "-" : procid,
1601 msgid == NULL ? "-" : msgid,
1602 structured_data == NULL ? "-" : structured_data, msg);
1606 if (!(((f->f_pcmp[fac] & PRI_EQ) && (f->f_pmask[fac] == prilev))
1607 ||((f->f_pcmp[fac] & PRI_LT) && (f->f_pmask[fac] < prilev))
1608 ||((f->f_pcmp[fac] & PRI_GT) && (f->f_pmask[fac] > prilev))
1610 || f->f_pmask[fac] == INTERNAL_NOPRI)
1614 if (skip_message(hostname, f->f_host, 0))
1619 if (skip_message(kernel_app_name, f->f_program, 1))
1622 f->f_program, 1))
1626 if (f->f_prop_filter != NULL &&
1627 f->f_prop_filter->prop_type != FILT_PROP_NOOP) {
1628 switch (f->f_prop_filter->prop_type) {
1630 if (evaluate_prop_filter(f->f_prop_filter,
1635 if (evaluate_prop_filter(f->f_prop_filter,
1640 if (evaluate_prop_filter(f->f_prop_filter,
1650 if (f->f_type == F_CONSOLE && (flags & IGN_CONS))
1654 if ((flags & MARK) && (now - f->f_time) < MarkInterval / 2)
1660 if (no_compress - (f->f_type != F_PIPE) < 1 &&
1661 (flags & MARK) == 0 && savedlen == f->f_prevlen &&
1662 strcmp(saved, f->f_prevline) == 0) {
1663 f->f_lasttime = *timestamp;
1664 f->f_prevcount++;
1666 f->f_prevcount, (long)(now - f->f_time),
1667 repeatinterval[f->f_repeatcount]);
1680 if (f->f_prevcount)
1682 f->f_repeatcount = 0;
1683 f->f_prevpri = pri;
1684 f->f_lasttime = *timestamp;
1685 static_assert(sizeof(f->f_prevline) == sizeof(saved),
1687 (void)strcpy(f->f_prevline, saved);
1688 f->f_prevlen = savedlen;
1701 if (f->f_type == F_FILE &&
1702 (f->f_flags & FFLAG_NEEDSYNC) != 0) {
1703 f->f_flags &= ~FFLAG_NEEDSYNC;
1704 (void)fsync(f->f_file);
1714 il->iovcnt = 0;
1715 il->totalsize = 0;
1724 if (il->iovcnt < nitems(il->iov)) {
1726 il->iov[il->iovcnt++] = (struct iovec){
1730 il->totalsize += size;
1741 while (il->totalsize > size) {
1742 diff = il->totalsize - size;
1743 last = &il->iov[il->iovcnt - 1];
1744 if (diff >= last->iov_len) {
1746 --il->iovcnt;
1747 il->totalsize -= last->iov_len;
1750 last->iov_len -= diff;
1751 il->totalsize -= diff;
1762 switch (f->f_type) {
1767 int domain, sockfd = f->f_addr_fds[0];
1774 printf(" %s", f->f_hname);
1811 for (size_t i = 0; i < f->f_num_addr_fds; ++i) {
1813 .msg_iov = il->iov,
1814 .msg_iovlen = il->iovcnt,
1817 lsent = sendmsg(f->f_addr_fds[i], &msg, 0);
1818 if (lsent == (ssize_t)il->totalsize && !send_to_all)
1821 dprintf("lsent/totalsize: %zd/%zu\n", lsent, il->totalsize);
1822 if (lsent != (ssize_t)il->totalsize) {
1844 f->f_type = F_UNUSED;
1852 dprintf(" %s\n", f->f_fname);
1854 if (writev(f->f_file, il->iov, il->iovcnt) < 0) {
1864 logerror(f->f_fname);
1866 } else if ((flags & SYNC_FILE) && (f->f_flags & FFLAG_SYNC)) {
1867 f->f_flags |= FFLAG_NEEDSYNC;
1873 dprintf(" %s\n", f->f_pname);
1875 if (f->f_procdesc == -1) {
1885 f->f_file = cap_p_open(cap_syslogd, i, f->f_pname,
1886 &f->f_procdesc);
1887 if (f->f_file < 0) {
1888 logerror(f->f_pname);
1891 EV_SET(&ev, f->f_procdesc, EVFILT_PROCDESC, EV_ADD,
1893 if (kevent(kq, &ev, 1, NULL, 0, NULL) == -1) {
1898 if (writev(f->f_file, il->iov, il->iovcnt) < 0) {
1899 logerror(f->f_pname);
1900 f->f_dq = deadq_enter(f->f_procdesc);
1912 dprintf(" %s%s\n", _PATH_DEV, f->f_fname);
1915 if ((msgret = cap_ttymsg(cap_syslogd, il->iov, il->iovcnt,
1916 f->f_fname, 10))) {
1917 f->f_type = F_UNUSED;
1926 cap_wallmsg(cap_syslogd, f, il->iov, il->iovcnt);
1944 if (f->f_type == F_WALL)
1947 snprintf(priority_number, sizeof(priority_number), "%d", f->f_prevpri);
1951 &f->f_lasttime.tm) == sizeof(timebuf) - 2) {
1959 usec = f->f_lasttime.usec;
1960 for (i = 25; i >= 20; --i) {
1966 iovlist_append(&il, "-");
1970 iovlist_append(&il, app_name == NULL ? "-" : app_name);
1972 iovlist_append(&il, procid == NULL ? "-" : procid);
1974 iovlist_append(&il, msgid == NULL ? "-" : msgid);
1976 iovlist_append(&il, structured_data == NULL ? "-" : structured_data);
1995 &f->f_lasttime.tm) == 0)
1999 switch (f->f_type) {
2004 f->f_prevpri);
2036 facility = f->f_prevpri & LOG_FACMASK;
2039 for (c = facilitynames; c->c_name; c++) {
2040 if (c->c_val == facility) {
2041 iovlist_append(&il, c->c_name);
2056 priority = LOG_PRI(f->f_prevpri);
2059 for (c = prioritynames; c->c_name; c++) {
2060 if (c->c_val == priority) {
2061 iovlist_append(&il, c->c_name);
2102 dprintf("Logging to %s", TypeNames[f->f_type]);
2103 f->f_time = now;
2104 f->f_prevcount = 0;
2105 if (f->f_type == F_UNUSED) {
2126 assert(f->f_prevcount > 0);
2128 f->f_prevcount);
2134 * WALLMSG -- Write a message to the world at large
2137 * world, or a list of approved users.
2155 if (ut->ut_type != USER_PROCESS)
2157 if (f->f_type == F_WALL) {
2158 if ((p = ttymsg(iov, iovlen, ut->ut_line,
2165 if (!f->f_uname[i][0])
2167 if (!strcmp(f->f_uname[i], ut->ut_user)) {
2168 if ((p = ttymsg_check(iov, iovlen, ut->ut_line,
2211 dprintf("cvthname(%d) len = %d\n", f->sa_family, f->sa_len);
2212 error = cap_getnameinfo(cap_net, f, f->sa_len, ip, sizeof(ip), NULL, 0,
2223 error = cap_getnameinfo(cap_net, f, f->sa_len, hname, sizeof(hname),
2230 if (hl > 0 && hname[hl-1] == '.')
2231 hname[--hl] = '\0';
2260 recursed--;
2272 if (f->f_prevcount)
2275 if (f->f_type == F_PIPE)
2285 if (sl->sl_sa != NULL && sl->sl_family == AF_LOCAL) {
2286 if (unlinkat(sl->sl_dirfd, sl->sl_name, 0) == -1) {
2287 dprintf("Failed to unlink %s: %s", sl->sl_name,
2303 if (dp->d_name[0] == '.')
2306 ext_len = sizeof(include_ext) -1;
2308 if (dp->d_namlen <= ext_len)
2311 p = &dp->d_name[dp->d_namlen - ext_len];
2335 include_len = sizeof(include_str) - 1;
2341 * check for end-of-section, comments, strip off trailing
2361 if (nents == -1) {
2368 ent[i]->d_name) >= (int)sizeof(file)) {
2370 "'%s/%s'\n", p, ent[i]->d_name);
2387 if (*p == '\0' || strchr("!+-:", *p) == NULL)
2390 if (*p == '+' || *p == '-') {
2400 for (i = 1; i < MAXHOSTNAMELEN - 1; i++) {
2401 if (!isalnum(*p) && *p != '.' && *p != '-'
2417 for (i = 0; i < LINE_MAX - 1; i++) {
2439 if (*(p - 1) == '\\') {
2440 strcpy(p - 1, p);
2441 p--;
2447 for (i = strlen(cline) - 1; i >= 0 && isspace(cline[i]); i--)
2511 if (f->f_prevcount)
2514 switch (f->f_type) {
2522 if (f->f_procdesc != -1) {
2528 EV_SET(&ev, f->f_procdesc, EVFILT_PROCDESC,
2530 if (kevent(kq, &ev, 1, NULL, 0, NULL) == -1) {
2542 if (f->f_prop_filter) {
2543 switch (f->f_prop_filter->cmp_type) {
2545 regfree(f->f_prop_filter->pflt_re);
2546 free(f->f_prop_filter->pflt_re);
2551 free(f->f_prop_filter->pflt_strval);
2554 free(f->f_prop_filter);
2581 if (cap_net_limit(limit) == -1)
2585 if (caph_enter_casper() == -1)
2591 * INIT -- Initialize syslogd from configuration table
2663 if (f->f_pmask[i] == INTERNAL_NOPRI)
2666 printf("%d ", f->f_pmask[i]);
2667 printf("%s: ", TypeNames[f->f_type]);
2668 switch (f->f_type) {
2670 printf("%s", f->f_fname);
2675 printf("%s%s", _PATH_DEV, f->f_fname);
2679 int domain, sockfd = f->f_addr_fds[0];
2713 printf("%s:%d", f->f_hname, port);
2715 printf("%s", f->f_hname);
2721 printf("%s", f->f_pname);
2725 for (i = 0; i < MAXUNAMES && *f->f_uname[i]; i++)
2726 printf("%s, ", f->f_uname[i]);
2731 if (*f->f_program != '\0')
2732 printf(" (%s)", f->f_program);
2765 * Compile property-based filter.
2785 * 'hostname, icase_ereregex, "^server-(dcA|podB)-rack1[0-9]{2}\\..*"'
2822 if (strncasecmp(argv[1], "icase_", (sizeof("icase_") - 1)) == 0) {
2824 argv[1] += sizeof("icase_") - 1;
2951 for (i = strlen(buf) - 1; i >= 0 && buf[i] == ' '; i--)
2973 f->f_pmask[i] = pri;
2974 f->f_pcmp[i] = pri_cmp;
2982 f->f_pmask[i >> 3] = pri;
2983 f->f_pcmp[i >> 3] = pri_cmp;
2999 return (-1);
3013 if (memcmp(&forw[j].raddr, rsa, rsa->sa_len) != 0 ||
3014 memcmp(&forw[j].laddr, lsa, lsa->sa_len) != 0)
3024 return (-1);
3037 s = socket(ai->ai_family, ai->ai_socktype, 0);
3044 if (bind(s, lai->ai_addr, lai->ai_addrlen) < 0)
3047 if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0) {
3051 s1 = maybe_dup_forw_socket(nvl, ai->ai_addr,
3052 lai->ai_addr);
3061 /* Make it a write-only socket. */
3075 f->f_num_addr_fds = 0;
3078 for (ai = res; ai != NULL; ai = ai->ai_next) {
3084 if (boundsock->sl_ai.ai_family == ai->ai_family)
3089 f->f_num_addr_fds += count;
3092 f->f_addr_fds = calloc(f->f_num_addr_fds, sizeof(*f->f_addr_fds));
3093 f->f_addrs = calloc(f->f_num_addr_fds, sizeof(*f->f_addrs));
3094 if (f->f_addr_fds == NULL || f->f_addrs == NULL)
3104 for (ai = res; ai != NULL; ai = ai->ai_next) {
3110 if (boundsock->sl_ai.ai_family ==
3111 ai->ai_family) {
3112 memcpy(&f->f_addrs[i].raddr, ai->ai_addr,
3113 ai->ai_addrlen);
3114 memcpy(&f->f_addrs[i].laddr,
3115 boundsock->sl_ai.ai_addr,
3116 boundsock->sl_ai.ai_addrlen);
3117 f->f_addr_fds[i++] = make_forw_socket(nvl, ai,
3118 &boundsock->sl_ai);
3123 memcpy(&f->f_addrs[i].raddr, ai->ai_addr,
3124 ai->ai_addrlen);
3125 f->f_addr_fds[i++] = make_forw_socket(nvl, ai, NULL);
3128 assert(i == f->f_num_addr_fds);
3140 if (*p == '-') {
3146 f->f_file = -1;
3156 i = sizeof(f->f_hname);
3157 tp = f->f_hname;
3168 while (*p && (*p != endkey) && (i-- > 0)) {
3185 error = getaddrinfo(f->f_hname, p ? p : "syslog", &hints, &res);
3192 f->f_type = F_FORW;
3196 if ((f->f_file = open(p, logflags, 0600)) < 0) {
3197 f->f_type = F_UNUSED;
3202 f->f_flags |= FFLAG_SYNC;
3203 if (isatty(f->f_file)) {
3205 f->f_type = F_CONSOLE;
3207 f->f_type = F_TTY;
3208 (void)strlcpy(f->f_fname, p + sizeof(_PATH_DEV) - 1,
3209 sizeof(f->f_fname));
3211 (void)strlcpy(f->f_fname, p, sizeof(f->f_fname));
3212 f->f_type = F_FILE;
3217 f->f_procdesc = -1;
3218 (void)strlcpy(f->f_pname, p + 1, sizeof(f->f_pname));
3219 f->f_type = F_PIPE;
3223 f->f_type = F_WALL;
3230 (void)strncpy(f->f_uname[i], p, MAXLOGNAME - 1);
3231 if ((q - p) >= MAXLOGNAME)
3232 f->f_uname[i][MAXLOGNAME - 1] = '\0';
3234 f->f_uname[i][q - p] = '\0';
3239 f->f_type = F_USERS;
3268 if (hl > 0 && f.f_host[hl-1] == '.')
3269 f.f_host[--hl] = '\0';
3317 for (p = buf; *name && p < &buf[sizeof(buf) - 1]; p++, name++) {
3324 for (c = codetab; c->c_name; c++)
3325 if (!strcmp(buf, c->c_name))
3326 return (c->c_val);
3328 return (-1);
3341 "-- MARK --", MARK);
3346 if (f->f_prevcount && now >= REPEATTIME(f)) {
3348 TypeNames[f->f_type], f->f_prevcount,
3349 repeatinterval[f->f_repeatcount]);
3357 switch (dq->dq_timeout) {
3360 (void)pdkill(dq->dq_procdesc, SIGKILL);
3364 (void)pdkill(dq->dq_procdesc, SIGTERM);
3367 dq->dq_timeout--;
3384 if (pipe(pipefd) == -1) {
3389 if (pid == -1) {
3397 if (events == -1)
3413 if (setsid() == -1) {
3449 int masklen = -1;
3472 ap->port = 0;
3474 ap->port = ntohs(se->s_port);
3476 ap->port = strtol(cp1, &cp2, 0);
3483 ap->port = ntohs(se->s_port);
3486 ap->port = 514;
3497 cp2 = s + strlen(s) - 1;
3514 ap->isnumeric = true;
3515 memcpy(&ap->a_addr, res->ai_addr, res->ai_addrlen);
3516 ap->a_mask = (struct sockaddr_storage){
3517 .ss_family = res->ai_family,
3518 .ss_len = res->ai_addrlen
3520 switch (res->ai_family) {
3523 maskp = &sstosin(&ap->a_mask)->sin_addr.s_addr;
3524 addrp = &sstosin(&ap->a_addr)->sin_addr.s_addr;
3537 *maskp = htonl(~((1 << (32 - masklen)) - 1));
3552 mask6p = (uint32_t *)&sstosin6(&ap->a_mask)->sin6_addr.s6_addr32[0];
3553 addr6p = (uint32_t *)&sstosin6(&ap->a_addr)->sin6_addr.s6_addr32[0];
3564 masklen -= 32;
3575 ap->isnumeric = false;
3576 ap->a_name = s;
3582 --s;
3590 if (ap->isnumeric) {
3592 getnameinfo(sstosa(&ap->a_addr),
3593 (sstosa(&ap->a_addr))->sa_len,
3596 getnameinfo(sstosa(&ap->a_mask),
3597 (sstosa(&ap->a_mask))->sa_len,
3601 printf("domainname = %s; ", ap->a_name);
3603 printf("port = %d\n", ap->port);
3649 if (cap_getnameinfo(cap_net, sa, sa->sa_len, ip, sizeof(ip), port,
3660 if (ap->port != 0 && ap->port != sport) {
3666 if (ap->isnumeric) {
3667 if (ap->a_addr.ss_family != sa->sa_family) {
3672 else if (ap->a_addr.ss_family == AF_INET) {
3674 a4p = satosin(&ap->a_addr);
3675 m4p = satosin(&ap->a_mask);
3676 if ((sin4->sin_addr.s_addr & m4p->sin_addr.s_addr)
3677 != a4p->sin_addr.s_addr) {
3684 else if (ap->a_addr.ss_family == AF_INET6) {
3686 a6p = satosin6(&ap->a_addr);
3687 m6p = satosin6(&ap->a_mask);
3688 if (a6p->sin6_scope_id != 0 &&
3689 sin6->sin6_scope_id != a6p->sin6_scope_id) {
3693 if (!IN6_ARE_MASKED_ADDR_EQUAL(&sin6->sin6_addr,
3694 &a6p->sin6_addr, &m6p->sin6_addr)) {
3703 if (fnmatch(ap->a_name, name, FNM_NOESCAPE) ==
3730 char *argv[4]; /* sh -c cmd NULL */
3732 if (pipe(pfd) == -1)
3733 return (-1);
3736 case -1:
3737 return (-1);
3742 argv[1] = strdup("-c");
3751 if (sigaction(sigcatch[i], &act, NULL) == -1)
3773 if (fcntl(pfd[1], F_SETFL, O_NONBLOCK) == -1) {
3775 dprintf("Warning: cannot change pipe to PID %d to non-blocking"
3787 if (pd == -1)
3796 dq->dq_procdesc = pd;
3797 dq->dq_timeout = DQ_TIMO_INIT;
3827 if (pdgetpid(pd, &pid) == -1)
3831 pid, f->f_pname, reason, code);
3842 if (ai->ai_family != AF_LOCAL && SecureMode > 1) {
3846 if (family != AF_UNSPEC && ai->ai_family != AF_LOCAL &&
3847 ai->ai_family != family)
3850 s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
3856 if (ai->ai_family == AF_INET6) {
3873 * Bind INET and UNIX-domain sockets.
3875 * A UNIX-domain socket is always bound to a pathname
3876 * regardless of -N flag.
3885 if (ai->ai_family == AF_LOCAL)
3887 if (ai->ai_family == AF_LOCAL || NoBind == 0 || name != NULL) {
3891 if (ai->ai_family == AF_LOCAL && fchmod(s, mode) < 0) {
3910 error = bind(s, ai->ai_addr, ai->ai_addrlen);
3917 if (ai->ai_family == AF_LOCAL || SecureMode == 0)
3923 if (SecureMode && (ai->ai_family == AF_INET ||
3924 ai->ai_family == AF_INET6)) {
3937 /* Copy *ai->ai_addr to the tail of struct socklist if any. */
3938 sl = calloc(1, sizeof(*sl) + ai->ai_addrlen);
3941 sl->sl_socket = s;
3942 if (ai->ai_family == AF_LOCAL) {
3946 sl->sl_name = strdup(basename(name2));
3947 sl->sl_dirfd = open(dirname(name2), O_DIRECTORY);
3948 if (sl->sl_name == NULL || sl->sl_dirfd == -1)
3952 sl->sl_recv = sl_recv;
3953 (void)memcpy(&sl->sl_ai, ai, sizeof(*ai));
3954 if (ai->ai_addrlen > 0) {
3955 (void)memcpy((sl + 1), ai->ai_addr, ai->ai_addrlen);
3956 sl->sl_sa = (struct sockaddr *)(sl + 1);
3958 sl->sl_sa = NULL;