diff options
author | bluhm <bluhm@openbsd.org> | 2017-03-16 17:55:22 +0000 |
---|---|---|
committer | bluhm <bluhm@openbsd.org> | 2017-03-16 17:55:22 +0000 |
commit | d7f86a498b55cecbe3ba49f35b44a90225b634b7 (patch) | |
tree | 1220aaf19288562cd2c28c76997ed1eb22fc5381 /usr.sbin/syslogd | |
parent | Fix handling of the SVM instructions such that they accept a register as (diff) | |
download | wireguard-openbsd-d7f86a498b55cecbe3ba49f35b44a90225b634b7.tar.xz wireguard-openbsd-d7f86a498b55cecbe3ba49f35b44a90225b634b7.zip |
Convert the global variable fd_tls to a local one. Use separate
callbacks for TCP and TLS accept(2) instead of looking at the value
of the listen file descriptor.
OK millert@
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index b6392cab166..5e4d1afbd4f 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.228 2017/03/14 15:35:48 deraadt Exp $ */ +/* $OpenBSD: syslogd.c,v 1.229 2017/03/16 17:55:22 bluhm Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -272,7 +272,7 @@ size_t ctl_reply_offset = 0; /* Number of bytes of reply written so far */ char *linebuf; int linesize; -int fd_ctlconn, fd_udp, fd_udp6, fd_tls; +int fd_ctlconn, fd_udp, fd_udp6; struct event *ev_ctlaccept, *ev_ctlread, *ev_ctlwrite; struct peer { @@ -291,6 +291,8 @@ void unix_readcb(int, short, void *); int reserve_accept4(int, int, struct event *, void (*)(int, short, void *), struct sockaddr *, socklen_t *, int); void tcp_acceptcb(int, short, void *); +void tls_acceptcb(int, short, void *); +void acceptcb(int, short, void *, int); int octet_counting(struct evbuffer *, char **, int); int non_transparent_framing(struct evbuffer *, char **); void tcp_readcb(struct bufferevent *, void *); @@ -354,7 +356,7 @@ main(int argc, char *argv[]) int ch, i; int lockpipe[2] = { -1, -1}, pair[2], nullfd, fd; int fd_ctlsock, fd_klog, fd_sendsys, *fd_bind, *fd_listen; - int *fd_unix, nbind, nlisten; + int fd_tls, *fd_unix, nbind, nlisten; char **bind_host, **bind_port, **listen_host, **listen_port; char *tls_hostport, *tls_host, *tls_port; @@ -772,7 +774,7 @@ main(int argc, char *argv[]) for (i = 0; i < nlisten; i++) event_set(&ev_listen[i], fd_listen[i], EV_READ|EV_PERSIST, tcp_acceptcb, &ev_listen[i]); - event_set(ev_tls, fd_tls, EV_READ|EV_PERSIST, tcp_acceptcb, ev_tls); + event_set(ev_tls, fd_tls, EV_READ|EV_PERSIST, tls_acceptcb, ev_tls); for (i = 0; i < nunix; i++) event_set(&ev_unix[i], fd_unix[i], EV_READ|EV_PERSIST, unix_readcb, &ev_unix[i]); @@ -1088,6 +1090,18 @@ reserve_accept4(int lfd, int event, struct event *ev, void tcp_acceptcb(int lfd, short event, void *arg) { + acceptcb(lfd, event, arg, 0); +} + +void +tls_acceptcb(int lfd, short event, void *arg) +{ + acceptcb(lfd, event, arg, 1); +} + +void +acceptcb(int lfd, short event, void *arg, int usetls) +{ struct event *ev = arg; struct peer *p; struct sockaddr_storage ss; @@ -1132,7 +1146,7 @@ tcp_acceptcb(int lfd, short event, void *arg) return; } p->p_ctx = NULL; - if (lfd == fd_tls) { + if (usetls) { if (tls_accept_socket(server_ctx, &p->p_ctx, fd) < 0) { snprintf(ebuf, sizeof(ebuf), "tls_accept_socket \"%s\"", peername); |