/* Report internal state on SIGUSR1. */ static void report (void) { FILE *rfp, *old; mode_t old_umask; old_umask = umask (S_IRWXG | S_IRWXO); rfp = monitor_fopen (report_file, "w"); umask (old_umask); if (!rfp) { log_error ("fopen (\"%s\", \"w\") failed", report_file); return; } /* Divert the log channel to the report file during the report. */ old = log_current (); log_to (rfp); ui_report ("r"); log_to (old); fclose (rfp); sigusr1ed = 0; }
/* * Call the relevant command handler based on the first character of the * line (the command). */ static void ui_handle_command(char *line) { /* Find out what one-letter command was sent. */ switch (line[0]) { case 'c': ui_connect(line); break; case 'C': ui_config(line); break; case 'd': ui_delete(line); break; case 'D': ui_debug(line); break; case 'M': ui_setmode(line); break; case 'p': ui_packetlog(line); break; case 'Q': ui_shutdown_daemon(line); break; case 'R': reinit(); break; case 'S': ui_report_sa(line); break; case 'r': ui_report(line); break; case 't': ui_teardown(line); break; case 'T': ui_teardown_all(line); break; default: log_print("ui_handle_messages: unrecognized command: '%c'", line[0]); } }