X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;ds=sidebyside;f=server.c;h=011367e3481af17e10f6390fb36192a136c271fd;hb=3998a8c581623224b7b56bce593646b2c8516a0f;hp=2018b8eece1988206e2992f560b65fa73059ff5e;hpb=e32a0e7295c6386b421956553ae577a7df1abf8e;p=paraslash.git diff --git a/server.c b/server.c index 2018b8ee..011367e3 100644 --- a/server.c +++ b/server.c @@ -45,6 +45,7 @@ #include "afh.h" #include "string.h" #include "afs.h" +#include "net.h" #include "server.h" #include "list.h" #include "send.h" @@ -52,7 +53,6 @@ #include "vss.h" #include "config.h" #include "close_on_fork.h" -#include "net.h" #include "daemon.h" #include "ipc.h" #include "fd.h" @@ -86,7 +86,15 @@ struct lls_parse_result *server_lpr = NULL; /* Command line options (no config file options). Used in handle_sighup(). */ static struct lls_parse_result *cmdline_lpr; -/** A random value used in child context for authentication. */ +/** + * A random number used to "authenticate" the afs connection. + * + * para_server picks this number by random before it forks the afs process. The + * command handlers know this number as well and write it to the afs socket, + * together with the id of the shared memory area which contains the payload of + * the afs command. A local process has to know this number to abuse the afs + * service provided by the local socket. + */ uint32_t afs_socket_cookie; /** The mutex protecting the shared memory area containing the mmd struct. */ @@ -177,7 +185,6 @@ void parse_config_or_die(bool reload) struct lls_parse_result *cf_lpr, *merged_lpr; char *home = para_homedir(); - daemon_close_log(); if (OPT_GIVEN(CONFIG_FILE)) cf = para_strdup(OPT_STRING_VAL(CONFIG_FILE)); else @@ -449,12 +456,13 @@ static int init_afs(int argc, char **argv) int i; afs_pid = getpid(); + crypt_shutdown(); for (i = argc - 1; i >= 0; i--) memset(argv[i], 0, strlen(argv[i])); i = argc - lls_num_inputs(cmdline_lpr) - 1; sprintf(argv[i], "para_server (afs)"); close(afs_server_socket[0]); - afs_init(afs_socket_cookie, afs_server_socket[1]); + afs_init(afs_server_socket[1]); } close(afs_server_socket[1]); if (read(afs_server_socket[0], &c, 1) <= 0) { @@ -506,7 +514,7 @@ static void server_init(int argc, char **argv) /* become daemon */ if (OPT_GIVEN(DAEMON)) daemon_pipe = daemonize(true /* parent waits for SIGTERM */); - init_random_seed_or_die(); + crypt_init(); daemon_log_welcome("server"); init_ipc_or_die(); /* init mmd struct and mmd->lock */ daemon_set_start_time(); @@ -603,6 +611,7 @@ int main(int argc, char *argv[]) mutex_lock(mmd_mutex); ret = schedule(&sched); sched_shutdown(&sched); + crypt_shutdown(); lls_free_parse_result(server_lpr, CMD_PTR); if (server_lpr != cmdline_lpr) lls_free_parse_result(cmdline_lpr, CMD_PTR);