X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=server%2Fsubauthd.c;h=393c8342031b91a9aaa4a06e67bf7c1bab04a8c9;hb=5e4edc0b1400bc90a4ea1821ca3756c141a81931;hp=0654685e78a93aff2429e7edeff7d77e281edba4;hpb=e9822b7dd42b67b6dc532a00f6059716eb20825b;p=subauth.git diff --git a/server/subauthd.c b/server/subauthd.c index 0654685..393c834 100644 --- a/server/subauthd.c +++ b/server/subauthd.c @@ -26,6 +26,7 @@ static char *socket_path = "subauthd.socket"; static uint max_connections = ~0U; clist zone_list; char *database_name = "subauthd.db"; +char *temp_key_file; static struct main_file listen_socket; static uint num_connections; @@ -43,7 +44,7 @@ static void client_close(struct client *c) timer_del(&c->timer); close(c->socket.fd); json_delete(c->json); - xfree(c); + mp_delete(c->pool); // This includes the connection structure num_connections--; } @@ -227,7 +228,9 @@ static int listen_read_handler(struct main_file *fi) if (fcntl(new_sk, F_SETFL, fcntl(new_sk, F_GETFL) | O_NONBLOCK) < 0) die("Cannot set O_NONBLOCK: %m"); - struct client *c = xmalloc_zero(sizeof(*c)); + struct mempool *mp = mp_new(4096); + struct client *c = mp_alloc_zero(mp, sizeof(*c)); + c->pool = mp; c->json = json_new(); c->socket.fd = new_sk; @@ -266,7 +269,7 @@ static void init_socket(void) if (listen(sk, 64) < 0) die("listen(): %m"); - int one; + int one = 1; if (setsockopt(sk, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) < 0) die("setsockopt(SO_PASSCRED): %m"); @@ -274,6 +277,9 @@ static void init_socket(void) listen_socket.read_handler = listen_read_handler; file_add(&listen_socket); + if (chmod(socket_path, 0666) < 0) + die("Cannot chmod socket: %m"); + msg(L_INFO, "Listening on %s", socket_path); } @@ -294,6 +300,7 @@ static struct cf_section zone_config = { CF_UINT("AutoCreateAcct", PTR_TO(struct auth_zone, auto_create_acct)), CF_UINT("AllowPasswd", PTR_TO(struct auth_zone, allow_passwd)), CF_UINT("AllowTokens", PTR_TO(struct auth_zone, allow_tokens)), + CF_UINT("MaxTempValidity", PTR_TO(struct auth_zone, max_temp_validity)), CF_END } }; @@ -304,6 +311,7 @@ static struct cf_section daemon_config = { CF_UINT("MaxConnections", &max_connections), CF_LIST("Zone", &zone_list, &zone_config), CF_STRING("Database", &database_name), + CF_STRING("TempKeyFile", &temp_key_file), CF_END } }; @@ -329,6 +337,7 @@ int main(int argc UNUSED, char **argv) opt_parse(&options, argv+1); auth_init(); + temp_init(); main_init(); init_socket();