#include "vss.h"
#include "config.h"
#include "close_on_fork.h"
+#include "list.h"
#include "send.h"
#include "net.h"
#include "daemon.h"
#include "ipc.h"
#include "fd.h"
-#include "list.h"
#include "sched.h"
#include "signal.h"
#include "user_list.h"
mmd->sender_cmd_data.cmd_num = -1;
return;
err_out:
- PARA_EMERG_LOG("%s", para_strerror(-ret));
+ PARA_EMERG_LOG("%s\n", para_strerror(-ret));
exit(EXIT_FAILURE);
}
struct server_cmdline_parser_params params = {
.override = override,
.initialize = 0,
- .check_required = 0,
- .check_ambiguity = 0
+ .check_required = 1,
+ .check_ambiguity = 0,
+ .print_errors = 1
};
server_cmdline_parser_config_file(cf, &conf, ¶ms);
conf.daemon_given = tmp;
}
- /* logfile */
- if (!conf.logfile_given && conf.daemon_given) {
- ret = -1;
- PARA_EMERG_LOG("%s", "daemon, but no log file\n");
- goto out;
- }
if (conf.logfile_given)
logfile = open_log(conf.logfile_arg);
ret = 1;
static void init_random_seed(void)
{
- int fd, ret = -1;
unsigned int seed;
- size_t len = sizeof(unsigned int);
+ int fd, ret = para_open("/dev/urandom", O_RDONLY, 0);
- fd = open("/dev/urandom", O_RDONLY);
- if (fd < 0)
+ if (ret < 0)
+ goto err;
+ fd = ret;
+ ret = read(fd, &seed, sizeof(seed));
+ if (ret < 0) {
+ ret = -ERRNO_TO_PARA_ERROR(errno);
goto out;
- ret = -2;
- if (read(fd, &seed, len) != len)
+ }
+ if (ret != sizeof(seed)) {
+ ret = -ERRNO_TO_PARA_ERROR(EIO);
goto out;
+ }
srandom(seed);
ret = 1;
out:
- if (fd >= 0)
- close(fd);
- if (ret > 0)
+ close(fd);
+ if (ret >= 0)
return;
- PARA_EMERG_LOG("can not seed pseudo random generator (ret = %d)\n",
- ret);
+err:
+ PARA_EMERG_LOG("can not seed pseudo random number generator: %s\n",
+ para_strerror(-ret));
exit(EXIT_FAILURE);
}
(unsigned) afs_socket_cookie);
}
-
static unsigned server_init(int argc, char **argv)
{
/* connector's address information */
int sockfd;
-
+ struct server_cmdline_parser_params params = {
+ .override = 0,
+ .initialize = 1,
+ .check_required = 0,
+ .check_ambiguity = 0,
+ .print_errors = 1
+ };
init_random_seed();
/* parse command line options */
- server_cmdline_parser(argc, argv, &conf);
+ server_cmdline_parser_ext(argc, argv, &conf, ¶ms);
HANDLE_VERSION_FLAG("server", conf);
para_drop_privileges(conf.user_arg, conf.group_arg);
/* parse config file, open log and set defaults */
*/
static void handle_sighup(void)
{
- PARA_NOTICE_LOG("%s", "SIGHUP\n");
+ PARA_NOTICE_LOG("SIGHUP\n");
close_log(logfile); /* gets reopened if necessary by parse_config */
logfile = NULL;
parse_config(1); /* reopens log */
mmd_unlock();
ret = para_select(max_fileno + 1, &rfds, &wfds, timeout);
mmd_lock();
- vss_post_select(&rfds, &wfds);
if (ret < 0)
goto repeat;
+ vss_post_select(&rfds, &wfds);
for (i = 0; senders[i].name; i++) {
if (!senders[i].post_select)
continue;
random();
chld_pid = fork();
if (chld_pid < 0) {
- PARA_CRIT_LOG("%s", "fork failed\n");
+ PARA_CRIT_LOG("fork failed\n");
goto repeat;
}
if (chld_pid) {