summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ldapd/conn.c4
-rw-r--r--usr.sbin/ldapd/control.c7
-rw-r--r--usr.sbin/ldapd/ldapd.c20
-rw-r--r--usr.sbin/ldapd/ldapd.h3
-rw-r--r--usr.sbin/ldapd/ldape.c7
-rw-r--r--usr.sbin/ldapd/util.c4
6 files changed, 12 insertions, 33 deletions
diff --git a/usr.sbin/ldapd/conn.c b/usr.sbin/ldapd/conn.c
index 980d0164657..0a4a02ad323 100644
--- a/usr.sbin/ldapd/conn.c
+++ b/usr.sbin/ldapd/conn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conn.c,v 1.11 2013/11/02 13:31:51 deraadt Exp $ */
+/* $OpenBSD: conn.c,v 1.12 2015/11/02 06:32:51 jmatthew Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
@@ -291,8 +291,6 @@ conn_accept(int fd, short event, void *data)
log_debug("accepted connection from %s on fd %d", host, afd);
}
- fd_nonblock(afd);
-
if ((conn = calloc(1, sizeof(*conn))) == NULL) {
log_warn("malloc");
goto giveup;
diff --git a/usr.sbin/ldapd/control.c b/usr.sbin/ldapd/control.c
index e72139441d5..61a721a81f1 100644
--- a/usr.sbin/ldapd/control.c
+++ b/usr.sbin/ldapd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.10 2015/01/16 16:04:38 deraadt Exp $ */
+/* $OpenBSD: control.c,v 1.11 2015/11/02 06:32:51 jmatthew Exp $ */
/*
* Copyright (c) 2010 Martin Hedenfalk <martin@bzero.se>
@@ -55,7 +55,7 @@ control_init(struct control_sock *cs)
if (cs->cs_name == NULL)
return;
- if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
+ if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)) == -1)
fatal("control_init: socket");
bzero(&sun, sizeof(sun));
@@ -89,7 +89,6 @@ control_init(struct control_sock *cs)
fatal("control_init: chmod");
}
- fd_nonblock(fd);
cs->cs_fd = fd;
}
@@ -149,8 +148,6 @@ control_accept(int listenfd, short event, void *arg)
return;
}
- fd_nonblock(connfd);
-
if ((c = calloc(1, sizeof(*c))) == NULL) {
log_warn("control_accept");
close(connfd);
diff --git a/usr.sbin/ldapd/ldapd.c b/usr.sbin/ldapd/ldapd.c
index 2df5cf5a2b7..0805a9519a0 100644
--- a/usr.sbin/ldapd/ldapd.c
+++ b/usr.sbin/ldapd/ldapd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldapd.c,v 1.13 2015/11/02 04:48:43 jmatthew Exp $ */
+/* $OpenBSD: ldapd.c,v 1.14 2015/11/02 06:32:51 jmatthew Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
@@ -99,18 +99,6 @@ ldapd_sigchld_handler(int sig, short why, void *data)
}
}
-/* set socket non-blocking */
-void
-fd_nonblock(int fd)
-{
- int flags = fcntl(fd, F_GETFL, 0);
- int rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
- if (rc == -1) {
- log_warn("failed to set fd %d non-blocking", fd);
- }
-}
-
-
int
main(int argc, char *argv[])
{
@@ -194,12 +182,10 @@ main(int argc, char *argv[])
log_init(debug);
log_info("startup");
- if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_parent2ldap) != 0)
+ if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, PF_UNSPEC,
+ pipe_parent2ldap) != 0)
fatal("socketpair");
- fd_nonblock(pipe_parent2ldap[0]);
- fd_nonblock(pipe_parent2ldap[1]);
-
ldape_pid = ldape(pw, csockpath, pipe_parent2ldap);
setproctitle("auth");
diff --git a/usr.sbin/ldapd/ldapd.h b/usr.sbin/ldapd/ldapd.h
index 144db1b7937..d6b9b8a981d 100644
--- a/usr.sbin/ldapd/ldapd.h
+++ b/usr.sbin/ldapd/ldapd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldapd.h,v 1.24 2015/01/16 16:04:38 deraadt Exp $ */
+/* $OpenBSD: ldapd.h,v 1.25 2015/11/02 06:32:51 jmatthew Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
@@ -332,7 +332,6 @@ struct control_sock {
extern struct ldapd_stats stats;
extern struct ldapd_config *conf;
-void fd_nonblock(int fd);
void imsg_event_add(struct imsgev *iev);
int imsg_compose_event(struct imsgev *iev, u_int16_t type,
u_int32_t peerid, pid_t pid, int fd, void *data,
diff --git a/usr.sbin/ldapd/ldape.c b/usr.sbin/ldapd/ldape.c
index 9d833c66b74..4fcdbea47b7 100644
--- a/usr.sbin/ldapd/ldape.c
+++ b/usr.sbin/ldapd/ldape.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldape.c,v 1.21 2015/11/02 04:48:43 jmatthew Exp $ */
+/* $OpenBSD: ldape.c,v 1.22 2015/11/02 06:32:51 jmatthew Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
@@ -383,7 +383,8 @@ ldape(struct passwd *pw, char *csockpath, int pipe_parent2ldap[2])
/* Initialize LDAP listeners.
*/
TAILQ_FOREACH(l, &conf->listeners, entry) {
- l->fd = socket(l->ss.ss_family, SOCK_STREAM, 0);
+ l->fd = socket(l->ss.ss_family, SOCK_STREAM | SOCK_NONBLOCK,
+ 0);
if (l->fd < 0)
fatal("ldape: socket");
@@ -419,8 +420,6 @@ ldape(struct passwd *pw, char *csockpath, int pipe_parent2ldap[2])
if (listen(l->fd, 20) != 0)
fatal("ldape: listen");
- fd_nonblock(l->fd);
-
event_set(&l->ev, l->fd, EV_READ, conn_accept, l);
event_add(&l->ev, NULL);
evtimer_set(&l->evt, conn_accept, l);
diff --git a/usr.sbin/ldapd/util.c b/usr.sbin/ldapd/util.c
index eb30dc1edf7..8a7e283c2de 100644
--- a/usr.sbin/ldapd/util.c
+++ b/usr.sbin/ldapd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.5 2013/11/23 18:02:44 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.6 2015/11/02 06:32:51 jmatthew Exp $ */
/*
* Copyright (c) 2009 Martin Hedenfalk <martin@bzero.se>
@@ -210,5 +210,5 @@ accept_reserve(int sockfd, struct sockaddr *addr, socklen_t *addrlen,
return -1;
}
- return accept(sockfd, addr, addrlen);
+ return accept4(sockfd, addr, addrlen, SOCK_NONBLOCK);
}