summaryrefslogtreecommitdiff
path: root/daemon/simple.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/simple.c')
-rw-r--r--daemon/simple.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/daemon/simple.c b/daemon/simple.c
index fdaa0e0..d51e9d9 100644
--- a/daemon/simple.c
+++ b/daemon/simple.c
@@ -25,10 +25,11 @@ unsigned char g_simple_secret[DIGEST_SECRET_LEN];
typedef struct simple_context
{
- const char* filename; /* The file name with the user names */
- const char* realm; /* The realm for basic authentication */
+ const char* filename; /* The file name with the user names */
+ const char* realm; /* The realm for basic authentication */
const char* domains; /* Domains for which digest auth is valid */
int cache_max; /* Maximum number of connections at once */
+ int cache_timeout;
/* Context ----------------------------------------------------------- */
hash_t* cache; /* Some cached records or basic */
@@ -41,7 +42,8 @@ static const simple_context_t simple_defaults =
NULL, /* filename */
NULL, /* realm */
NULL, /* domains */
- 1000, /* cache_max */
+ 0, /* cache_max */
+ 0, /* cache_timeout */
NULL /* cache */
};
@@ -381,7 +383,7 @@ static int simple_digest_challenge(simple_context_t* ctx, ha_response_t* resp,
}
static int simple_digest_response(simple_context_t* ctx, const char* header,
- const char* method, const char* uri, int timeout,
+ const char* method, const char* uri,
ha_response_t* resp, ha_buffer_t* buf)
{
unsigned char nonce[DIGEST_NONCE_LEN];
@@ -414,7 +416,7 @@ static int simple_digest_response(simple_context_t* ctx, const char* header,
rec = get_cached_digest(ctx, nonce);
/* Check to see if we're stale */
- if((expiry + timeout) <= time(NULL))
+ if((expiry + ctx->cache_timeout) <= time(NULL))
{
stale = 1;
goto finally;
@@ -453,7 +455,7 @@ static int simple_digest_response(simple_context_t* ctx, const char* header,
resp->detail = dg.username;
/* Figure out if we need a new nonce */
- if((expiry + (timeout - (timeout / 8))) < time(NULL))
+ if((expiry + (ctx->cache_timeout - (ctx->cache_timeout / 8))) < time(NULL))
{
digest_makenonce(nonce, g_simple_secret, NULL);
stale = 1;
@@ -518,11 +520,6 @@ int simple_config(ha_context_t* context, const char* name, const char* value)
return HA_OK;
}
- else if(strcmp(name, "cachemax") == 0)
- {
- return ha_confint(name, value, 0, 0x7FFFFFFF, &(ctx->cache_max));
- }
-
return HA_FALSE;
}
@@ -576,6 +573,11 @@ int simple_init(ha_context_t* context)
ha_messagex(LOG_CRIT, "out of memory");
return HA_ERROR;
}
+
+ /* Copy some settings over for easy access */
+ ctx->cache_max = context->cache_max;
+ ctx->cache_timeout = context->cache_timeout;
+
}
return HA_OK;
@@ -610,7 +612,7 @@ int simple_process(ha_context_t* context, ha_request_t* req,
ha_lock(NULL);
/* Purge the cache */
- hash_purge(ctx->cache, time(NULL) - context->timeout);
+ hash_purge(ctx->cache, time(NULL) - ctx->cache_timeout);
ha_unlock(NULL);
@@ -626,8 +628,7 @@ int simple_process(ha_context_t* context, ha_request_t* req,
if(header)
{
ret = simple_digest_response(ctx, header, req->args[AUTH_ARG_METHOD],
- req->args[AUTH_ARG_URI], context->timeout,
- resp, buf);
+ req->args[AUTH_ARG_URI], resp, buf);
if(ret == HA_ERROR)
return ret;
}