All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
radiusd.c
Go to the documentation of this file.
1 /*
2  * radiusd.c Main loop of the radius server.
3  *
4  * Version: $Id: 2674e30c099136ec84cb4b09ca58d3235853ec6e $
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  * Copyright 2000-2012 The FreeRADIUS server project
21  * Copyright 1999,2000 Miquel van Smoorenburg <miquels@cistron.nl>
22  * Copyright 2000 Alan DeKok <aland@ox.org>
23  * Copyright 2000 Alan Curry <pacman-radius@cqc.com>
24  * Copyright 2000 Jeff Carneal <jeff@apex.net>
25  * Copyright 2000 Chad Miller <cmiller@surfsouth.com>
26  */
27 
28 RCSID("$Id: 2674e30c099136ec84cb4b09ca58d3235853ec6e $")
29 
30 #include <freeradius-devel/radiusd.h>
31 #include <freeradius-devel/modules.h>
32 #include <freeradius-devel/state.h>
33 #include <freeradius-devel/map_proc.h>
34 #include <freeradius-devel/rad_assert.h>
35 
36 #include <sys/file.h>
37 
38 #include <fcntl.h>
39 #include <ctype.h>
40 
41 #ifdef HAVE_GETOPT_H
42 # include <getopt.h>
43 #endif
44 
45 #ifdef HAVE_SYS_WAIT_H
46 # include <sys/wait.h>
47 #endif
48 #ifndef WEXITSTATUS
49 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
50 #endif
51 #ifndef WIFEXITED
52 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
53 #endif
54 
55 /*
56  * Global variables.
57  */
58 char const *radacct_dir = NULL;
59 char const *radlog_dir = NULL;
60 
62 
63 char const *radiusd_version = "FreeRADIUS Version " RADIUSD_VERSION_STRING
64 #ifdef RADIUSD_VERSION_COMMIT
65 " (git #" STRINGIFY(RADIUSD_VERSION_COMMIT) ")"
66 #endif
67 ", for host " HOSTINFO ", built on " __DATE__ " at " __TIME__;
68 
69 static pid_t radius_pid;
70 
71 /*
72  * Configuration items.
73  */
74 
75 /*
76  * Static functions.
77  */
78 static void usage(int);
79 
80 static void sig_fatal (int);
81 #ifdef SIGHUP
82 static void sig_hup (int);
83 #endif
84 
85 /*
86  * The main guy.
87  */
88 int main(int argc, char *argv[])
89 {
90  int rcode = EXIT_SUCCESS;
91  int status;
92  int argval;
93  bool display_version = false;
94  int from_child[2] = {-1, -1};
95  char *p;
96 
97  /*
98  * We probably don't want to free the talloc autofree context
99  * directly, so we'll allocate a new context beneath it, and
100  * free that before any leak reports.
101  */
102  TALLOC_CTX *autofree = talloc_init("main");
103 
104 #ifdef OSFC2
105  set_auth_parameters(argc, argv);
106 #endif
107 
108 #ifdef WIN32
109  {
110  WSADATA wsaData;
111  if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
112  fprintf(stderr, "%s: Unable to initialize socket library.\n",
113  main_config.name);
114  exit(EXIT_FAILURE);
115  }
116  }
117 #endif
118 
119  rad_debug_lvl = 0;
120  set_radius_dir(autofree, RADIUS_DIR);
121 
122  /*
123  * Ensure that the configuration is initialized.
124  */
125  memset(&main_config, 0, sizeof(main_config));
126  main_config.daemonize = true;
127  main_config.spawn_workers = true;
128 
129  p = strrchr(argv[0], FR_DIR_SEP);
130  if (!p) {
131  main_config.name = argv[0];
132  } else {
133  main_config.name = p + 1;
134  }
135 
136  /*
137  * Don't put output anywhere until we get told a little
138  * more.
139  */
141  default_log.fd = -1;
142  main_config.log_file = NULL;
143 
144  /* Process the options. */
145  while ((argval = getopt(argc, argv, "Cd:D:fhi:l:mMn:p:PstvxX")) != EOF) {
146 
147  switch (argval) {
148  case 'C':
149  check_config = true;
150  main_config.spawn_workers = false;
151  main_config.daemonize = false;
152  break;
153 
154  case 'd':
155  set_radius_dir(autofree, optarg);
156  break;
157 
158  case 'D':
159  main_config.dictionary_dir = talloc_typed_strdup(autofree, optarg);
160  break;
161 
162  case 'f':
163  main_config.daemonize = false;
164  break;
165 
166  case 'h':
167  usage(0);
168  break;
169 
170  case 'l':
171  if (strcmp(optarg, "stdout") == 0) {
172  goto do_stdout;
173  }
174  main_config.log_file = strdup(optarg);
176  default_log.fd = open(main_config.log_file, O_WRONLY | O_APPEND | O_CREAT, 0640);
177  if (default_log.fd < 0) {
178  fprintf(stderr, "%s: Failed to open log file %s: %s\n",
180  exit(EXIT_FAILURE);
181  }
182  fr_log_fp = fdopen(default_log.fd, "a");
183  break;
184 
185  case 'n':
186  main_config.name = optarg;
187  break;
188 
189  case 'm':
190  main_config.debug_memory = true;
191  break;
192 
193  case 'M':
194  main_config.memory_report = true;
195  main_config.debug_memory = true;
196  break;
197 
198  case 'P':
199  /* Force the PID to be written, even in -f mode */
200  main_config.write_pid = true;
201  break;
202 
203  case 's': /* Single process mode */
204  main_config.spawn_workers = false;
205  main_config.daemonize = false;
206  break;
207 
208  case 't': /* no child threads */
209  main_config.spawn_workers = false;
210  break;
211 
212  case 'v':
213  display_version = true;
214  break;
215 
216  case 'X':
217  main_config.spawn_workers = false;
218  main_config.daemonize = false;
219  rad_debug_lvl += 2;
220  main_config.log_auth = true;
223  do_stdout:
224  fr_log_fp = stdout;
226  default_log.fd = STDOUT_FILENO;
227  break;
228 
229  case 'x':
230  rad_debug_lvl++;
231  break;
232 
233  default:
234  usage(1);
235  break;
236  }
237  }
238 
239  /*
240  * Mismatch between the binary and the libraries it depends on.
241  */
243  fr_perror("%s", main_config.name);
244  exit(EXIT_FAILURE);
245  }
246 
247  if (rad_check_lib_magic(RADIUSD_MAGIC_NUMBER) < 0) exit(EXIT_FAILURE);
248 
249  /*
250  * Mismatch between build time OpenSSL and linked SSL, better to die
251  * here than segfault later.
252  */
253 #ifdef HAVE_OPENSSL_CRYPTO_H
254  if (ssl_check_consistency() < 0) exit(EXIT_FAILURE);
255 #endif
256 
257  /*
258  * According to the talloc peeps, no two threads may modify any part of
259  * a ctx tree with a common root without synchronisation.
260  *
261  * So we can't run with a null context and threads.
262  */
265  fprintf(stderr, "%s: The server cannot produce memory reports (-M) in threaded mode\n",
266  main_config.name);
267  exit(EXIT_FAILURE);
268  }
269  talloc_enable_null_tracking();
270  } else {
271  talloc_disable_null_tracking();
272  }
273 
274  /*
275  * Initialising OpenSSL once, here, is safer than having individual modules do it.
276  * Must be called before display_version to ensure relevant engines are loaded.
277  */
278 #ifdef HAVE_OPENSSL_CRYPTO_H
279  if (tls_global_init() < 0) exit(EXIT_FAILURE);
280 #endif
281 
282  /*
283  * Better here, so it doesn't matter whether we get passed -xv or -vx.
284  */
285  if (display_version) {
286  if (rad_debug_lvl == 0) rad_debug_lvl = 1;
287  fr_log_fp = stdout;
289  default_log.fd = STDOUT_FILENO;
290 
291  INFO("%s: %s", main_config.name, radiusd_version);
292  version_print();
293  exit(EXIT_SUCCESS);
294  }
295 
297 
298  /*
299  * Under linux CAP_SYS_PTRACE is usually only available before setuid/setguid,
300  * so we need to check whether we can attach before calling those functions
301  * (in main_config_init()).
302  */
304 
305  /*
306  * Write the PID always if we're running as a daemon.
307  */
309 
310  /*
311  * Read the configuration files, BEFORE doing anything else.
312  */
313  if (main_config_init() < 0) exit(EXIT_FAILURE);
314 
315  /*
316  * This is very useful in figuring out why the panic_action didn't fire.
317  */
319 
320  /*
321  * Check for vulnerabilities in the version of libssl were linked against.
322  */
323 #if defined(HAVE_OPENSSL_CRYPTO_H) && defined(ENABLE_OPENSSL_VERSION_CHECK)
324  if (tls_global_version_check(main_config.allow_vulnerable_openssl) < 0) exit(EXIT_FAILURE);
325 #endif
326 
328 
329  /*
330  * Set the panic action (if required)
331  */
332  {
333  char const *panic_action = NULL;
334 
335  panic_action = getenv("PANIC_ACTION");
336  if (!panic_action) panic_action = main_config.panic_action;
337 
338  if (panic_action && (fr_fault_setup(panic_action, argv[0]) < 0)) {
339  fr_perror("%s", main_config.name);
340  exit(EXIT_FAILURE);
341  }
342  }
343 
344 #ifndef __MINGW32__
345  /*
346  * Disconnect from session
347  */
348  if (main_config.daemonize) {
349  pid_t pid;
350  int devnull;
351 
352  /*
353  * Really weird things happen if we leave stdin open and call things like
354  * system() later.
355  */
356  devnull = open("/dev/null", O_RDWR);
357  if (devnull < 0) {
358  ERROR("Failed opening /dev/null: %s", fr_syserror(errno));
359  exit(EXIT_FAILURE);
360  }
361  dup2(devnull, STDIN_FILENO);
362 
363  close(devnull);
364 
365  if (pipe(from_child) != 0) {
366  ERROR("Couldn't open pipe for child status: %s", fr_syserror(errno));
367  exit(EXIT_FAILURE);
368  }
369 
370  pid = fork();
371  if (pid < 0) {
372  ERROR("Couldn't fork: %s", fr_syserror(errno));
373  exit(EXIT_FAILURE);
374  }
375 
376  /*
377  * The parent exits, so the child can run in the background.
378  *
379  * As the child can still encounter an error during initialisation
380  * we do a blocking read on a pipe between it and the parent.
381  *
382  * Just before entering the event loop the child will send a success
383  * or failure message to the parent, via the pipe.
384  */
385  if (pid > 0) {
386  uint8_t ret = 0;
387  int stat_loc;
388 
389  /* So the pipe is correctly widowed if the child exits */
390  close(from_child[1]);
391 
392  /*
393  * The child writes a 0x01 byte on success, and closes
394  * the pipe on error.
395  */
396  if ((read(from_child[0], &ret, 1) < 0)) {
397  ret = 0;
398  }
399 
400  /* For cleanliness... */
401  close(from_child[0]);
402 
403  /* Don't turn children into zombies */
404  if (!ret) {
405  waitpid(pid, &stat_loc, WNOHANG);
406  exit(EXIT_FAILURE);
407  }
408 
409  exit(EXIT_SUCCESS);
410  }
411 
412  /* so the pipe is correctly widowed if the parent exits?! */
413  close(from_child[0]);
414 # ifdef HAVE_SETSID
415  setsid();
416 # endif
417  }
418 #endif
419 
420  /*
421  * Ensure that we're using the CORRECT pid after forking, NOT the one
422  * we started with.
423  */
424  radius_pid = getpid();
425 
426 #ifdef HAVE_PTHREAD_H
427  /*
428  * Parse the thread pool configuration.
429  */
430  if (thread_pool_bootstrap(main_config.config, &main_config.spawn_workers) < 0) exit(EXIT_FAILURE);
431 #endif
432 
433  /*
434  * Initialize Auth-Type, etc. in the virtual servers
435  * before loading the modules. Some modules need those
436  * to be defined.
437  */
438  if (virtual_servers_bootstrap(main_config.config) < 0) exit(EXIT_FAILURE);
439 
440  /*
441  * Bootstrap the modules. This links to them, and runs
442  * their "bootstrap" routines.
443  *
444  * After this step, all dynamic attributes, xlats, etc. are defined.
445  */
446  if (modules_bootstrap(main_config.config) < 0) exit(EXIT_FAILURE);
447 
448  /*
449  * Load the modules before starting up any threads.
450  */
451  if (modules_init(main_config.config) < 0) exit(EXIT_FAILURE);
452 
453  /*
454  * And then load the virtual servers.
455  */
456  if (virtual_servers_init(main_config.config) < 0) exit(EXIT_FAILURE);
457 
458  /*
459  * Initialize any event loops just enough so module instantiations can
460  * add fd/event to them, but do not start them yet.
461  *
462  * This has to be done post-fork in case we're using kqueue, where the
463  * queue isn't inherited by the child process.
464  */
465  if (!radius_event_init(autofree)) exit(EXIT_FAILURE);
466 
467  /*
468  * Redirect stderr/stdout as appropriate.
469  */
471  ERROR("%s", fr_strerror());
472  exit(EXIT_FAILURE);
473  }
474 
475 #ifdef HAVE_PTHREAD_H
476  /*
477  * Initialize the threads ONLY if we're spawning, AND
478  * we're running normally.
479  */
480  if (main_config.spawn_workers && (thread_pool_init() < 0)) exit(EXIT_FAILURE);
481 #endif
482 
483  event_loop_started = true;
484 
485  /*
486  * Start the event loop.
487  */
489 
490  /*
491  * If we're debugging, then a CTRL-C will cause the server to die
492  * immediately. Use SIGTERM to shut down the server cleanly in
493  * that case.
494  */
495  if (main_config.debug_memory || (rad_debug_lvl == 0)) {
496  if ((fr_set_signal(SIGINT, sig_fatal) < 0)
497 #ifdef SIGQUIT
498  || (fr_set_signal(SIGQUIT, sig_fatal) < 0)
499 #endif
500  ) {
501  ERROR("%s", fr_strerror());
502  exit(EXIT_FAILURE);
503  }
504  }
505 
506  /*
507  * Everything seems to have loaded OK, exit gracefully.
508  */
509  if (check_config) {
510  DEBUG("Configuration appears to be OK");
511 
512  /* for -C -m|-M */
513  if (main_config.debug_memory) goto cleanup;
514 
515  exit(EXIT_SUCCESS);
516  }
517 
518  /*
519  * Now that we've set everything up, we can install the signal
520  * handlers. Before this, if we get any signal, we don't know
521  * what to do, so we might as well do the default, and die.
522  */
523 #ifdef SIGPIPE
524  signal(SIGPIPE, SIG_IGN);
525 #endif
526 
527  if ((fr_set_signal(SIGHUP, sig_hup) < 0) ||
528  (fr_set_signal(SIGTERM, sig_fatal) < 0)) {
529  ERROR("%s", fr_strerror());
530  exit(EXIT_FAILURE);
531  }
532 
533 #ifdef WITH_STATS
535 #endif
536 
537  /*
538  * Write the PID after we've forked, so that we write the correct one.
539  */
540  if (main_config.write_pid) {
541  FILE *fp;
542 
543  fp = fopen(main_config.pid_file, "w");
544  if (fp != NULL) {
545  /*
546  * @fixme What about following symlinks,
547  * and having it over-write a normal file?
548  */
549  fprintf(fp, "%d\n", (int) radius_pid);
550  fclose(fp);
551  } else {
552  ERROR("Failed creating PID file %s: %s", main_config.pid_file, fr_syserror(errno));
553  exit(EXIT_FAILURE);
554  }
555  }
556 
557  exec_trigger(NULL, NULL, "server.start", false);
558 
559  /*
560  * Inform the parent (who should still be waiting) that the rest of
561  * initialisation went OK, and that it should exit with a 0 status.
562  * If we don't get this far, then we just close the pipe on exit, and the
563  * parent gets a read failure.
564  */
565  if (main_config.daemonize) {
566  if (write(from_child[1], "\001", 1) < 0) {
567  WARN("Failed informing parent of successful start: %s",
568  fr_syserror(errno));
569  }
570  close(from_child[1]);
571  }
572 
573  /*
574  * Clear the libfreeradius error buffer.
575  */
576  fr_strerror();
577 
578  /*
579  * Initialise the state rbtree (used to link multiple rounds of challenges).
580  */
582 
583  /*
584  * Process requests until HUP or exit.
585  */
586  while ((status = radius_event_process()) == 0x80) {
587 #ifdef WITH_STATS
589 #endif
590  main_config_hup();
591  }
592 
593  if (status < 0) {
594  ERROR("Exiting due to internal error: %s", fr_strerror());
595  rcode = EXIT_FAILURE;
596  } else {
597  INFO("Exiting normally");
598  rcode = EXIT_SUCCESS;
599  }
600 
601  /*
602  * Ignore the TERM signal: we're about to die.
603  */
604  signal(SIGTERM, SIG_IGN);
605 
606  /*
607  * Fire signal and stop triggers after ignoring SIGTERM, so handlers are
608  * not killed with the rest of the process group, below.
609  */
610  if (status == 2) exec_trigger(NULL, NULL, "server.signal.term", true);
611  exec_trigger(NULL, NULL, "server.stop", false);
612 
613  /*
614  * Send a TERM signal to all associated processes
615  * (including us, which gets ignored.)
616  */
617 #ifndef __MINGW32__
618  if (main_config.spawn_workers) kill(-radius_pid, SIGTERM);
619 #endif
620 
621  /*
622  * We're exiting, so we can delete the PID file.
623  * (If it doesn't exist, we can ignore the error returned by unlink)
624  */
626 
627  /*
628  * Free memory in an explicit and consistent order
629  *
630  * We could let everything be freed by the autofree
631  * context, but in some cases there are odd interactions
632  * with destructors that may cause double frees and
633  * SEGVs.
634  */
635  radius_event_free(); /* Free the requests */
636 
637 #ifdef HAVE_PTHREAD_H
638  thread_pool_stop(); /* stop all the threads */
639 #endif
640 
641  talloc_free(global_state); /* Free state entries */
642 
643 cleanup:
644  map_proc_free(); /* Free map processors */
645  main_config_free(); /* Free the main config */
646 
647  modules_free(); /* Detach any modules (and their connection pools) */
648  xlat_free(); /* modules may have xlat's */
649 
650 #ifdef WIN32
651  WSACleanup();
652 #endif
653 
654 #ifdef HAVE_OPENSSL_CRYPTO_H
655  tls_global_cleanup(); /* Cleanup any memory malloced by OpenSSL and placed into globals */
656 #endif
657  talloc_free(autofree); /* Cleanup everything else */
658 
659  /*
660  * Anything not cleaned up by the above is allocated in the NULL
661  * top level context, and is likely leaked memory.
662  */
664 
665  return rcode;
666 }
667 
668 
669 /*
670  * Display the syntax for starting this program.
671  */
672 static void NEVER_RETURNS usage(int status)
673 {
674  FILE *output = status?stderr:stdout;
675 
676  fprintf(output, "Usage: %s [options]\n", main_config.name);
677  fprintf(output, "Options:\n");
678  fprintf(output, " -C Check configuration and exit.\n");
679  fprintf(stderr, " -d <raddb> Set configuration directory (defaults to " RADDBDIR ").\n");
680  fprintf(stderr, " -D <dictdir> Set main dictionary directory (defaults to " DICTDIR ").\n");
681  fprintf(output, " -f Run as a foreground process, not a daemon.\n");
682  fprintf(output, " -h Print this help message.\n");
683  fprintf(output, " -l <log_file> Logging output will be written to this file.\n");
684  fprintf(output, " -m On SIGINT or SIGQUIT clean up all used memory instead of just exiting.\n");
685  fprintf(output, " -n <name> Read raddb/name.conf instead of raddb/radiusd.conf.\n");
686  fprintf(output, " -P Always write out PID, even with -f.\n");
687  fprintf(output, " -s Do not spawn child processes to handle requests (same as -ft).\n");
688  fprintf(output, " -t Disable threads.\n");
689  fprintf(output, " -v Print server version information.\n");
690  fprintf(output, " -X Turn on full debugging (similar to -tfxxl stdout).\n");
691  fprintf(output, " -x Turn on additional debugging (-xx gives more debugging).\n");
692  exit(status);
693 }
694 
695 
696 /*
697  * We got a fatal signal.
698  */
699 static void sig_fatal(int sig)
700 {
701  if (getpid() != radius_pid) _exit(sig);
702 
703  switch (sig) {
704  case SIGTERM:
706  break;
707 
708  case SIGINT:
709 #ifdef SIGQUIT
710  case SIGQUIT:
711 #endif
714  break;
715  }
716  /* FALL-THROUGH */
717 
718  default:
719  fr_exit(sig);
720  }
721 }
722 
723 #ifdef SIGHUP
724 /*
725  * We got the hangup signal.
726  * Re-read the configuration files.
727  */
728 static void sig_hup(UNUSED int sig)
729 {
730  reset_signal(SIGHUP, sig_hup);
731 
733 }
734 #endif
char const * radacct_dir
Definition: radiusd.c:58
FILE * fr_log_fp
Definition: radius.c:81
int ssl_check_consistency(void)
Definition: version.c:184
Main server configuration.
Definition: radiusd.h:108
void exec_trigger(REQUEST *request, CONF_SECTION *cs, char const *name, bool quench) CC_HINT(nonnull(3))
Execute a trigger - call an executable to process an event.
Definition: exec.c:686
static pid_t radius_pid
Definition: radiusd.c:69
int main_config_init(void)
Definition: mainconfig.c:731
void version_print(void)
Definition: version.c:512
bool write_pid
write the PID file
Definition: radiusd.h:167
#define INFO(fmt,...)
Definition: log.h:143
static void sig_fatal(int)
Definition: radiusd.c:699
int virtual_servers_init(CONF_SECTION *config)
Definition: modules.c:1577
bool daemonize
Should the server daemonize on startup.
Definition: radiusd.h:121
int radius_event_start(bool spawn_flag)
Definition: process.c:5317
bool log_stripped_names
Definition: radiusd.c:61
#define UNUSED
Definition: libradius.h:134
int main(int argc, char *argv[])
Definition: radiusd.c:88
int main_config_free(void)
Definition: mainconfig.c:1055
fr_state_tree_t * fr_state_tree_init(TALLOC_CTX *ctx, uint32_t max_sessions, uint32_t timeout)
Initialise a new state tree.
Definition: state.c:156
char const * pid_file
Path to write out PID file.
Definition: radiusd.h:123
fr_log_t default_log
Definition: log.c:216
int fr_log_talloc_report(TALLOC_CTX *ctx)
Generate a talloc memory report for a context and print to stderr/stdout.
Definition: debug.c:810
char const * name
Name of the daemon, usually 'radiusd'.
Definition: radiusd.h:109
char const * log_file
Definition: radiusd.h:139
int virtual_servers_bootstrap(CONF_SECTION *config)
Definition: modules.c:1457
void set_radius_dir(TALLOC_CTX *ctx, char const *path)
Set the global radius config directory.
Definition: mainconfig.c:705
void radius_stats_init(int flag)
Definition: stats.c:831
char const * radlog_dir
Definition: radiusd.c:59
int fr_fault_setup(char const *cmd, char const *program)
Registers signal handlers to execute panic_action on fatal signal.
Definition: debug.c:890
uint32_t continuation_timeout
How long to wait before cleaning up state entries.
Definition: radiusd.h:135
void(*) fr_debug_state_ fr_debug_state)
int modules_init(CONF_SECTION *)
Instantiate the modules.
Definition: modules.c:2064
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
Definition: log.c:238
static void usage(int)
Definition: radiusd.c:672
int fr_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
Definition: version.c:38
#define DEBUG(fmt,...)
Definition: log.h:175
void(*)(int) reset_signal(int signo, void(*func)(int))
Definition: radiusd.h:397
bool debug_memory
Cleanup the server properly on exit, freeing up any memory we allocated.
Definition: radiusd.h:156
void fr_store_debug_state(void)
Should be run before using setuid or setgid to get useful results.
Definition: debug.c:258
void main_config_hup(void)
Definition: mainconfig.c:1134
uint32_t max_requests
Definition: radiusd.h:136
#define STRINGIFY(x)
Definition: build.h:34
void void fr_perror(char const *,...) CC_HINT(format(printf
void thread_pool_stop(void)
static char panic_action[512]
The command to execute when panicking.
Definition: debug.c:92
bool log_auth_goodpass
Log failed authentications.
Definition: radiusd.h:114
bool log_auth
Log authentication attempts.
Definition: radiusd.h:112
bool memory_report
Print a memory report on what's left unfreed.
Definition: radiusd.h:158
int radius_event_init(TALLOC_CTX *ctx)
Definition: process.c:5197
char const * fr_strerror(void)
Get the last library error.
Definition: log.c:212
int radlog_init(fr_log_t *log, bool daemonize)
Initialise file descriptors based on logging destination.
Definition: log.c:257
static bool cleanup
Definition: radsniff.c:53
void xlat_free(void)
De-register all xlat functions, used mainly for debugging.
Definition: xlat.c:1147
Log to a file on disk.
Definition: log.h:59
bool event_loop_started
Whether the main event loop has been started yet.
Definition: mainconfig.c:50
CONF_SECTION * config
Root of the server config.
Definition: radiusd.h:110
log_lvl_t rad_debug_lvl
Global debugging level.
Definition: log.c:49
void radius_signal_self(int flag)
Definition: process.c:5132
int thread_pool_bootstrap(CONF_SECTION *cs, bool *spawn_workers)
char const * radiusd_version
Definition: radiusd.c:63
char const * dictionary_dir
Where to load dictionaries from.
Definition: radiusd.h:142
#define WARN(fmt,...)
Definition: log.h:144
int modules_free(void)
Definition: modules.c:413
int modules_bootstrap(CONF_SECTION *)
Definition: modules.c:1866
void int fr_set_signal(int sig, sig_t func)
Sets a signal handler using sigaction if available, else signal.
Definition: misc.c:56
bool check_config
Definition: conffile.c:45
Discard log messages.
Definition: log.h:63
char const * panic_action
Command to execute if the server receives a fatal signal.
Definition: radiusd.h:150
void map_proc_free(void)
Definition: map_proc.c:113
void fr_talloc_fault_setup(void)
Register talloc fault handlers.
Definition: debug.c:872
bool log_auth_badpass
Log successful authentications.
Definition: radiusd.h:113
char const * fr_debug_state_to_msg(fr_debug_state_t state)
Return current value of debug_state.
Definition: debug.c:278
static TALLOC_CTX * autofree
Definition: radeapclient.c:205
log_dst_t dst
Log destination.
Definition: log.h:72
void radius_event_free(void)
Definition: process.c:5524
#define NEVER_RETURNS
Definition: libradius.h:133
Log to stdout.
Definition: log.h:58
bool spawn_workers
Should the server spawn threads.
Definition: radiusd.h:122
#define RCSID(id)
Definition: build.h:135
char * talloc_typed_strdup(void const *t, char const *p)
Call talloc strdup, setting the type on the new chunk correctly.
Definition: missing.c:588
int fd
File descriptor to write messages to.
Definition: log.h:71
#define fr_exit(_x)
Definition: libradius.h:508
int thread_pool_init(void)
int radius_event_process(void)
Definition: process.c:5581
#define ERROR(fmt,...)
Definition: log.h:145
fr_state_tree_t * global_state
Definition: state.c:87
#define RADIUS_DIR
Definition: conf.h:3
int rad_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
Definition: version.c:208
#define RADIUSD_MAGIC_NUMBER
Definition: libradius.h:51