/*! \brief REHASH CONF handler * Attempts to reload server's configuration file(s) * \param source_p Pointer to client issuing the command */ static void rehash_conf(struct Client *source_p) { sendto_one_numeric(source_p, &me, RPL_REHASHING, "CONF"); sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "%s is rehashing configuration file(s)", get_oper_name(source_p)); ilog(LOG_TYPE_IRCD, "REHASH CONF from %s", get_oper_name(source_p)); conf_rehash(0); }
/*! \brief REHASH command handler * * \param source_p Pointer to allocated Client struct from which the message * originally comes from. This can be a local or remote client. * \param parc Integer holding the number of supplied arguments. * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL * pointers. * \note Valid arguments for this command are: * - parv[0] = command * - parv[1] = additional option */ static int mo_rehash(struct Client *source_p, int parc, char *parv[]) { int found = 0; const char *const option = parv[1]; if (!HasOFlag(source_p, OPER_FLAG_REHASH)) { sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "rehash"); return 0; } if (!EmptyString(option)) { if (!irccmp(option, "DNS")) { sendto_one_numeric(source_p, &me, RPL_REHASHING, "DNS"); sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "%s is rehashing DNS", get_oper_name(source_p)); restart_resolver(); found = 1; } else if (!irccmp(option, "MOTD")) { sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "%s is forcing re-reading of MOTD files", get_oper_name(source_p)); motd_recache(); found = 1; } if (found) ilog(LOG_TYPE_IRCD, "REHASH %s From %s", option, get_oper_name(source_p)); else sendto_one_notice(source_p, &me, ":%s is not a valid option. " "Choose from DNS, MOTD", option); } else { sendto_one_numeric(source_p, &me, RPL_REHASHING, ConfigGeneral.configfile); sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "%s is rehashing configuration file(s)", get_oper_name(source_p)); ilog(LOG_TYPE_IRCD, "REHASH From %s", get_oper_name(source_p)); conf_rehash(0); } return 0; }
/* REHASH */ void os_cmd_rehash(sourceinfo_t *si, int parc, char *parv[]) { slog(LG_INFO, "UPDATE (due to REHASH): \2%s\2", get_oper_name(si)); wallops("Updating database by request of \2%s\2.", get_oper_name(si)); expire_check(NULL); if (db_save) db_save(NULL, DB_SAVE_BG_IMPORTANT); logcommand(si, CMDLOG_ADMIN, "REHASH"); wallops("Rehashing \2%s\2 by request of \2%s\2.", config_file, get_oper_name(si)); if (conf_rehash()) command_success_nodata(si, _("REHASH completed.")); else command_fail(si, fault_nosuch_target, _("REHASH of \2%s\2 failed. Please correct any errors in the file and try again."), config_file); }
static void os_cmd_modload(sourceinfo_t *si, int parc, char *parv[]) { char *module; module_t *m; int i; if (parc < 1) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MODLOAD"); command_fail(si, fault_needmoreparams, _("Syntax: MODLOAD <module...>")); return; } i = 0; while (i < parc) { module = parv[i++]; if (module_find_published(module)) { command_fail(si, fault_nochange, _("\2%s\2 is already loaded."), module); continue; } logcommand(si, CMDLOG_ADMIN, "MODLOAD: \2%s\2", module); m = module_load(module); if (m != NULL) command_success_nodata(si, _("Module \2%s\2 loaded."), module); else command_fail(si, fault_nosuch_target, _("Module \2%s\2 failed to load."), module); } if (conf_need_rehash) { logcommand(si, CMDLOG_ADMIN, "REHASH (MODLOAD)"); wallops("Rehashing \2%s\2 to complete module load by request of \2%s\2.", config_file, get_oper_name(si)); if (!conf_rehash()) command_fail(si, fault_nosuch_target, _("REHASH of \2%s\2 failed. Please correct any errors in the file and try again."), config_file); } }
void set_time(void) { struct timeval newtime = { .tv_sec = 0, .tv_usec = 0 }; if (gettimeofday(&newtime, NULL) == -1) { ilog(LOG_TYPE_IRCD, "Clock Failure (%s), TS can be corrupted", strerror(errno)); sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "Clock Failure (%s), TS can be corrupted", strerror(errno)); server_die("Clock Failure", 1); } if (newtime.tv_sec < CurrentTime) { ilog(LOG_TYPE_IRCD, "System clock is running backwards - (%lu < %lu)", (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, "System clock is running backwards - (%lu < %lu)", (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); set_back_events(CurrentTime - newtime.tv_sec); } SystemTime.tv_sec = newtime.tv_sec; SystemTime.tv_usec = newtime.tv_usec; } static void io_loop(void) { while (1) { if (listing_client_list.head) { dlink_node *node = NULL, *node_next = NULL; DLINK_FOREACH_SAFE(node, node_next, listing_client_list.head) safe_list_channels(node->data, 0); } /* Run pending events */ event_run(); comm_select(); exit_aborted_clients(); free_exited_clients(); /* Check to see whether we have to rehash the configuration .. */ if (dorehash) { conf_rehash(1); dorehash = 0; } if (doremotd) { motd_recache(); sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "Got signal SIGUSR1, reloading motd file(s)"); doremotd = 0; } } } /* initalialize_global_set_options() * * inputs - none * output - none * side effects - This sets all global set options needed */ static void initialize_global_set_options(void) { GlobalSetOptions.maxclients = ConfigServerInfo.default_max_clients; GlobalSetOptions.autoconn = 1; GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME; GlobalSetOptions.spam_num = MAX_JOIN_LEAVE_COUNT; GlobalSetOptions.floodcount = ConfigGeneral.default_floodcount; GlobalSetOptions.joinfloodcount = ConfigChannel.default_join_flood_count; GlobalSetOptions.joinfloodtime = ConfigChannel.default_join_flood_time; split_servers = ConfigChannel.default_split_server_count; split_users = ConfigChannel.default_split_user_count; if (split_users && split_servers && (ConfigChannel.no_create_on_split || ConfigChannel.no_join_on_split)) { splitmode = 1; splitchecking = 1; } GlobalSetOptions.ident_timeout = IDENT_TIMEOUT; }