From ac5b20e9ffa8ab9ccc24fa49b24579abe5ddbc41 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Wed, 4 Sep 2013 12:10:41 +0100 Subject: [PATCH] as I currently have no idea whats the problem I first fixed all warnings...included the ldap warnings that where caused by the use of deprecated ldap_simple_bind_s and ldap_unbind_s. --- src/auth/ldap.c | 17 ++++++++++++++-- src/hash/each.c | 2 +- src/server/read.c | 48 +++------------------------------------------ src/server/run.c | 2 ++ src/server/write.c | 2 -- src/socket/socket.c | 1 - 6 files changed, 21 insertions(+), 51 deletions(-) diff --git a/src/auth/ldap.c b/src/auth/ldap.c index 38e95c5..c5975d6 100644 --- a/src/auth/ldap.c +++ b/src/auth/ldap.c @@ -76,6 +76,9 @@ authLdapAuthenticate(void * _this, Credential cred) char * who_ptr = who; int ldap_err; + struct berval ldap_cred; + struct berval * ldap_servcred; + if (CRED_PASSWORD != cred->type) { return FALSE; } @@ -91,9 +94,19 @@ authLdapAuthenticate(void * _this, Credential cred) memcpy(who_ptr, this->base_dn, this->nbase_dn); who_ptr[this->nbase_dn] = 0; - ldap_err = ldap_simple_bind_s(this->ldap, who, CRED_PWD(cred).pass); + ldap_cred.bv_val = CRED_PWD(cred).pass; + ldap_cred.bv_len = CRED_PWD(cred).npass; + ldap_err = ldap_sasl_bind_s( + this->ldap, + who, + LDAP_SASL_SIMPLE, + &ldap_cred, + NULL, + NULL, + &ldap_servcred); + if (0 == ldap_err) { - ldap_unbind_s(this->ldap); + ldap_unbind_ext_s(this->ldap, NULL, NULL); //! \todo here we need to get and return the user id return TRUE; } diff --git a/src/hash/each.c b/src/hash/each.c index 4df28d1..e953af8 100644 --- a/src/hash/each.c +++ b/src/hash/each.c @@ -24,7 +24,7 @@ #include "hash.h" -static void (*cb)(void*); +static void (*cb)(const void*); static inline diff --git a/src/server/read.c b/src/server/read.c index c422202..f3605f5 100644 --- a/src/server/read.c +++ b/src/server/read.c @@ -26,13 +26,11 @@ #include "logger.h" #include "stream.h" -void serverCloseConn(Server, unsigned int); ssize_t serverRead(Server this, unsigned int i) { int fd = (this->fds)[i].fd; - ssize_t size; if (NULL == (this->conns)[fd].worker) { loggerLog( @@ -42,49 +40,9 @@ serverRead(Server this, unsigned int i) return -1; } - switch ((size = streamReaderRead( - (this->conns)[fd].worker, - (this->conns)[fd].stream))) - { - case -1: - /* - * read failure - */ - if (errno == EAGAIN || errno == EWOULDBLOCK) { - /* on EGAIN just try again later. */ - break; - } - // DROP-THROUGH - - case -2: - /** - * normal close: this must be mapped to -2 within the - * underlying read call. - * - * \todo make sure all pending writes will be done before - * close. - */ - - /* - * close connection if not EAGAIN, this would also - * remove the filedescriptor from the poll list. - * Else just return indicate - */ - loggerLog(this->logger, LOGGER_INFO, - "connection[%d] closed...%s", - fd, - inet_ntoa((((this->conns)[fd].sock)->addr).sin_addr)); - serverCloseConn(this, i); - - //case 0: - // break; - - default: - // (this->fds)[i].events |= POLLOUT; - break; - } - - return size; + return streamReaderRead( + (this->conns)[fd].worker, + (this->conns)[fd].stream); } // vim: set ts=4 sw=4: diff --git a/src/server/run.c b/src/server/run.c index 43f2d0a..afdb648 100644 --- a/src/server/run.c +++ b/src/server/run.c @@ -29,6 +29,8 @@ int serverPoll(Server); int serverHandleAccept(Server, unsigned int); ssize_t serverRead(Server, unsigned int); ssize_t serverWrite(Server, unsigned int); +void serverCloseConn(Server, unsigned int); + void serverRun(Server this) diff --git a/src/server/write.c b/src/server/write.c index 11896c8..d28ee1a 100644 --- a/src/server/write.c +++ b/src/server/write.c @@ -26,8 +26,6 @@ #include "logger.h" #include "stream.h" -void serverCloseConn(Server, unsigned int); - ssize_t serverWrite(Server this, unsigned int i) { diff --git a/src/socket/socket.c b/src/socket/socket.c index 1429c6e..ead4f00 100644 --- a/src/socket/socket.c +++ b/src/socket/socket.c @@ -35,7 +35,6 @@ socketCtor(void * _this, va_list * params) Sock this = _this; int reUse = 1; //! \todo make this configurable int port; - int nonblock; this->log = va_arg(* params, Logger); port = va_arg(* params, int);