summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'daemon')
-rw-r--r--daemon/httpauthd.c5
-rw-r--r--daemon/ldap.c44
-rw-r--r--daemon/ntlm.c40
-rw-r--r--daemon/simple.c30
4 files changed, 61 insertions, 58 deletions
diff --git a/daemon/httpauthd.c b/daemon/httpauthd.c
index e5b8dcb..c238a1a 100644
--- a/daemon/httpauthd.c
+++ b/daemon/httpauthd.c
@@ -340,9 +340,12 @@ int main(int argc, char* argv[])
continue;
}
+ memset(&sany, 0, sizeof(sany));
+ SANY_LEN(sany) = sizeof(sany);
+
/* Get the peer name */
if(getpeername(fd, &SANY_ADDR(sany), &SANY_LEN(sany)) == -1 ||
- sock_any_ntop(&sany, peername, MAXPATHLEN) == -1)
+ sock_any_ntop(&sany, peername, MAXPATHLEN, SANY_OPT_NOPORT) == -1)
ha_messagex(LOG_WARNING, "%d: couldn't get peer address", fd);
else
ha_messagex(LOG_INFO, "%d: accepted connection from: %s", fd, peername);
diff --git a/daemon/ldap.c b/daemon/ldap.c
index 3befc4b..4398dc0 100644
--- a/daemon/ldap.c
+++ b/daemon/ldap.c
@@ -74,7 +74,7 @@ typedef struct ldap_context
int ldap_timeout; /* Maximum amount of time to dedicate to an ldap query */
/* Context ----------------------------------------------------------- */
- hash_t* cache; /* Some cached records or basic */
+ hsh_t* cache; /* Some cached records or basic */
LDAP** pool; /* Pool of available connections */
int pool_mark; /* Amount of connections allocated */
@@ -145,11 +145,11 @@ static digest_record_t* get_cached_digest(ldap_context_t* ctx, ha_context_t* c,
ha_lock(NULL);
- rec = (digest_record_t*)hash_get(ctx->cache, nonce);
+ rec = (digest_record_t*)hsh_get(ctx->cache, nonce);
/* Just in case it's a basic :) */
if(rec && rec != BASIC_ESTABLISHED)
- hash_rem(ctx->cache, nonce);
+ hsh_rem(ctx->cache, nonce);
ha_unlock(NULL);
@@ -165,7 +165,7 @@ static int have_cached_basic(ldap_context_t* ctx, unsigned char* key)
ha_lock(NULL);
- ret = (hash_get(ctx->cache, key) == BASIC_ESTABLISHED);
+ ret = (hsh_get(ctx->cache, key) == BASIC_ESTABLISHED);
ha_unlock(NULL);
@@ -187,10 +187,10 @@ static int save_cached_digest(ldap_context_t* ctx, ha_context_t* c,
ha_lock(NULL);
- while(hash_count(ctx->cache) >= c->cache_max)
- hash_bump(ctx->cache);
+ while(hsh_count(ctx->cache) >= c->cache_max)
+ hsh_bump(ctx->cache);
- r = hash_set(ctx->cache, rec->nonce, rec);
+ r = hsh_set(ctx->cache, rec->nonce, rec);
ha_unlock(NULL);
@@ -215,10 +215,10 @@ static int add_cached_basic(ldap_context_t* ctx, ha_context_t* c,
ha_lock(NULL);
- while(hash_count(ctx->cache) >= c->cache_max)
- hash_bump(ctx->cache);
+ while(hsh_count(ctx->cache) >= c->cache_max)
+ hsh_bump(ctx->cache);
- r = hash_set(ctx->cache, key, BASIC_ESTABLISHED);
+ r = hsh_set(ctx->cache, key, BASIC_ESTABLISHED);
ha_unlock(NULL);
@@ -633,6 +633,13 @@ static LDAP* get_ldap_connection(ldap_context_t* ctx)
return ld;
}
+static void discard_ldap_connection(ldap_context_t* ctx, LDAP* ld)
+{
+ ldap_unbind_s(ld);
+ ctx->pool_mark--;
+ ha_messagex(LOG_DEBUG, "ldap: discarding connection (total %d)", ctx->pool_mark);
+}
+
static void save_ldap_connection(ldap_context_t* ctx, LDAP* ld)
{
int i, e;
@@ -670,13 +677,6 @@ static void save_ldap_connection(ldap_context_t* ctx, LDAP* ld)
};
}
-static discard_ldap_connection(ldap_context_t* ctx, LDAP* ld)
-{
- ldap_unbind_s(ld);
- ctx->pool_mark--;
- ha_messagex(LOG_DEBUG, "ldap: discarding connection (total %d)", ctx->pool_mark);
-}
-
static int retrieve_user_entry(ldap_context_t* ctx, const ha_request_t* req, LDAP* ld,
const char* user, const char** dn,
LDAPMessage** entry, LDAPMessage** result)
@@ -1323,7 +1323,7 @@ int ldap_inithand(ha_context_t* context)
else
{
ldap_context_t* ctx = (ldap_context_t*)(context->ctx_data);
- hash_table_calls_t htc;
+ hsh_table_calls_t htc;
ASSERT(ctx);
@@ -1351,7 +1351,7 @@ int ldap_inithand(ha_context_t* context)
}
/* The cache for digest records and basic */
- if(!(ctx->cache = hash_create(MD5_LEN)))
+ if(!(ctx->cache = hsh_create(MD5_LEN)))
{
ha_messagex(LOG_CRIT, "out of memory");
return HA_CRITERROR;
@@ -1359,7 +1359,7 @@ int ldap_inithand(ha_context_t* context)
htc.f_freeval = free_hash_object;
htc.arg = NULL;
- hash_set_table_calls(ctx->cache, &htc);
+ hsh_set_table_calls(ctx->cache, &htc);
ASSERT(!ctx->pool);
ASSERT(ctx->ldap_max > 0);
@@ -1398,7 +1398,7 @@ void ldap_destroy(ha_context_t* context)
ASSERT(ctx);
if(ctx->cache)
- hash_free(ctx->cache);
+ hsh_free(ctx->cache);
if(ctx->pool)
{
@@ -1430,7 +1430,7 @@ int ldap_process(const ha_request_t* req, ha_response_t* resp)
ha_lock(NULL);
/* Purge out stale connection stuff. */
- r = hash_purge(ctx->cache, t - req->context->cache_timeout);
+ r = hsh_purge(ctx->cache, t - req->context->cache_timeout);
ha_unlock(NULL);
diff --git a/daemon/ntlm.c b/daemon/ntlm.c
index 37de9e8..031e19d 100644
--- a/daemon/ntlm.c
+++ b/daemon/ntlm.c
@@ -47,8 +47,8 @@ typedef struct ntlm_context
int pending_timeout; /* Timeout for authentication (in seconds) */
/* Context ----------------------------------------------------------- */
- hash_t* pending; /* Pending connections */
- hash_t* established; /* Established connections */
+ hsh_t* pending; /* Pending connections */
+ hsh_t* established; /* Established connections */
}
ntlm_context_t;
@@ -135,7 +135,7 @@ static ntlm_connection_t* getpending(ntlm_context_t* ctx, const void* key)
ha_lock(NULL);
- ret = (ntlm_connection_t*)hash_rem(ctx->pending, key);
+ ret = (ntlm_connection_t*)hsh_rem(ctx->pending, key);
ha_unlock(NULL);
@@ -149,11 +149,11 @@ static int putpending(ntlm_context_t* ctx, const void* key, ntlm_connection_t* c
ASSERT(ctx && key && conn);
ASSERT(conn->handle);
- if(!hash_get(ctx->pending, key))
+ if(!hsh_get(ctx->pending, key))
{
ha_lock(NULL);
- if(!hash_set(ctx->pending, key, (void*)conn))
+ if(!hsh_set(ctx->pending, key, (void*)conn))
{
free_hash_object(NULL, conn);
ha_messagex(LOG_ERR, "out of memory");
@@ -196,7 +196,7 @@ int ntlm_auth_basic(ntlm_context_t* ctx, char* key, const char* header,
/* Check and see if this connection is in the cache */
ha_lock(NULL);
- if(hash_get(ctx->established, basic.key) == NTLM_ESTABLISHED)
+ if(hsh_get(ctx->established, basic.key) == NTLM_ESTABLISHED)
found = 1;
ha_unlock(NULL);
@@ -259,7 +259,7 @@ int ntlm_auth_basic(ntlm_context_t* ctx, char* key, const char* header,
ha_lock(NULL);
/* We put this connection into the successful connections */
- r = hash_set(ctx->established, basic.key, NTLM_ESTABLISHED);
+ r = hsh_set(ctx->established, basic.key, NTLM_ESTABLISHED);
ha_unlock(NULL);
@@ -371,8 +371,8 @@ int ntlm_auth_ntlm(ntlm_context_t* ctx, void* key, const char* header,
{
ha_lock(NULL);
- if(hash_count(ctx->pending) >= ctx->pending_max)
- hash_bump(ctx->pending);
+ if(hsh_count(ctx->pending) >= ctx->pending_max)
+ hsh_bump(ctx->pending);
ha_unlock(NULL);
}
@@ -498,7 +498,7 @@ int ntlm_auth_ntlm(ntlm_context_t* ctx, void* key, const char* header,
ha_lock(NULL);
/* We put this connection into the successful connections */
- r = hash_set(ctx->established, key, NTLM_ESTABLISHED);
+ r = hsh_set(ctx->established, key, NTLM_ESTABLISHED);
ha_unlock(NULL);
@@ -581,7 +581,7 @@ int ntlm_init(ha_context_t* context)
if(context)
{
ntlm_context_t* ctx = (ntlm_context_t*)(context->ctx_data);
- hash_table_calls_t htc;
+ hsh_table_calls_t htc;
ASSERT(ctx);
@@ -605,8 +605,8 @@ int ntlm_init(ha_context_t* context)
ASSERT(!ctx->established);
/* Initialize our tables */
- if(!(ctx->pending = hash_create(NTLM_HASH_KEY_LEN)) ||
- !(ctx->established = hash_create(NTLM_HASH_KEY_LEN)))
+ if(!(ctx->pending = hsh_create(NTLM_HASH_KEY_LEN)) ||
+ !(ctx->established = hsh_create(NTLM_HASH_KEY_LEN)))
{
ha_messagex(LOG_CRIT, "out of memory");
return HA_CRITERROR;
@@ -614,7 +614,7 @@ int ntlm_init(ha_context_t* context)
htc.f_freeval = free_hash_object;
htc.arg = NULL;
- hash_set_table_calls(ctx->pending, &htc);
+ hsh_set_table_calls(ctx->pending, &htc);
ha_messagex(LOG_INFO, "ntlm: initialized handler");
}
@@ -644,10 +644,10 @@ void ntlm_destroy(ha_context_t* context)
ntlm_context_t* ctx = (ntlm_context_t*)(context->ctx_data);
if(ctx->pending)
- hash_free(ctx->pending);
+ hsh_free(ctx->pending);
if(ctx->established)
- hash_free(ctx->established);
+ hsh_free(ctx->established);
ha_messagex(LOG_INFO, "ntlm: uninitialized handler");
}
@@ -686,8 +686,8 @@ int ntlm_process(const ha_request_t* req, ha_response_t* resp)
* authenticated connections which have expired as
* well as half open connections which expire.
*/
- r = hash_purge(ctx->pending, t - ctx->pending_timeout);
- r += hash_purge(ctx->established, t - req->context->cache_timeout);
+ r = hsh_purge(ctx->pending, t - ctx->pending_timeout);
+ r += hsh_purge(ctx->established, t - req->context->cache_timeout);
ha_unlock(NULL);
@@ -739,9 +739,9 @@ int ntlm_process(const ha_request_t* req, ha_response_t* resp)
* allow connections to be re-authenticated.
*/
- if(hash_get(ctx->established, key) == NTLM_ESTABLISHED)
+ if(hsh_get(ctx->established, key) == NTLM_ESTABLISHED)
{
- hash_touch(ctx->established, key);
+ hsh_touch(ctx->established, key);
resp->code = HA_SERVER_OK;
}
diff --git a/daemon/simple.c b/daemon/simple.c
index 52d565d..ee4fafa 100644
--- a/daemon/simple.c
+++ b/daemon/simple.c
@@ -29,7 +29,7 @@ typedef struct simple_context
const char* filename; /* The file name with the user names */
/* Context ----------------------------------------------------------- */
- hash_t* cache; /* Some cached records or basic */
+ hsh_t* cache; /* Some cached records or basic */
}
simple_context_t;
@@ -56,11 +56,11 @@ static digest_record_t* get_cached_digest(simple_context_t* ctx, ha_context_t* c
ha_lock(NULL);
- rec = (digest_record_t*)hash_get(ctx->cache, nonce);
+ rec = (digest_record_t*)hsh_get(ctx->cache, nonce);
/* Just in case it's a basic :) */
if(rec && rec != BASIC_ESTABLISHED)
- hash_rem(ctx->cache, nonce);
+ hsh_rem(ctx->cache, nonce);
ha_unlock(NULL);
@@ -76,7 +76,7 @@ static int have_cached_basic(simple_context_t* ctx, unsigned char* key)
ha_lock(NULL);
- ret = (hash_get(ctx->cache, key) == BASIC_ESTABLISHED);
+ ret = (hsh_get(ctx->cache, key) == BASIC_ESTABLISHED);
ha_unlock(NULL);
@@ -98,10 +98,10 @@ static int save_cached_digest(simple_context_t* ctx, ha_context_t* c,
ha_lock(NULL);
- while(hash_count(ctx->cache) >= c->cache_max)
- hash_bump(ctx->cache);
+ while(hsh_count(ctx->cache) >= c->cache_max)
+ hsh_bump(ctx->cache);
- r = hash_set(ctx->cache, rec->nonce, rec);
+ r = hsh_set(ctx->cache, rec->nonce, rec);
ha_unlock(NULL);
@@ -127,10 +127,10 @@ static int add_cached_basic(simple_context_t* ctx, ha_context_t* c,
ha_lock(NULL);
- while(hash_count(ctx->cache) >= c->cache_max)
- hash_bump(ctx->cache);
+ while(hsh_count(ctx->cache) >= c->cache_max)
+ hsh_bump(ctx->cache);
- r = hash_set(ctx->cache, key, BASIC_ESTABLISHED);
+ r = hsh_set(ctx->cache, key, BASIC_ESTABLISHED);
ha_unlock(NULL);
@@ -611,7 +611,7 @@ int simple_init(ha_context_t* context)
else
{
simple_context_t* ctx = (simple_context_t*)(context->ctx_data);
- hash_table_calls_t htc;
+ hsh_table_calls_t htc;
int fd;
ASSERT(ctx);
@@ -645,7 +645,7 @@ int simple_init(ha_context_t* context)
ASSERT(!ctx->cache);
/* The cache for digest records and basic */
- if(!(ctx->cache = hash_create(MD5_LEN)))
+ if(!(ctx->cache = hsh_create(MD5_LEN)))
{
ha_messagex(LOG_CRIT, "out of memory");
return HA_CRITERROR;
@@ -653,7 +653,7 @@ int simple_init(ha_context_t* context)
htc.f_freeval = free_hash_object;
htc.arg = NULL;
- hash_set_table_calls(ctx->cache, &htc);
+ hsh_set_table_calls(ctx->cache, &htc);
ha_messagex(LOG_INFO, "simple: initialized handler");
}
@@ -670,7 +670,7 @@ void simple_destroy(ha_context_t* context)
simple_context_t* ctx = (simple_context_t*)(context->ctx_data);
if(ctx->cache)
- hash_free(ctx->cache);
+ hsh_free(ctx->cache);
ha_messagex(LOG_INFO, "simple: uninitialized handler");
}
@@ -692,7 +692,7 @@ int simple_process(const ha_request_t* req, ha_response_t* resp)
ha_lock(NULL);
/* Purge the cache */
- r = hash_purge(ctx->cache, time(NULL) - req->context->cache_timeout);
+ r = hsh_purge(ctx->cache, time(NULL) - req->context->cache_timeout);
ha_unlock(NULL);