return para_strdup(NULL);
}
-static int want_colors(void)
-{
- if (conf.color_arg == color_arg_no)
- return 0;
- if (conf.color_arg == color_arg_yes)
- return 1;
- if (conf.logfile_given)
- return 0;
- return isatty(STDERR_FILENO);
-}
-
static void parse_config_or_die(void)
{
int ret;
/* does not unlink socket on errors */
static int audiod_get_socket(void)
{
- struct sockaddr_un unix_addr;
- int ret, fd;
+ int ret;
if (conf.socket_given)
socket_name = para_strdup(conf.socket_arg);
PARA_NOTICE_LOG("local socket: %s\n", socket_name);
if (conf.force_given)
unlink(socket_name);
- ret = create_local_socket(socket_name, &unix_addr,
+ ret = create_local_socket(socket_name,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IWOTH);
if (ret < 0)
goto err;
- fd = ret;
- if (listen(fd , 5) < 0) {
- ret = -ERRNO_TO_PARA_ERROR(errno);
- goto err;
- }
- ret = mark_fd_nonblocking(fd);
- if (ret < 0)
- goto err;
- return fd;
+ return ret;
err:
PARA_EMERG_LOG("%s\n", para_strerror(-ret));
exit(EXIT_FAILURE);
exit(0);
}
-static void init_colors_or_die(void)
-{
- int i;
-
- if (!want_colors())
- return;
- daemon_set_default_log_colors();
- daemon_set_flag(DF_COLOR_LOG);
- for (i = 0; i < conf.log_color_given; i++)
- daemon_set_log_color_or_die(conf.log_color_arg[i]);
-}
-
/**
* the main function of para_audiod
*
print_help_and_die();
daemon_drop_privileges_or_die(conf.user_arg, conf.group_arg);
parse_config_or_die();
- init_colors_or_die();
+ daemon_init_colors_or_die(conf.color_arg, color_arg_auto, color_arg_no,
+ conf.logfile_given, conf.log_color_arg, conf.log_color_given);
init_random_seed_or_die();
daemon_set_flag(DF_LOG_TIME);
daemon_set_flag(DF_LOG_HOSTNAME);