# include <freeradius-devel/tls/version.h>
#endif
-char const *radiusd_version = RADIUSD_VERSION_BUILD("FreeRADIUS");
-static pid_t radius_pid;
+char const *radiusd_version = RADIUSD_VERSION_BUILD("FreeRADIUS");
+static pid_t radius_pid;
+char const *program = NULL;
/*
* Configuration items.
/*
* Static functions.
*/
-static void usage(main_config_t const *config, int status);
+static void usage(int status);
static void sig_fatal (int);
#ifdef SIGHUP
if (fr_time_eq(now, fr_time_wrap(0))) {
if (fr_event_timer_in(el, el, &ev, exit_after, fr_exit_after, uctx) < 0) {
- PERROR("Failed inserting exit event");
+ PERROR("%s: Failed inserting exit event", program);
}
return;
}
bool display_version = false;
bool radmin = false;
int from_child[2] = {-1, -1};
- char const *program;
fr_schedule_t *sc = NULL;
int ret = EXIT_SUCCESS;
*/
(void) fr_talloc_fault_setup();
+ /*
+ * Set some default values
+ */
+ program = strrchr(argv[0], FR_DIR_SEP);
+ if (!program) {
+ program = argv[0];
+ } else {
+ program++;
+ }
+
/*
* We probably don't want to free the talloc global_ctx context
* directly, so we'll allocate a new context beneath it, and
env = getenv("FR_GLOBAL_POOL");
if (env) {
if (fr_size_from_str(&pool_size, &FR_SBUFF_IN(env, strlen(env))) < 0) {
- fr_perror("Invalid pool size string \"%s\"", env);
+ fr_perror("%s: Invalid pool size string \"%s\"", program, env);
EXIT_WITH_FAILURE;
}
EXIT_WITH_FAILURE;
}
- /*
- * Set some default values
- */
- program = strrchr(argv[0], FR_DIR_SEP);
- if (!program) {
- program = argv[0];
- } else {
- program++;
- }
main_config_name_set_default(config, program, false);
config->daemonize = true;
config->spawn_workers = true;
-#ifdef OSFC2
- set_auth_parameters(argc, argv);
-#endif
-
-#ifdef WIN32
- {
- WSADATA wsaData;
- if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
- fprintf(stderr, "%s: Unable to initialize socket library.\n", config->name);
- EXIT_WITH_FAILURE;
- }
- }
-#endif
-
fr_debug_lvl = 0;
fr_time_start();
* Set the panic action and enable other debugging facilities
*/
if (fr_fault_setup(global_ctx, getenv("PANIC_ACTION"), argv[0]) < 0) {
- fr_perror("Failed installing fault handlers... continuing");
+ fr_perror("%s: Failed installing fault handlers... continuing", program);
}
/* Process the options. */
break;
case 'h':
- usage(config, EXIT_SUCCESS);
+ usage(EXIT_SUCCESS);
break;
case 'l':
default_log.fd = open(config->log_file, O_WRONLY | O_APPEND | O_CREAT, 0640);
if (default_log.fd < 0) {
fprintf(stderr, "%s: Failed to open log file %s: %s\n",
- config->name, config->log_file, fr_syserror(errno));
+ program, config->log_file, fr_syserror(errno));
EXIT_WITH_FAILURE;
}
break;
case 'S': /* Migration support */
if (main_config_parse_option(optarg) < 0) {
fprintf(stderr, "%s: Unknown configuration option '%s'\n",
- config->name, optarg);
+ program, optarg);
EXIT_WITH_FAILURE;
}
break;
break;
default:
- usage(config, EXIT_FAILURE);
+ usage(EXIT_FAILURE);
break;
}
* Mismatch between the binary and the libraries it depends on.
*/
if (fr_check_lib_magic(RADIUSD_MAGIC_NUMBER) < 0) {
- fr_perror("%s", config->name);
+ fr_perror("%s", program);
EXIT_WITH_FAILURE;
}
* So we can't run with a null context and threads.
*/
if (talloc_config_set(config) != 0) {
- fr_perror("%s", config->name);
+ fr_perror("%s", program);
EXIT_WITH_FAILURE;
}
default_log.dst = L_DST_STDOUT;
default_log.fd = STDOUT_FILENO;
- INFO("%s - %s", config->name, radiusd_version);
+ INFO("%s - %s", program, radiusd_version);
dependency_version_print();
EXIT_WITH_SUCCESS;
}
break;
case -1: /* Permissions error - fail open */
- PWARN("%s - Process concurrency checks disabled", program);
+ PWARN("%s: Process concurrency checks disabled", program);
break;
case 1:
*/
if (config->panic_action && !getenv("PANIC_ACTION") &&
(fr_fault_setup(global_ctx, config->panic_action, argv[0]) < 0)) {
- fr_perror("radiusd - Failed configuring panic action: %s", config->name);
+ fr_perror("%s: Failed configuring panic action", program);
EXIT_WITH_FAILURE;
}
* Call this again now we've loaded the configuration. Yes I know...
*/
if (talloc_config_set(config) < 0) {
- fr_perror("%s", config->name);
+ fr_perror("%s", program);
EXIT_WITH_FAILURE;
}
*/
} else if (pid == 0) {
if (main_config_exclusive_proc_child(main_config) < 0) {
- PWARN("%s - Failed incrementing exclusive proc semaphore in child", program);
+ PWARN("%s: Failed incrementing exclusive proc semaphore in child", program);
}
}
*/
if (talloc_free(global_ctx) < 0) {
#ifndef NDEBUG
- fr_perror("radiusd");
+ fr_perror("program");
ret = EXIT_FAILURE;
#endif
}
/*
* Display the syntax for starting this program.
*/
-static NEVER_RETURNS void usage(main_config_t const *config, int status)
+static NEVER_RETURNS void usage(int status)
{
FILE *output = status ? stderr : stdout;
- fprintf(output, "Usage: %s [options]\n", config->name);
+ fprintf(output, "Usage: %s [options]\n", program);
fprintf(output, "Options:\n");
fprintf(output, " -C Check configuration and exit.\n");
fprintf(stderr, " -d <raddb> Set configuration directory (defaults to " RADDBDIR ").\n");
#ifndef NDEBUG
fprintf(output, " -L <size> When running in memory debug mode, set a hard limit on talloced memory\n");
#endif
- fprintf(output, " -n <name> Read raddb/name.conf instead of raddb/radiusd.conf.\n");
- fprintf(output, " -m Allow multiple processes reading the same radiusd.conf to exist simultaneously.\n");
+ fprintf(output, " -n <name> Read raddb/name.conf instead of raddb/%s.conf.\n", program);
+ fprintf(output, " -m Allow multiple processes reading the same %s.conf to exist simultaneously.\n", program);
#ifndef NDEBUG
fprintf(output, " -M Enable talloc memory debugging, and issue a memory report when the server terminates\n");
#endif