diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2018-02-08 18:02:07 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2018-02-08 18:02:07 +0000 |
commit | 8144ed9b5932e5e620c0a19811063dc9bb512853 (patch) | |
tree | 6ea163252c430fd273231b2660f557b67b01df6f /usr.sbin/ldapd | |
parent | 0740f610fd5619e60ae9e935b5410c820d897b3f (diff) |
Kill ber.c support for direct fd read/writes
This mechanism is already unused and annotated with lots of XXX's, no
need to keep it around. ok claudio@
Diffstat (limited to 'usr.sbin/ldapd')
-rw-r--r-- | usr.sbin/ldapd/ber.c | 40 | ||||
-rw-r--r-- | usr.sbin/ldapd/ber.h | 3 | ||||
-rw-r--r-- | usr.sbin/ldapd/conn.c | 3 | ||||
-rw-r--r-- | usr.sbin/ldapd/util.c | 4 |
4 files changed, 10 insertions, 40 deletions
diff --git a/usr.sbin/ldapd/ber.c b/usr.sbin/ldapd/ber.c index 454e891d990..02d1b7d2020 100644 --- a/usr.sbin/ldapd/ber.c +++ b/usr.sbin/ldapd/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.12 2017/02/11 20:40:03 guenther Exp $ */ +/* $OpenBSD: ber.c,v 1.13 2018/02/08 18:02:06 jca Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -783,10 +783,6 @@ ber_write_elements(struct ber *ber, struct ber_element *root) if (ber_dump_element(ber, root) == -1) return -1; - /* XXX this should be moved to a different function */ - if (ber->fd != -1) - return write(ber->fd, ber->br_wbuf, len); - return (len); } @@ -1095,9 +1091,9 @@ ber_read_element(struct ber *ber, struct ber_element *elm) DPRINTF("ber read element size %zd\n", len); totlen += r + len; - /* If using an external buffer and the total size of the element - * is larger then the external buffer don't bother to continue. */ - if (ber->fd == -1 && len > ber->br_rend - ber->br_rptr) { + /* If the total size of the element is larger than the buffer + * don't bother to continue. */ + if (len > ber->br_rend - ber->br_rptr) { errno = ECANCELED; return -1; } @@ -1243,17 +1239,7 @@ ber_free(struct ber *b) static ssize_t ber_getc(struct ber *b, u_char *c) { - ssize_t r; - /* - * XXX calling read here is wrong in many ways. The most obvious one - * being that we will block till data arrives. - * But for now it is _good enough_ *gulp* - */ - if (b->fd == -1) - r = ber_readbuf(b, c, 1); - else - r = read(b->fd, c, 1); - return r; + return ber_readbuf(b, c, 1); } static ssize_t @@ -1262,22 +1248,10 @@ ber_read(struct ber *ber, void *buf, size_t len) u_char *b = buf; ssize_t r, remain = len; - /* - * XXX calling read here is wrong in many ways. The most obvious one - * being that we will block till data arrives. - * But for now it is _good enough_ *gulp* - */ - while (remain > 0) { - if (ber->fd == -1) - r = ber_readbuf(ber, b, remain); - else - r = read(ber->fd, b, remain); - if (r == -1) { - if (errno == EINTR || errno == EAGAIN) - continue; + r = ber_readbuf(ber, b, remain); + if (r == -1) return -1; - } if (r == 0) return (b - (u_char *)buf); b += r; diff --git a/usr.sbin/ldapd/ber.h b/usr.sbin/ldapd/ber.h index e2400762ad0..e831435312a 100644 --- a/usr.sbin/ldapd/ber.h +++ b/usr.sbin/ldapd/ber.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.h,v 1.2 2017/02/11 20:40:03 guenther Exp $ */ +/* $OpenBSD: ber.h,v 1.3 2018/02/08 18:02:06 jca Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -35,7 +35,6 @@ struct ber_element { }; struct ber { - int fd; u_char *br_wbuf; u_char *br_wptr; u_char *br_wend; diff --git a/usr.sbin/ldapd/conn.c b/usr.sbin/ldapd/conn.c index 4e8306c58fb..7fcd6e043e8 100644 --- a/usr.sbin/ldapd/conn.c +++ b/usr.sbin/ldapd/conn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conn.c,v 1.14 2017/01/20 11:55:08 benno Exp $ */ +/* $OpenBSD: conn.c,v 1.15 2018/02/08 18:02:06 jca Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -296,7 +296,6 @@ conn_accept(int fd, short event, void *data) log_warn("malloc"); goto giveup; } - conn->ber.fd = -1; ber_set_application(&conn->ber, ldap_application); conn->fd = afd; conn->listener = l; diff --git a/usr.sbin/ldapd/util.c b/usr.sbin/ldapd/util.c index 7cf38a18b90..c1bb0829c9b 100644 --- a/usr.sbin/ldapd/util.c +++ b/usr.sbin/ldapd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.8 2017/01/20 11:55:08 benno Exp $ */ +/* $OpenBSD: util.c,v 1.9 2018/02/08 18:02:06 jca Exp $ */ /* * Copyright (c) 2009 Martin Hedenfalk <martin@bzero.se> @@ -113,7 +113,6 @@ ber2db(struct ber_element *root, struct btval *val, int compression_level) memset(val, 0, sizeof(*val)); memset(&ber, 0, sizeof(ber)); - ber.fd = -1; ber_write_elements(&ber, root); if ((len = ber_get_writebuf(&ber, &buf)) == -1) @@ -168,7 +167,6 @@ db2ber(struct btval *val, int compression_level) assert(val != NULL); memset(&ber, 0, sizeof(ber)); - ber.fd = -1; if (compression_level > 0) { if (val->size < sizeof(uint32_t)) |