]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - server.c
afs.h: Don't try to list all supported audio formats.
[paraslash.git] / server.c
index 31d29c73dc5595c881173abe4eea892854b1f6a3..a9e9495fd3f7238c4b875f7958cc5ebf8ccdd863 100644 (file)
--- a/server.c
+++ b/server.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1997-2013 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2014 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -8,10 +8,7 @@
 
 
 /**
- * \mainpage Paraslash API Reference
- *
- * Starting points for getting an overview:
- *
+ * \mainpage Starting points for getting an overview:
  *
  *     - The main programs: \ref server.c, \ref audiod.c, \ref client.c,
  *       \ref audioc.c, \ref afh.c, \ref play.c,
  *     - Spawning processes: \ref exec.c,
  *     - Inter process communication: \ref ipc.c,
  *     - Blob tables: \ref blob.c,
- *     - The error subsystem: \ref error.h.
- *     - Access control for paraslash senders: \ref acl.c, \ref acl.h.
- *     - Internal crypto API: \ref crypt.h.
- *     - interactive sessions (libreadline): \ref interactive.c.
+ *     - The error subsystem: \ref error.h, \ref error2.c,
+ *     - Access control for paraslash senders: \ref acl.c, \ref acl.h,
+ *     - Internal crypto API: \ref crypt.h,
+ *     - interactive sessions (libreadline): \ref interactive.c,
+ *     - sideband API: \ref sideband.h.
  *
  * Low-level data structures:
  *
@@ -91,6 +89,7 @@
 #include "signal.h"
 #include "user_list.h"
 #include "color.h"
+#include "ggo.h"
 #include "version.h"
 
 __printf_2_3 void (*para_log)(int, const char*, ...) = daemon_log;
@@ -390,6 +389,9 @@ static int command_post_select(struct sched *s, struct task *t)
                goto out;
        }
        if (child_pid) {
+               /* avoid problems with non-fork-safe PRNGs */
+               unsigned char buf[16];
+               get_random_bytes_or_die(buf, sizeof(buf));
                close(new_fd);
                /* parent keeps accepting connections */
                return 0;
@@ -473,6 +475,15 @@ static int init_afs(int argc, char **argv)
        return afs_server_socket[0];
 }
 
+__noreturn static void print_help_and_die(void)
+{
+       struct ggo_help h = DEFINE_GGO_HELP(server);
+       bool d = conf.detailed_help_given;
+
+       ggo_print_help(&h, d? GPH_STANDARD_FLAGS_DETAILED : GPH_STANDARD_FLAGS);
+       exit(0);
+}
+
 static void server_init(int argc, char **argv)
 {
        struct server_cmdline_parser_params params = {
@@ -488,9 +499,11 @@ static void server_init(int argc, char **argv)
        init_random_seed_or_die();
        /* parse command line options */
        server_cmdline_parser_ext(argc, argv, &conf, &params);
-       HANDLE_VERSION_FLAG("server", conf);
-       drop_privileges_or_die(conf.user_arg, conf.group_arg);
        daemon_set_loglevel(conf.loglevel_arg);
+       version_handle_flag("server", conf.version_given);
+       if (conf.help_given || conf.detailed_help_given)
+               print_help_and_die();
+       drop_privileges_or_die(conf.user_arg, conf.group_arg);
        /* parse config file, open log and set defaults */
        parse_config_or_die(0);
        log_welcome("para_server");