diff options
author | Jonathan Matthew <jmatthew@cvs.openbsd.org> | 2012-06-16 00:08:33 +0000 |
---|---|---|
committer | Jonathan Matthew <jmatthew@cvs.openbsd.org> | 2012-06-16 00:08:33 +0000 |
commit | 13e1995d2d480fdedfbd4d24b123246496d85e86 (patch) | |
tree | 5871128642d3205945aded9f753bc11aee4b4ec1 /usr.sbin/ldapd/ldapd.c | |
parent | e9e58745c35db60fc74c0f849458bcad5e111207 (diff) |
Protect against fd exhaustion when reopening database files. Only accept
client or control connections when there are at least 8 fds available,
and close a connection before calling imsg_read if it would be unable to
accept an fd from the parent process.
ok gilles@
Diffstat (limited to 'usr.sbin/ldapd/ldapd.c')
-rw-r--r-- | usr.sbin/ldapd/ldapd.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.sbin/ldapd/ldapd.c b/usr.sbin/ldapd/ldapd.c index 78b1b4f9ad1..e6459151793 100644 --- a/usr.sbin/ldapd/ldapd.c +++ b/usr.sbin/ldapd/ldapd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapd.c,v 1.8 2010/11/10 08:00:54 martinh Exp $ */ +/* $OpenBSD: ldapd.c,v 1.9 2012/06/16 00:08:32 jmatthew Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -41,6 +41,7 @@ void usage(void); void ldapd_sig_handler(int fd, short why, void *data); void ldapd_sigchld_handler(int sig, short why, void *data); static void ldapd_imsgev(struct imsgev *iev, int code, struct imsg *imsg); +static void ldapd_needfd(struct imsgev *iev); static void ldapd_auth_request(struct imsgev *iev, struct imsg *imsg); static void ldapd_open_request(struct imsgev *iev, struct imsg *imsg); static void ldapd_log_verbose(struct imsg *imsg); @@ -218,7 +219,8 @@ main(int argc, char *argv[]) if ((iev_ldape = calloc(1, sizeof(struct imsgev))) == NULL) fatal("calloc"); - imsgev_init(iev_ldape, pipe_parent2ldap[0], NULL, ldapd_imsgev); + imsgev_init(iev_ldape, pipe_parent2ldap[0], NULL, ldapd_imsgev, + ldapd_needfd); event_dispatch(); log_debug("ldapd: exiting"); @@ -260,6 +262,12 @@ ldapd_imsgev(struct imsgev *iev, int code, struct imsg *imsg) } } +static void +ldapd_needfd(struct imsgev *iev) +{ + fatal("should never need an fd for parent messages"); +} + static int ldapd_auth_classful(char *name, char *password) { |