/* * me_forcenick * parv[1] = forcenick victim * parv[2] = new nickname */ static int me_forcenick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *target_p, *exist_p; const char *user; const char *newnick; user = parv[1]; /* We're supposed to drop servers over protocol violations, but shit happens... */ if(EmptyString(parv[2])) return 0; else { char *s; s = LOCAL_COPY(parv[2]); if(strlen(s) > (size_t) NICKLEN) s[NICKLEN] = '\0'; newnick = s; } if(!clean_nick(newnick)) return 0; if((target_p = find_person(user)) == NULL) return 0; if(IsServer(target_p) || IsMe(target_p)) return 0; if(!MyClient(target_p) && !IsOperGlobalForce(source_p)) return 0; if((exist_p = find_person(newnick)) != NULL) { /* Could just be a case shift */ if(irccmp(target_p->name, newnick)) return 0; /* If it's the same nick, f**k it */ else if(!strcmp(target_p->name, newnick)) return 0; } ilog(L_MAIN, "FORCENICK called for [%s] by %s!%s@%s", target_p->name, source_p->name, source_p->username, source_p->host); if(!MyClient(target_p)) { struct Client *cptr = target_p->servptr; sendto_one(cptr, ":%s ENCAP %s FORCENICK %s :%s", get_id(source_p, cptr), cptr->name, get_id(target_p, cptr), newnick); return 0; } change_nick(target_p, newnick); return 0; }
/* * mo_forcepart * parv[1] = forcepart victim * parv[2] = channels to part * parv[3] = reason */ static int mo_forcepart(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *target_p; const char *user, *channels, *reason; const char default_reason[] = "Leaving"; int chasing = 0; user = parv[1]; channels = parv[2]; if(!IsOperLocalForce(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "local_force"); return 0; } /* if target_p == NULL then let the oper know */ if((target_p = find_chasing(source_p, user, &chasing)) == NULL) { sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, user); return 0; } if(EmptyString(channels)) { sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "FORCEPART"); return 0; } if(EmptyString(parv[3])) reason = default_reason; else { char *s; s = LOCAL_COPY(parv[3]); if(strlen(s) > (size_t) REASONLEN) s[REASONLEN] = '\0'; reason = s; } if(!IsClient(target_p)) return 0; if(!MyClient(target_p) && (!IsOperGlobalForce(source_p))) { sendto_one_notice(source_p, ":Nick %s is not on your server and you do not have the global_force flag", target_p->name); return 0; } sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Received FORCEPART message for %s!%s@%s. From %s (Channels: %s)", target_p->name, target_p->username, target_p->host, source_p->name, channels); ilog(L_MAIN, "FORCEPART called for %s %s by %s!%s@%s (part reason %s)", user, channels, source_p->name, source_p->username, source_p->host, reason); if(!MyClient(target_p)) { struct Client *cptr = target_p->servptr; sendto_one(cptr, ":%s ENCAP %s FORCEPART %s :%s", get_id(source_p, cptr), cptr->name, get_id(target_p, cptr), channels); return 0; } forcepart_channels(client_p, source_p, target_p, channels, reason); return 0; }
/* ** mo_forcenick ** parv[1] = forcenick victim ** parv[2] = new nickname */ static int mo_forcenick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *target_p, *exist_p; const char *user; const char *newnick; user = parv[1]; /* You must be this tall to ride the ride */ if(!IsOperLocalForce(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "local_force"); return 0; } /* Truncate it so clean_nick doesn't spaz out */ if(!EmptyString(parv[2])) { char *s; s = LOCAL_COPY(parv[2]); if(strlen(s) > (size_t) NICKLEN) s[NICKLEN] = '\0'; newnick = s; } else { sendto_one_numeric(source_p, ERR_NONICKNAMEGIVEN, form_str(ERR_NONICKNAMEGIVEN), me.name, source_p->name); return 0; } /* Nick has to be clean or we'll have a protocol violation... */ if(!clean_nick(newnick)) { sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME), me.name, user, newnick); return 0; } /* Find the target... */ if((target_p = find_named_person(user)) == NULL) { sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "FORCENICK"); return 0; } /* If it's a server, sod it, changing its name is stupid... */ if(IsServer(target_p) || IsMe(target_p)) { sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK), user); return 0; } /* Do we have permission to send it globally? */ if(!MyClient(target_p) && (!IsOperGlobalForce(source_p))) { sendto_one_notice(source_p, ":Nick %s is not on your server and you do not have the global_force flag", target_p->name); return 0; } /* Check to see if the new nick exists */ if((exist_p = find_named_person(newnick)) != NULL) { /* Could just be a case shift */ if(irccmp(target_p->name, newnick)) { sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name, user, newnick); return 0; } /* If it's the same nick, f**k it */ else if(!strcmp(target_p->name, newnick)) return 0; } sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Received FORCENICK message for %s!%s@%s. From %s (Newnick: %s)", target_p->name, target_p->username, target_p->orighost, source_p->name, newnick); ilog(L_MAIN, "FORCENICK called for [%s] by %s!%s@%s", target_p->name, source_p->name, source_p->username, source_p->host); sendto_one_notice(target_p, ":You have been forcenicked from %s to %s by %s", target_p->name, newnick, source_p->name); if(!MyClient(target_p)) { struct Client *cptr = target_p->servptr; sendto_one(cptr, ":%s ENCAP %s FORCENICK %s :%s", get_id(source_p, cptr), cptr->name, get_id(target_p, cptr), newnick); return 0; } change_nick(target_p, newnick); return 0; }
/* ** mo_forcejoin ** parv[1] = forcejoin victim ** parv[2] = forcejoin channel list */ static int mo_forcejoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *target_p; const char *user, *chanlist; user = parv[1]; if(!IsOperLocalForce(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "local_force"); return 0; } if(EmptyString(parv[2])) { sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "FORCEJOIN"); return 0; } else chanlist = parv[2]; if((target_p = find_named_person(user)) == NULL) { sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK), user); return 0; } if(!IsPerson(target_p)) return 0; if(!MyClient(target_p) && !IsOperGlobalForce(source_p)) { sendto_one_notice(source_p, ":Nick %s is not on your server and you do not have the global_force flag", target_p->name); return 0; } sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Received FORCEJOIN message for %s!%s@%s. From %s (Channels: %s)", target_p->name, target_p->username, target_p->orighost, source_p->name, chanlist); ilog(L_MAIN, "FORCEJOIN called for [%s] by %s!%s@%s", target_p->name, source_p->name, source_p->username, source_p->host); sendto_one_notice(target_p, ":You have been forcejoined to %s by %s", chanlist, source_p->name); if(!MyClient(target_p)) { struct Client *cptr = target_p->servptr; sendto_one(cptr, ":%s ENCAP %s FORCEJOIN %s :%s", get_id(source_p, cptr), cptr->name, get_id(target_p, cptr), chanlist); return 0; } user_join_override(client_p, source_p, target_p, chanlist); return 0; }