int ircncmp (const char *s1, const char *s2, int n) { const unsigned char *str1 = (const unsigned char *) s1; const unsigned char *str2 = (const unsigned char *) s2; if (!s1 || !s2) { sendto_realops ("ircncmp called with s1=%s s2=%s", s1 ? s1 : "(NULL)", s2 ? s2 : "NULL"); sendto_realops ("Please report to the development team! [email protected]"); return 1; } while (touppertab[*str1] == touppertab[*str2]) { str1++; str2++; n--; if (n == 0 || (*str1 == '\0' && *str2 == '\0')) return 0; } return 1; }
/* * irccmp_lex - case insensitive comparison of two 0 terminated strings. * * returns 0, if s1 equal to s2 * <0, if s1 lexicographically less than s2 * >0, if s1 lexicographically greater than s2 */ int irccmp_lex (const char *s1, const char *s2) { const unsigned char *str1 = (const unsigned char *) s1; const unsigned char *str2 = (const unsigned char *) s2; int res; if (!s1 || !s2) { sendto_realops ("irccmp_lex called with s1=%s s2=%s", s1 ? s1 : "(NULL)", s2 ? s2 : "NULL"); sendto_realops ("Please report to the development team! [email protected]"); return 1; } /* * More often than not we wont have to bother about case * so lets not waste cycles on touppertab and looping */ if (s1 == s2) { return 0; } while ((res = touppertab[*str1] - touppertab[*str2]) == 0) { if (*str1 == '\0') return 0; str1++; str2++; } return (res); }
/* Called when module is unloaded */ DLLFUNC int MOD_UNLOAD(m_pingpong)(int module_unload) { if (del_Command(MSG_PING, TOK_PING, m_ping) < 0) { sendto_realops("Failed to delete command ping when unloading %s", MOD_HEADER(m_pingpong).name); } if (del_Command(MSG_PONG, TOK_PONG, m_pong) < 0) { sendto_realops("Failed to delete command pong when unloading %s", MOD_HEADER(m_pingpong).name); } return MOD_SUCCESS; }
/* ** zip_buffer ** Zip the content of cptr->zip->outbuf and of the buffer, ** put anything left in cptr->zip->outbuf, update cptr->zip->outcount ** ** if flush is set, then all available data will be compressed, ** otherwise, compression only occurs if there's enough to compress, ** or if we are reaching the maximum allowed size during a connect burst. ** ** will return the uncompressed buffer, length will be updated. ** if a fatal error occurs, length will be set to -1 */ char *zip_buffer(aClient *cptr, char *buffer, int *length, int flush) { z_stream *zout = cptr->zip->out; int r; if (buffer) { /* concatenate buffer in cptr->zip->outbuf */ memcpy((void *)(cptr->zip->outbuf + cptr->zip->outcount), (void *)buffer, *length ); cptr->zip->outcount += *length; } *length = 0; #if 0 if (!flush && ((cptr->zip->outcount < ZIP_MINIMUM) || ((cptr->zip->outcount < (ZIP_MAXIMUM - BUFSIZE)) && CBurst(cptr)))) /* Implement this? more efficient? or not? -- Syzop */ #else if (!flush && (cptr->zip->outcount < ZIP_MINIMUM)) #endif return((char *)NULL); zout->next_in = (Bytef *) cptr->zip->outbuf; zout->avail_in = cptr->zip->outcount; zout->next_out = (Bytef *) zipbuf; zout->avail_out = ZIP_BUFFER_SIZE; switch (r = deflate(zout, Z_PARTIAL_FLUSH)) { case Z_OK: if (zout->avail_in) { /* can this occur?? I hope not... */ sendto_realops("deflate() didn't process all available data!"); } cptr->zip->outcount = 0; *length = ZIP_BUFFER_SIZE - zout->avail_out; return zipbuf; default: /* error ! */ sendto_realops("deflate() error(%d): %s", r, (zout->msg) ? zout->msg : "?"); *length = -1; break; } return((char *)NULL); }
/* Called when module is unloaded */ DLLFUNC int MOD_UNLOAD(m_sendumode)(int module_unload) { if (del_Command(MSG_SENDUMODE, TOK_SENDUMODE, m_sendumode) < 0) { sendto_realops("Failed to delete command sendumode when unloading %s", MOD_HEADER(m_sendumode).name); } if (del_Command(MSG_SMO, TOK_SMO, m_sendumode) < 0) { sendto_realops("Failed to delete command smo when unloading %s", MOD_HEADER(m_sendumode).name); } return MOD_SUCCESS; }
/* This is called on module init, before Server Ready */ DLLFUNC int MOD_INIT(m_dummy)(ModuleInfo *modinfo) { CmodeInfo req; ircd_log(LOG_ERROR, "debug: mod_init called from chmodetst module"); ModuleSetOptions(modinfo->handle, MOD_OPT_PERM); sendto_realops("chmodetst loading..."); /* TODO: load mode here */ /* +w doesn't do anything, it's just for testing */ memset(&req, 0, sizeof(req)); req.paracount = 0; req.is_ok = extcmode_default_requirechop; req.flag = 'w'; ModeTest = CmodeAdd(modinfo->handle, req, &EXTCMODE_TEST); /* +y doesn't do anything except that you can set/unset it with a * numeric parameter (1-100) */ memset(&req, 0, sizeof(req)); req.paracount = 1; req.is_ok = modey_is_ok; req.put_param = modey_put_param; req.get_param = modey_get_param; req.conv_param = modey_conv_param; req.free_param = modey_free_param; req.sjoin_check = modey_sjoin_check; req.dup_struct = modey_dup_struct; req.flag = 'y'; ModeTest2 = CmodeAdd(modinfo->handle, req, &EXTCMODE_TEST2); return MOD_SUCCESS; }
/* * m_svinfo - SVINFO message handler * parv[0] = sender prefix * parv[1] = TS_CURRENT for the server * parv[2] = TS_MIN for the server * parv[3] = clock ts */ int m_svinfo(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) { aConfItem *aconf; time_t remote_ts = 0; struct Client *acptr; if (MyConnect(sptr) && IsUnknown(sptr)) return exit_client(sptr, sptr, sptr, "Need SERVER before SVINFO"); if (!IsServer(sptr) || !MyConnect(sptr) || parc < 3) return 0; if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN) { /* * a server with the wrong TS version connected; since we're * TS_ONLY we can't fall back to the non-TS protocol so * we drop the link -orabidoo */ #ifdef HIDE_SERVERS_IPS sendto_realops("Link %s dropped, incompatible TS protocol version (%s,%s)", get_client_name(sptr,MASK_IP), parv[1], parv[2]); #else sendto_realops("Link %s dropped, incompatible TS protocol version (%s,%s)", get_client_name(sptr, TRUE), parv[1], parv[2]); #endif return exit_client(sptr, sptr, sptr, "Incompatible TS version"); } if(parc>3) { remote_ts = atol(parv[3]); if (UseIRCNTP && (remote_ts > 0)) { if(IsService(cptr) || ((aconf = find_conf_host(cptr->confs, sptr->name, CONF_HUB)) && !(acptr = find_server(ServicesServer)))) { ircntp_offset = remote_ts - time(NULL); sendto_realops("Adjusting IRCNTP offset to %d", ircntp_offset); } } } return 0; }
DLLFUNC int MOD_UNLOAD(m_restrictcolors)(int module_unload) { HookDel(CheckMsg); CmodeDel(ModeRcolors); ircd_log(LOG_ERROR, "debug: mod_unload called from m_restrictcolors"); sendto_realops("unloading m_restrictcolors"); return MOD_SUCCESS; }
DLLFUNC int MOD_UNLOAD(m_addmotd)(int module_unload) { if (del_Command(MSG_ADDMOTD, TOK_ADDMOTD, m_addmotd) < 0) { sendto_realops("Failed to delete commands when unloading %s", MOD_HEADER(m_addmotd).name); } return MOD_SUCCESS; }
DLLFUNC int MOD_UNLOAD(m_svssno)(int module_unload) { if (del_Command(MSG_SVSSNO, TOK_SVSSNO, m_svssno) < 0 || del_Command(MSG_SVS2SNO, TOK_SVS2SNO, m_svs2sno) < 0) { sendto_realops("Failed to delete commands when unloading %s", MOD_HEADER(m_svssno).name); } return MOD_SUCCESS; }
/* Called when module is unloaded */ DLLFUNC int MOD_UNLOAD(m_dummy)(int module_unload) { if (del_Command(MSG_DUMMY, TOK_DUMMY, m_dummy) < 0) { sendto_realops("Failed to delete commands when unloading %s", MOD_HEADER(m_dummy).name); } return MOD_SUCCESS; }
/* Called when module is unloaded */ DLLFUNC int MOD_UNLOAD(m_rakill)(int module_unload) { if (del_Command(MSG_RAKILL, TOK_RAKILL, m_rakill) < 0) { sendto_realops("Failed to delete commands when unloading %s", MOD_HEADER(m_rakill).name); } return MOD_SUCCESS; }
DLLFUNC int MOD_UNLOAD(m_chgident)(int module_unload) { if (del_Command(MSG_CHGIDENT, TOK_CHGIDENT, m_chgident) < 0) { sendto_realops("Failed to delete commands when unloading %s", MOD_HEADER(m_chgident).name); } return MOD_SUCCESS; }
/* Called when module is unloaded */ DLLFUNC int MOD_UNLOAD(m_unsqline)(int module_unload) { if (del_Command(MSG_UNSQLINE, TOK_UNSQLINE, m_unsqline) < 0) { sendto_realops("Failed to delete commands when unloading %s", MOD_HEADER(m_unsqline).name); } return MOD_SUCCESS; }
DLLFUNC int MOD_UNLOAD(m_userhost)(int module_unload) { if (del_Command(MSG_USERHOST, TOK_USERHOST, m_userhost) < 0) { sendto_realops("Failed to delete commands when unloading %s", MOD_HEADER(m_userhost).name); } return MOD_SUCCESS; }
DLLFUNC int MOD_UNLOAD(m_locops)(int module_unload) { if (del_Command(MSG_LOCOPS, TOK_LOCOPS, m_locops) < 0) { sendto_realops("Failed to delete commands when unloading %s", MOD_HEADER(m_locops).name); } return MOD_SUCCESS; }
/* Called when module is unloaded */ DLLFUNC int MOD_UNLOAD(m_svsjoin)(int module_unload) { if (del_Command(MSG_SVSJOIN, TOK_SVSJOIN, m_svsjoin) < 0) { sendto_realops("Failed to delete commands when unloading %s", MOD_HEADER(m_svsjoin).name); } return MOD_SUCCESS; }
/* ** m_sanick() - PID - 08-08-2011 ** ** parv[0] - sender ** parv[1] - nick to make join ** parv[2] - channel(s) to join */ int m_sanick(aClient * cptr, aClient * sptr, int parc, char *parv[]) { aClient *acptr; char *param[3]; int self = 0; // if (IsServer(sptr) || IsServices(sptr)) // return 0; //Servers and Services should be invoking SVSNICK directly... if (!IsOper(sptr) && !IsAdmin(sptr) && !IsULine(sptr)) { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); return 0; } if (parv[1] == NULL || !parv[1] || !parv[2]) { sendnotice(sptr, "*** Usage: \2/sanick oldnick newnick\2"); return 0; } if (parv[2] == NULL || !(acptr = find_person(parv[1], NULL))) { sendnotice(sptr, "*** No such user, %s.", parv[1]); return 0; } if (!strcmp(parv[2], parv[1]) || !strcmp(parv[2], parv[0])) { sendnotice(sptr, "*** Perhaps I should warn people that they have given an idiot IRCOp access?"); return 0; } if (!strcmp(parv[0], parv[1])) self = 1; if (find_client(parv[2], NULL)) { sendnotice(sptr, "*** WARNING: User %s already exists!", parv[2]); return 0; } if(acptr->umodes & UMODE_REGNICK) acptr->umodes &= ~UMODE_REGNICK; param[0] = acptr->name; param[1] = parv[2]; param[2] = NULL; sendnotice(acptr, "*** You were forced to change your nick to %s", parv[2]); do_cmd(acptr, acptr, "NICK", 2, param); if(self) { sendto_realops("%s used \2SANICK\2 to change their nick to %s.", parv[1], parv[2]); ircd_log(LOG_SACMDS,"SANICK: %s used SANICK to change their nick to %s", parv[1], parv[2]); } else { sendto_realops("%s used \2SANICK\2 to make %s change their nick to %s.", parv[0], parv[1], parv[2]); ircd_log(LOG_SACMDS,"SANICK: %s used SANICK to make %s change their nick to %s", acptr->name, parv[1], parv[2]); } return 0; }
DLLFUNC int MOD_LOAD(m_listreg)(int module_load) { listreg_override = CmdoverrideAdd(m_listreg_modinfo->handle, MSG_LIST, listreg); if (!listreg_override) { sendto_realops("m_listreg: Failed to allocate override: %s", ModuleGetErrorStr(m_listreg_modinfo->handle)); return MOD_FAILED; } return MOD_SUCCESS; }
void confparse_error(char *problem, int line) { if(!forked) printf("ERROR: %s near line %d of %s\n", problem, line, current_file); else sendto_realops("Conf Error: %s near line %d of %s", problem, line, current_file); return; }
DLLFUNC int MOD_LOAD(delaylist)(int module_load) { delaylist_override = CmdoverrideAdd(delaylist_modinfo->handle, MSG_LIST, m_delaylist); if (!delaylist_override) { sendto_realops("delaylist: Failed to allocate override: %s", ModuleGetErrorStr(delaylist_modinfo->handle)); return MOD_FAILED; } return MOD_SUCCESS; }
int m_rawto_Unload(int module_unload) #endif { if (del_Command(MSG_RAWTO, TOK_RAWTO, m_rawto) < 0) { sendto_realops("Failed to delete commands when unloading %s", m_rawto_Header.name); } tainted--; return MOD_SUCCESS; }
static DOMAIN_PIECE *find_or_add_host_piece(DOMAIN_LEVEL *level_ptr, int flags,char *host_piece) { DOMAIN_PIECE *piece_ptr; DOMAIN_PIECE *cur_piece; DOMAIN_PIECE *new_ptr; DOMAIN_PIECE *last_ptr; DOMAIN_PIECE *ptr; int index; index = *host_piece&(MAX_PIECE_LIST-1); piece_ptr = level_ptr->piece_list[index]; if(piece_ptr == (DOMAIN_PIECE *)NULL) { cur_piece = (DOMAIN_PIECE *)MyMalloc(sizeof(DOMAIN_PIECE)); memset((void *)cur_piece,0,sizeof(DOMAIN_PIECE)); DupString(cur_piece->host_piece,host_piece); level_ptr->piece_list[index] = cur_piece; cur_piece->flags |= flags; return(cur_piece); } last_ptr = (DOMAIN_PIECE *)NULL; for(ptr=piece_ptr; ptr; ptr = ptr->next_piece) { if(!strcasecmp(ptr->host_piece,host_piece)) { ptr->flags |= flags; return(ptr); } last_ptr = ptr; } if(last_ptr) { new_ptr = (DOMAIN_PIECE *)MyMalloc(sizeof(DOMAIN_PIECE)); memset((void *)new_ptr,0,sizeof(DOMAIN_PIECE)); DupString(new_ptr->host_piece,host_piece); last_ptr->next_piece = new_ptr; new_ptr->flags |= flags; return(new_ptr); } else { sendto_realops("Bug: in find_or_add_host_piece. yay."); return(NULL); } /* NOT REACHED */ }
/* ** m_join ** parv[0] = sender prefix ** parv[1] = channel ** parv[2] = channel password (key) */ DLLFUNC CMD_FUNC(m_join) { int r; if (bouncedtimes) sendto_realops("m_join: bouncedtimes=%d??? [please report at http://bugs.unrealircd.org/]", bouncedtimes); bouncedtimes = 0; if (IsServer(sptr)) return 0; r = do_join(cptr, sptr, parc, parv); bouncedtimes = 0; return r; }
DLLFUNC CMD_FUNC(nopost) { if (MyConnect(sptr) && !is_except_host(sptr)) { /* We send a message to the ircops if the action is KILL, because otherwise * you won't even notice it. This is not necessary for *LINE/SHUN/etc as * ircops see them being added. */ if (cfg.ban_action == BAN_ACT_KILL) sendto_realops("[nopost] Killed connection from %s", GetIP(sptr)); return place_host_ban(sptr, cfg.ban_action, cfg.ban_reason, cfg.ban_time); } return 0; }
/* Called when module is unloaded */ DLLFUNC int MOD_UNLOAD(m_htm)(int module_unload) { if (del_Command(MSG_HTM, TOK_HTM, m_htm) < 0) { sendto_realops("Failed to delete commands when unloading %s", MOD_HEADER(m_htm).name); } #ifndef NO_FDLIST LockEventSystem(); EventDel(e_lcf); EventDel(e_htmcalc); UnlockEventSystem(); #endif return MOD_SUCCESS; }
static void redirect_all_clients(void) { int i, count = 0; aClient *acptr; for (i = LastSlot; i >= 0; i--) { if ((acptr = local[i]) && IsPerson(acptr) && !IsAnOper(acptr)) { do_jumpserver_exit_client(acptr); count++; } } sendto_realops("JUMPSERVER: Redirected %d client%s", count, count == 1 ? "" : "s"); /* Language fun... ;p */ }
DLLFUNC int MOD_INIT(m_nocaps)(ModuleInfo *modinfo) { ModuleSetOptions(modinfo->handle, MOD_OPT_PERM); CmodeInfo req; ircd_log(LOG_ERROR, "debug: mod_init called from m_nocaps"); sendto_realops("loading m_nocaps"); memset(&req, 0, sizeof(req)); req.paracount = 0; req.is_ok = extcmode_default_requirehalfop; req.flag = 'd'; ModeBlock = CmodeAdd(modinfo->handle, req, &NOCAPS_BLOCK); bcopy(modinfo,&NoCapsModInfo,modinfo->size); CheckMsg = HookAddPCharEx(NoCapsModInfo.handle, HOOKTYPE_CHANMSG, nocaps_checkmsg); return MOD_SUCCESS; }
DLLFUNC int MOD_INIT(m_restrictcolors)(ModuleInfo *modinfo) { ModuleSetOptions(modinfo->handle, MOD_OPT_PERM); CmodeInfo req; ircd_log(LOG_ERROR, "debug: mod_init called from m_restrictcolors"); sendto_realops("loading m_restrictcolors"); memset(&req, 0, sizeof(req)); req.paracount = 0; req.is_ok = extcmode_default_requirehalfop; req.flag = 'W'; ModeRcolors = CmodeAdd(modinfo->handle, req, &RESTRICT_COLORS); bcopy(modinfo,&RestrictColorsModInfo,modinfo->size); CheckMsg = HookAddPCharEx(RestrictColorsModInfo.handle, HOOKTYPE_CHANMSG, restrictcolors_checkmsg); return MOD_SUCCESS; }
int del_dccallow(aClient *sptr, aClient *optr) { Link **lpp, *lp; int found = 0; for (lpp = &(sptr->user->dccallow); *lpp; lpp=&((*lpp)->next)) { if ((*lpp)->flags != DCC_LINK_ME) continue; if ((*lpp)->value.cptr == optr) { lp = *lpp; *lpp = lp->next; free_link(lp); found++; break; } } if (!found) { sendto_one(sptr, ":%s %d %s :%s is not in your DCC allow list", me.name, RPL_DCCINFO, sptr->name, optr->name); return 0; } for (found = 0, lpp = &(optr->user->dccallow); *lpp; lpp=&((*lpp)->next)) { if ((*lpp)->flags != DCC_LINK_REMOTE) continue; if ((*lpp)->value.cptr == sptr) { lp = *lpp; *lpp = lp->next; free_link(lp); found++; break; } } if (!found) sendto_realops("[BUG!] %s was in dccallowme list of %s but not in dccallowrem list!", optr->name, sptr->name); sendto_one(sptr, rpl_str(RPL_DCCSTATUS), me.name, sptr->name, optr->name, "removed from"); return 0; }