diff options
author | Reyk Floeter <reyk@esdenera.com> | 2015-01-19 17:48:18 +0100 |
---|---|---|
committer | Reyk Floeter <reyk@esdenera.com> | 2015-01-19 17:48:18 +0100 |
commit | dda5d0c767c20326169f23cc38b6b53e51875bc2 (patch) | |
tree | 0d99cf0b000fc966de05d655f8a426bcc2a7c634 /httpd.c | |
parent | cb77100c319cef1e1da2cbfc368e967a917ed3f4 (diff) | |
download | httpd-dda5d0c767c20326169f23cc38b6b53e51875bc2.tar.gz httpd-dda5d0c767c20326169f23cc38b6b53e51875bc2.zip |
Split auth from server_config into struct auth
Diffstat (limited to 'httpd.c')
-rw-r--r-- | httpd.c | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -290,12 +290,18 @@ parent_configure(struct httpd *env) int ret = -1; struct server *srv; struct media_type *media; + struct auth *auth; RB_FOREACH(media, mediatypes, env->sc_mediatypes) { if (config_setmedia(env, media) == -1) fatal("send media"); } + TAILQ_FOREACH(auth, env->sc_auth, auth_entry) { + if (config_setauth(env, auth) == -1) + fatal("send auth"); + } + /* First send the servers... */ TAILQ_FOREACH(srv, env->sc_servers, srv_entry) { if (srv->srv_conf.flags & SRVFLAG_LOCATION) @@ -1146,3 +1152,42 @@ media_cmp(struct media_type *a, struct media_type *b) } RB_GENERATE(mediatypes, media_type, media_entry, media_cmp); + +struct auth * +auth_add(struct serverauth *serverauth, struct auth *auth) +{ + struct auth *entry; + + TAILQ_FOREACH(entry, serverauth, auth_entry) { + if (strcmp(entry->auth_htpasswd, auth->auth_htpasswd) == 0) + return (entry); + } + + if ((entry = calloc(1, sizeof(*entry))) == NULL) + return (NULL); + + memcpy(entry, auth, sizeof(*entry)); + + TAILQ_INSERT_TAIL(serverauth, entry, auth_entry); + + return (entry); +} + +struct auth * +auth_byid(struct serverauth *serverauth, u_int32_t id) +{ + struct auth *auth; + + TAILQ_FOREACH(auth, serverauth, auth_entry) { + if (auth->auth_id == id) + return (auth); + } + + return (NULL); +} + +void +auth_free(struct serverauth *serverauth, struct auth *auth) +{ + TAILQ_REMOVE(serverauth, auth, auth_entry); +} |