#include <errno.h>
#include <fcntl.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/un.h>
#include <unistd.h>
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;
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--;
}
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;
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");
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);
}
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
}
};
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
}
};
int main(int argc UNUSED, char **argv)
{
+ umask(0077);
+
cf_def_file = CONFIG_DIR "/subauthd";
cf_declare_section("SubauthD", &daemon_config, 0);
opt_parse(&options, argv+1);
auth_init();
+ temp_init();
main_init();
init_socket();