/* ** m_wallops (write to *all* opers currently online) ** parv[0] = sender prefix ** parv[1] = message text */ DLLFUNC CMD_FUNC(m_wallops) { char *message; message = parc > 1 ? parv[1] : NULL; if (BadPtr(message)) { sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "WALLOPS"); return 0; } if (MyClient(sptr) && !OPCanWallOps(sptr)) { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); return 0; } sendto_ops_butone(IsServer(cptr) ? cptr : NULL, sptr, ":%s WALLOPS :%s", parv[0], message); return 0; }
/* * m_squit - SQUIT message handler * parv[0] = sender prefix * parv[1] = server name * parv[2] = comment */ int m_squit(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) { struct ConfItem* aconf; char* server; struct Client* acptr; char *comment = (parc > 2 && parv[2]) ? parv[2] : cptr->name; if (!IsPrivileged(sptr)) { sendto_one(sptr, form_str(ERR_NOPRIVILEGES), me.name, parv[0]); return 0; } if (parc > 1) { server = parv[1]; /* ** To accomodate host masking, a squit for a masked server ** name is expanded if the incoming mask is the same as ** the server name for that link to the name of link. */ while ((*server == '*') && IsServer(cptr)) { aconf = cptr->serv->nline; if (!aconf) break; if (!irccmp(server, my_name_for_link(me.name, aconf))) server = cptr->name; break; /* WARNING is normal here */ /* NOTREACHED */ } /* ** The following allows wild cards in SQUIT. Only useful ** when the command is issued by an oper. */ for (acptr = GlobalClientList; (acptr = next_client(acptr, server)); acptr = acptr->next) if (IsServer(acptr) || IsMe(acptr)) break; if (acptr && IsMe(acptr)) { acptr = cptr; server = cptr->name; } } else { /* ** This is actually protocol error. But, well, closing ** the link is very proper answer to that... ** ** Closing the client's connection probably wouldn't do much ** good.. any oper out there should know that the proper way ** to disconnect is /QUIT :) ** ** its still valid if its not a local client, its then ** a protocol error for sure -Dianora */ if(MyClient(sptr)) { sendto_one(sptr, form_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "SQUIT"); return 0; } else { server = cptr->host; acptr = cptr; } } /* ** SQUIT semantics is tricky, be careful... ** ** The old (irc2.2PL1 and earlier) code just cleans away the ** server client from the links (because it is never true ** "cptr == acptr". ** ** This logic here works the same way until "SQUIT host" hits ** the server having the target "host" as local link. Then it ** will do a real cleanup spewing SQUIT's and QUIT's to all ** directions, also to the link from which the orinal SQUIT ** came, generating one unnecessary "SQUIT host" back to that ** link. ** ** One may think that this could be implemented like ** "hunt_server" (e.g. just pass on "SQUIT" without doing ** nothing until the server having the link as local is ** reached). Unfortunately this wouldn't work in the real life, ** because either target may be unreachable or may not comply ** with the request. In either case it would leave target in ** links--no command to clear it away. So, it's better just ** clean out while going forward, just to be sure. ** ** ...of course, even better cleanout would be to QUIT/SQUIT ** dependant users/servers already on the way out, but ** currently there is not enough information about remote ** clients to do this... --msa */ if (!acptr) { sendto_one(sptr, form_str(ERR_NOSUCHSERVER), me.name, parv[0], server); return 0; } if (IsLocOp(sptr) && !MyConnect(acptr)) { sendto_one(sptr, form_str(ERR_NOPRIVILEGES), me.name, parv[0]); return 0; } if (MyClient(sptr) && !IsOperRemote(sptr) && !MyConnect(acptr)) { sendto_one(sptr,":%s NOTICE %s :You have no R flag",me.name,parv[0]); return 0; } /* ** Notify all opers, if my local link is remotely squitted */ if (MyConnect(acptr) && !IsAnOper(cptr)) { sendto_ops_butone(NULL, &me, ":%s WALLOPS :Received SQUIT %s from %s (%s)", me.name, server, get_client_name(sptr,FALSE), comment); log(L_TRACE, "SQUIT From %s : %s (%s)", parv[0], server, comment); } else if (MyConnect(acptr)) sendto_ops("Received SQUIT %s from %s (%s)", acptr->name, get_client_name(sptr,FALSE), comment); return exit_client(cptr, acptr, sptr, comment); }
DLLFUNC int m_setident(aClient *cptr, aClient *sptr, int parc, char *parv[]) { char *vident, *s; #ifndef DISABLE_USERMOD int permit = 0; /* 0 = opers(glob/locop) 1 = global oper */ #else int permit = 2; #endif int legalident = 1; /* is legal characters? */ if (!MyConnect(sptr)) goto permit_2; switch (permit) { case 0: if (!IsAnOper(sptr)) { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); return 0; } break; case 1: if (!IsOper(sptr)) { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); return 0; } break; case 2: if (MyConnect(sptr)) { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); return 0; } break; default: sendto_ops_butone(IsServer(cptr) ? cptr : NULL, sptr, ":%s WALLOPS :[SETIDENT] Somebody fixing this corrupted server? !(0|1) !!!", me.name); break; } permit_2: if (parc < 2) vident = NULL; else vident = parv[1]; /* bad bad bad boys .. ;p */ if (vident == NULL) { if (MyConnect(sptr)) { sendto_one(sptr, ":%s NOTICE %s :*** Syntax: /SetIdent <new ident>", me.name, parv[0]); } return 1; } if (strlen(parv[1]) < 1) { if (MyConnect(sptr)) sendto_one(sptr, ":%s NOTICE %s :*** /SetIdent Error: Atleast write SOMETHING that makes sense (':' string)", me.name, sptr->name); return 0; } /* too large huh? */ if (strlen(vident) > (USERLEN)) { /* ignore us as well if we're not a child of 3k */ if (MyConnect(sptr)) sendto_one(sptr, ":%s NOTICE %s :*** /SetIdent Error: Usernames are limited to %i characters.", me.name, sptr->name, USERLEN); return 0; } /* illegal?! */ for (s = vident; *s; s++) { if ((*s == '~') && (s == vident)) continue; if (!isallowed(*s)) { legalident = 0; break; } } if (legalident == 0) { sendto_one(sptr, ":%s NOTICE %s :*** /SetIdent Error: A username may contain a-z, A-Z, 0-9, '-', '~' & '.' - Please only use them", me.name, parv[0]); return 0; } { switch (UHOST_ALLOWED) { case UHALLOW_ALWAYS: break; case UHALLOW_NEVER: if (MyClient(sptr)) { sendto_one(sptr, ":%s NOTICE %s :*** /SetIdent is disabled", me.name, sptr->name); return 0; } break; case UHALLOW_NOCHANS: if (MyClient(sptr) && sptr->user->joined) { sendto_one(sptr, ":%s NOTICE %s :*** /SetIdent can not be used while you are on a channel", me.name, sptr->name); return 0; } break; case UHALLOW_REJOIN: rejoin_doquits(sptr); break; } /* get it in */ ircsnprintf(sptr->user->username, sizeof(sptr->user->username), "%s", vident); /* spread it out */ sendto_server(cptr, 0, 0, ":%s SETIDENT %s", sptr->name, parv[1]); if (UHOST_ALLOWED == UHALLOW_REJOIN) rejoin_dojoinandmode(sptr); } if (MyConnect(sptr)) { sendto_one(sptr, ":%s NOTICE %s :Your nick!user@host-mask is now (%s!%s@%s) - To disable ident set change it manually by /setident'ing again", me.name, parv[0], parv[0], sptr->user->username, GetHost(sptr)); } return 0; }
/* * m_connect - CONNECT command handler * * Added by Jto 11 Feb 1989 * * m_connect * parv[0] = sender prefix * parv[1] = servername * parv[2] = port number * parv[3] = remote server */ int m_connect(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { int port; int tmpport; struct ConfItem* aconf; struct Client* acptr; if (!IsPrivileged(sptr)) { sendto_one(sptr, form_str(ERR_NOPRIVILEGES), me.name, parv[0]); return -1; } if (IsLocOp(sptr) && parc > 3) { /* * Only allow LocOps to make local CONNECTS --SRB */ return 0; } if (MyConnect(sptr) && !IsOperRemote(sptr) && parc > 3) { sendto_one(sptr,":%s NOTICE %s :You have no R flag", me.name, parv[0]); return 0; } if (hunt_server(cptr, sptr, ":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME) return 0; if (parc < 2 || *parv[1] == '\0') { sendto_one(sptr, form_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "CONNECT"); return -1; } if ((acptr = find_server(parv[1]))) { sendto_one(sptr, ":%s NOTICE %s :Connect: Server %s %s %s.", me.name, parv[0], parv[1], "already exists from", acptr->from->name); return 0; } /* * try to find the name, then host, if both fail notify ops and bail */ if (!(aconf = find_conf_by_name(parv[1], CONF_CONNECT_SERVER))) { #ifndef HIDE_SERVERS_IPS if (!(aconf = find_conf_by_host(parv[1], CONF_CONNECT_SERVER))) { #endif sendto_one(sptr, "NOTICE %s :Connect: Host %s not listed in ircd.conf", parv[0], parv[1]); return 0; #ifndef HIDE_SERVERS_IPS } #endif } assert(0 != aconf); /* * Get port number from user, if given. If not specified, * use the default form configuration structure. If missing * from there, then use the precompiled default. */ tmpport = port = aconf->port; if (parc > 2 && !EmptyString(parv[2])) { #ifdef NEG_PORT if ((port = atoi(parv[2])) < 0) #else if ((port = atoi(parv[2])) <= 0) #endif { sendto_one(sptr, "NOTICE %s :Connect: Illegal port number", parv[0]); return 0; } } #ifdef NEG_PORT else if (port < 0 && (port = PORTNUM) <= 0) #else else if (port <= 0 && (port = PORTNUM) <= 0) #endif { sendto_one(sptr, ":%s NOTICE %s :Connect: missing port number", me.name, parv[0]); return 0; } #ifdef NEG_PORT if (port == 0) port = tmpport; /* From conf */ if (port == 0) port = PORTNUM; /* Default if there wasn't one set in conf */ #endif /* * Notify all operators about remote connect requests */ if (!IsAnOper(cptr)) { sendto_ops_butone(NULL, &me, ":%s WALLOPS :Remote CONNECT %s %s from %s", me.name, parv[1], parv[2] ? parv[2] : "", get_client_name(sptr, FALSE)); irclog(L_TRACE, "CONNECT From %s : %s %s", parv[0], parv[1], parv[2] ? parv[2] : ""); } aconf->port = port; /* * at this point we should be calling connect_server with a valid * C:line and a valid port in the C:line */ if (connect_server(aconf, sptr, 0)) #if (defined SERVERHIDE) || (defined HIDE_SERVERS_IPS) sendto_one(sptr, ":%s NOTICE %s :*** Connecting to %s[%s].%d", me.name, parv[0], "255.255.255.255", aconf->name, aconf->port); else sendto_one(sptr, ":%s NOTICE %s :*** Couldn't connect to %s.%d", me.name, parv[0], "255.255.255.255",aconf->port); #else sendto_one(sptr, ":%s NOTICE %s :*** Connecting to %s[%s].%d", me.name, parv[0], aconf->host, aconf->name, aconf->port); else