summaryrefslogtreecommitdiff
path: root/daemon/httpauthd.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2008-06-11 21:48:27 +0000
committerStef Walter <stef@memberwebs.com>2008-06-11 21:48:27 +0000
commit0cb3f6098d959479a96c26a92d91becc2110b30d (patch)
tree22f1447d6c7ad77d802c476297cf9547f822f81a /daemon/httpauthd.c
parent67d7a6cc4d3234ac93e521632701e8d42513e042 (diff)
Support getting groups from the server and limiting access based on LDAP groups. See #112
Diffstat (limited to 'daemon/httpauthd.c')
-rw-r--r--daemon/httpauthd.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/daemon/httpauthd.c b/daemon/httpauthd.c
index 1161517..09fb1d7 100644
--- a/daemon/httpauthd.c
+++ b/daemon/httpauthd.c
@@ -31,6 +31,7 @@
#include <pthread.h>
#include <fcntl.h>
#include <err.h>
+#include <ctype.h>
#include <signal.h>
#include "usuals.h"
@@ -85,6 +86,8 @@ httpauth_loaded_t;
/* The list of handlers in use */
httpauth_loaded_t* g_handlers = NULL;
+extern int pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind);
+
/* -----------------------------------------------------------------------
* Structures and Constants
*/
@@ -162,7 +165,6 @@ static void writepid(const char* pid);
static void* httpauth_thread(void* arg);
static int httpauth_processor(int ifd, int ofd);
static int httpauth_respond(ha_request_t* rq, int ofd, int scode, int ccode, const char* msg);
-static int process_auth(ha_request_t* rq);
static int config_parse(const char* file, ha_buffer_t* buf);
static void on_quit(int signal);
@@ -176,7 +178,6 @@ int main(int argc, char* argv[])
const char* pidfile = NULL;
httpauth_thread_t* threads = NULL;
httpauth_loaded_t* h;
- char peername[MAXPATHLEN];
struct sockaddr_any sany;
int daemonize = 1;
ha_buffer_t cbuf;
@@ -944,9 +945,6 @@ static int httpauth_error(ha_request_t* rq, int ofd, int r)
static int httpauth_ready(ha_request_t* rq, int ofd)
{
- const char* t;
- httpauth_loaded_t* h;
-
ASSERT(ofd != -1);
ASSERT(rq);
@@ -1027,6 +1025,14 @@ static int httpauth_set(ha_request_t* rq, ha_buffer_t* cbuf, int ofd)
rq->digest_domain = ha_bufcpy(rq->conn_buf, value ? value : "");
}
+ else if (strcasecmp (name, "Groups") == 0) {
+
+ /* we need to copy this string so it doesn't get destroyed on next req */
+ if (rq->requested_groups)
+ str_array_free (rq->requested_groups);
+ rq->requested_groups = str_array_parse_quoted (value ? value : "");
+ }
+
else if(strcasecmp(name, "Handler") == 0)
{
if(!value || !*value)
@@ -1048,7 +1054,7 @@ static int httpauth_set(ha_request_t* rq, ha_buffer_t* cbuf, int ofd)
if(value != NULL)
{
- ha_messagex(rq, LOG_ERR, "unknown authentication handler: %s", rq->req_args[0]);
+ ha_messagex(rq, LOG_ERR, "unknown authentication handler: %s", value);
return httpauth_respond(rq, ofd, HA_SERVER_BADREQ, 0, "Unknown Auth Handler");
}
}
@@ -1107,6 +1113,7 @@ static int httpauth_processor(int ifd, int ofd)
/* Set up some context stuff */
rq.digest_domain = "";
+ rq.requested_groups = NULL;
rq.buf = &buf;
rq.conn_buf = &cbuf;
@@ -1188,6 +1195,8 @@ finally:
close(ofd);
}
+ if (rq.requested_groups)
+ str_array_free (rq.requested_groups);
ha_messagex(&rq, LOG_INFO, "closed connection");
ha_buffree(&cbuf);
@@ -1320,7 +1329,6 @@ static int config_parse(const char* file, ha_buffer_t* buf)
if(ha_bufchar(buf) == '[')
{
ha_handler_t* handler = NULL;
- const char* x;
ha_bufeat(buf);
name = ha_bufparseline(buf, 1);