static void parse_request(rb_helper *helper) { int len; static char *parv[MAXPARA + 1]; int parc; while((len = rb_helper_read(helper, readBuf, sizeof(readBuf))) > 0) { parc = rb_string_to_array(readBuf, parv, MAXPARA); switch (*parv[0]) { case 'I': if(parc != 4) abort(); resolve_ip(parv); break; case 'H': if(parc != 4) abort(); resolve_host(parv); break; case 'B': if(parc != 4) abort(); set_bind(parv); break; case 'R': restart_resolver(); report_nameservers(); break; default: break; } } }
static void check_rehash(void *unused) { if(do_rehash) { restart_resolver(); do_rehash = 0; report_nameservers(); } }
/*! \brief REHASH DNS handler * Attempts to restart server's resolver * \param source_p Pointer to client issuing the command */ static void rehash_dns(struct Client *source_p) { 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)); ilog(LOG_TYPE_IRCD, "REHASH DNS from %s", get_oper_name(source_p)); restart_resolver(); }
/*! \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; }
/** Create a DNS request record for the server. * @param[in] query Callback information for caller. * @return Newly allocated and linked-in reslist. */ static struct reslist * make_request(dns_callback_f callback, void *ctx) { struct reslist *request; if (!resolver_started()) restart_resolver(); request = (struct reslist *)MyMalloc(sizeof(struct reslist)); memset(request, 0, sizeof(struct reslist)); request->state = REQ_IDLE; request->sentat = CurrentTime; request->retries = feature_int(FEAT_IRCD_RES_RETRIES); request->resend = 1; request->timeout = feature_int(FEAT_IRCD_RES_TIMEOUT); memset(&request->addr, 0, sizeof(request->addr)); request->callback = callback; request->callback_ctx = ctx; add_dlink(&request->node, &request_list); return(request); }
/* * mo_rehash - REHASH message handler * */ static void mo_rehash(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { int found = NO; if ( !IsOperRehash(source_p) ) { sendto_one(source_p,":%s NOTICE %s :You need rehash = yes;", me.name, parv[0]); return; } if (parc > 1) { if (irccmp(parv[1],"CHANNELS") == 0) { sendto_realops_flags(FLAGS_ALL, L_ALL, "%s is forcing cleanup of channels",parv[0]); cleanup_channels(NULL); found = YES; } else if(irccmp(parv[1],"DNS") == 0) { sendto_one(source_p, form_str(RPL_REHASHING), me.name, parv[0], "DNS"); sendto_realops_flags(FLAGS_ALL, L_ALL,"%s is rehashing DNS", get_oper_name(source_p)); restart_resolver(); /* re-read /etc/resolv.conf AGAIN? and close/re-open res socket */ found = YES; } else if(irccmp(parv[1],"MOTD") == 0) { sendto_realops_flags(FLAGS_ALL, L_ALL, "%s is forcing re-reading of MOTD file", get_oper_name(source_p)); ReadMessageFile( &ConfigFileEntry.motd ); found = YES; } else if(irccmp(parv[1],"OMOTD") == 0) { sendto_realops_flags(FLAGS_ALL, L_ALL, "%s is forcing re-reading of OPER MOTD file", get_oper_name(source_p)); ReadMessageFile( &ConfigFileEntry.opermotd ); found = YES; } if(found) { ilog(L_NOTICE, "REHASH %s From %s\n", parv[1], get_client_name(source_p, HIDE_IP)); return; } else { sendto_one(source_p,":%s NOTICE %s :rehash one of :CHANNELS DNS MOTD OMOTD" ,me.name,source_p->name); return; } } else { sendto_one(source_p, form_str(RPL_REHASHING), me.name, parv[0], ConfigFileEntry.configfile); sendto_realops_flags(FLAGS_ALL, L_ALL, "%s is rehashing server config file", get_oper_name(source_p)); ilog(L_NOTICE, "REHASH From %s[%s]", get_oper_name(source_p), source_p->localClient->sockhost); rehash(0); return; } }
void reload_nameservers(const char letter) { /* Not a whole lot to it */ restart_resolver(); }
/* * mo_rehash - REHASH message handler * */ static void mo_rehash(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { int found = 0; if (!IsOperRehash(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, source_p->name); return; } if (parc > 1) { if (irccmp(parv[1], "DNS") == 0) { sendto_one(source_p, form_str(RPL_REHASHING), me.name, parv[0], "DNS"); sendto_realops_flags(UMODE_ALL, L_ALL, "%s is rehashing DNS", get_oper_name(source_p)); restart_resolver(); /* re-read /etc/resolv.conf AGAIN? and close/re-open res socket */ found = 1; } else if (irccmp(parv[1], "MOTD") == 0) { sendto_realops_flags(UMODE_ALL, L_ALL, "%s is forcing re-reading of MOTD file", get_oper_name(source_p)); read_message_file(&ConfigFileEntry.motd); found = 1; } else if (irccmp(parv[1], "OMOTD") == 0) { sendto_realops_flags(UMODE_ALL, L_ALL, "%s is forcing re-reading of OPER MOTD file", get_oper_name(source_p)); read_message_file(&ConfigFileEntry.opermotd); found = 1; } if (found) { ilog(L_NOTICE, "REHASH %s From %s", parv[1], get_client_name(source_p, HIDE_IP)); return; } else { sendto_one(source_p, ":%s NOTICE %s :rehash one of :DNS MOTD OMOTD", me.name, source_p->name); return; } } else { sendto_one(source_p, form_str(RPL_REHASHING), me.name, source_p->name, ConfigFileEntry.configfile); sendto_realops_flags(UMODE_ALL, L_ALL, "%s is rehashing server config file", get_oper_name(source_p)); ilog(L_NOTICE, "REHASH From %s[%s]", get_oper_name(source_p), source_p->localClient->sockhost); rehash(0); } }
/** Reload the configuration file. * @param cptr Client that requested rehash (if a signal, &me). * @param sig Type of rehash (0 = oper-requested, 1 = signal, 2 = * oper-requested but do not restart resolver) * @return CPTR_KILLED if any client was K/G-lined because of the * rehash; otherwise 0. */ int rehash(struct Client *cptr, int sig) { struct ConfItem** tmp = &GlobalConfList; struct ConfItem* tmp2; struct Client* acptr; int i; int ret = 0; int found_g = 0; if (1 == sig) sendto_opmask_butone(0, SNO_OLDSNO, "Got signal SIGHUP, reloading ircd conf. file"); while ((tmp2 = *tmp)) { if (tmp2->clients) { /* * Configuration entry is still in use by some * local clients, cannot delete it--mark it so * that it will be deleted when the last client * exits... */ if (CONF_CLIENT == (tmp2->status & CONF_CLIENT)) tmp = &tmp2->next; else { *tmp = tmp2->next; tmp2->next = 0; } tmp2->status |= CONF_ILLEGAL; } else { *tmp = tmp2->next; free_conf(tmp2); } } conf_erase_crule_list(); conf_erase_deny_list(); conf_erase_webirc_list(); conf_erase_shost_list(); conf_erase_except_list(); motd_clear(); /* * delete the juped nicks list */ clearNickJupes(); clear_quarantines(); class_mark_delete(); mark_listeners_closing(); auth_mark_closing(); close_mappings(); read_configuration_file(); if (sig != 2) restart_resolver(); log_reopen(); /* reopen log files */ auth_close_unused(); close_listeners(); class_delete_marked(); /* unless it fails */ /* * Flush out deleted I and P lines although still in use. */ for (tmp = &GlobalConfList; (tmp2 = *tmp);) { if (CONF_ILLEGAL == (tmp2->status & CONF_ILLEGAL)) { *tmp = tmp2->next; tmp2->next = NULL; if (!tmp2->clients) free_conf(tmp2); } else tmp = &tmp2->next; } for (i = 0; i <= HighestFd; i++) { if ((acptr = LocalClientArray[i])) { assert(!IsMe(acptr)); if (IsServer(acptr)) det_confs_butmask(acptr, ~(CONF_UWORLD | CONF_ILLEGAL)); /* Because admin's are getting so uppity about people managing to * get past K/G's etc, we'll "fix" the bug by actually explaining * whats going on. */ if ((found_g = find_kill(acptr))) { sendto_opmask_butone(0, found_g > -1 ? SNO_GLINE : SNO_OPERKILL, found_g == -2 ? "G-line active for %s%s" : (found_g == -3 ? "Z-line active for %s%s" : "K-line active for %s%s"), IsUnknown(acptr) ? "Unregistered Client ":"", get_client_name(acptr, SHOW_IP)); if (exit_client(cptr, acptr, &me, found_g == -2 ? "G-lined" : (found_g == -3 ? "Z-lined" : "K-lined")) == CPTR_KILLED) ret = CPTR_KILLED; } } } attach_conf_uworld(&me); geoip_init(); auth_send_event("rehash", NULL); return ret; }