| 1 |
/*
|
| 2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
|
| 3 |
* m_jupe.c: Jupes a server.
|
| 4 |
*
|
| 5 |
* Copyright (C) 2002 by the past and present ircd coders, and others.
|
| 6 |
*
|
| 7 |
* This program is free software; you can redistribute it and/or modify
|
| 8 |
* it under the terms of the GNU General Public License as published by
|
| 9 |
* the Free Software Foundation; either version 2 of the License, or
|
| 10 |
* (at your option) any later version.
|
| 11 |
*
|
| 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
* GNU General Public License for more details.
|
| 16 |
*
|
| 17 |
* You should have received a copy of the GNU General Public License
|
| 18 |
* along with this program; if not, write to the Free Software
|
| 19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
| 20 |
* USA
|
| 21 |
*
|
| 22 |
* $Id: m_jupe.c 801 2006-08-30 16:54:25Z adx $
|
| 23 |
*/
|
| 24 |
|
| 25 |
#include "stdinc.h"
|
| 26 |
#include "conf/conf.h"
|
| 27 |
#include "handlers.h"
|
| 28 |
#include "channel.h"
|
| 29 |
#include "client.h"
|
| 30 |
#include "ircd.h"
|
| 31 |
#include "numeric.h"
|
| 32 |
#include "server.h"
|
| 33 |
#include "send.h"
|
| 34 |
#include "whowas.h"
|
| 35 |
#include "hash.h"
|
| 36 |
#include "msg.h"
|
| 37 |
#include "parse.h"
|
| 38 |
#include "common.h"
|
| 39 |
#include "user.h"
|
| 40 |
|
| 41 |
static void mo_jupe(struct Client *, struct Client *, int, char *[]);
|
| 42 |
|
| 43 |
struct Message jupe_msgtab = {
|
| 44 |
"JUPE", 0, 0, 3, 0, MFLG_SLOW, 0,
|
| 45 |
{ m_unregistered, m_not_oper, mo_jupe, m_ignore, mo_jupe, m_ignore }
|
| 46 |
};
|
| 47 |
|
| 48 |
INIT_MODULE(m_jupe, "$Revision: 801 $")
|
| 49 |
{
|
| 50 |
mod_add_cmd(&jupe_msgtab);
|
| 51 |
}
|
| 52 |
|
| 53 |
CLEANUP_MODULE
|
| 54 |
{
|
| 55 |
mod_del_cmd(&jupe_msgtab);
|
| 56 |
}
|
| 57 |
|
| 58 |
|
| 59 |
/*! \brief JUPE command handler (called for operators only)
|
| 60 |
*
|
| 61 |
* \param client_p Pointer to allocated Client struct with physical connection
|
| 62 |
* to this server, i.e. with an open socket connected.
|
| 63 |
* \param source_p Pointer to allocated Client struct from which the message
|
| 64 |
* originally comes from. This can be a local or remote client.
|
| 65 |
* \param parc Integer holding the number of supplied arguments.
|
| 66 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
|
| 67 |
* pointers.
|
| 68 |
* \note Valid arguments for this command are:
|
| 69 |
* - parv[0] = sender prefix
|
| 70 |
* - parv[1] = name of server to jupe
|
| 71 |
* - parv[2] = reson for jupe
|
| 72 |
*/
|
| 73 |
static void
|
| 74 |
mo_jupe(struct Client *client_p, struct Client *source_p,
|
| 75 |
int parc, char *parv[])
|
| 76 |
{
|
| 77 |
struct Client *target_p = NULL;
|
| 78 |
struct Client *ajupe = NULL;
|
| 79 |
char reason[REALLEN + 1];
|
| 80 |
|
| 81 |
if (!IsAdmin(source_p))
|
| 82 |
{
|
| 83 |
sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
|
| 84 |
me.name, source_p->name);
|
| 85 |
return;
|
| 86 |
}
|
| 87 |
|
| 88 |
if (EmptyString(parv[2]))
|
| 89 |
{
|
| 90 |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
|
| 91 |
me.name, source_p->name, "JUPE");
|
| 92 |
return;
|
| 93 |
}
|
| 94 |
|
| 95 |
if (!ServerInfo.hub)
|
| 96 |
{
|
| 97 |
sendto_one(source_p, ":%s NOTICE %s :Must be used from a hub server",
|
| 98 |
me.name, source_p->name);
|
| 99 |
return;
|
| 100 |
}
|
| 101 |
|
| 102 |
if (bogus_host(parv[1]))
|
| 103 |
{
|
| 104 |
sendto_one(source_p, ":%s NOTICE %s :Invalid servername: %s",
|
| 105 |
me.name, source_p->name, parv[1]);
|
| 106 |
return;
|
| 107 |
}
|
| 108 |
|
| 109 |
if (match(parv[1], me.name))
|
| 110 |
{
|
| 111 |
sendto_one(source_p, ":%s NOTICE %s :I can't jupe myself!",
|
| 112 |
me.name, source_p->name);
|
| 113 |
return;
|
| 114 |
}
|
| 115 |
|
| 116 |
/* we need to give 7 chars to prepend "JUPED: " */
|
| 117 |
if (strlen(parv[2]) > (REALLEN - 7))
|
| 118 |
parv[2][REALLEN - 7] = '\0';
|
| 119 |
|
| 120 |
sendto_wallops_flags(UMODE_WALLOP, &me,
|
| 121 |
"JUPE for %s requested by %s: %s",
|
| 122 |
parv[1], get_oper_name(source_p), parv[2]);
|
| 123 |
|
| 124 |
sendto_server(NULL, source_p, NULL, NOCAPS, NOCAPS,
|
| 125 |
":%s WALLOPS :JUPE for %s requested by %s: %s",
|
| 126 |
me.name, parv[1], get_oper_name(source_p), parv[2]);
|
| 127 |
ilog(L_NOTICE, "JUPE for %s requested by %s: %s",
|
| 128 |
parv[1], get_oper_name(source_p), parv[2]);
|
| 129 |
|
| 130 |
if ((target_p = find_server(parv[1])) != NULL)
|
| 131 |
exit_client(target_p, &me, parv[2]);
|
| 132 |
|
| 133 |
sendto_server(NULL, NULL, NULL, NOCAPS, NOCAPS,
|
| 134 |
":%s SERVER %s 1 :JUPED: %s",
|
| 135 |
me.name, parv[1], parv[2]);
|
| 136 |
|
| 137 |
sendto_realops_flags(UMODE_ALL, L_ALL,
|
| 138 |
"Link with %s established: (JUPED) link",
|
| 139 |
parv[1]);
|
| 140 |
|
| 141 |
ajupe = make_client(NULL);
|
| 142 |
|
| 143 |
/* make_client() adds client to unknown_list */
|
| 144 |
dlinkDelete(&ajupe->localClient->lclient_node, &unknown_list);
|
| 145 |
|
| 146 |
make_server(ajupe);
|
| 147 |
|
| 148 |
strlcpy(ajupe->name, parv[1], sizeof(ajupe->name));
|
| 149 |
ircsprintf(reason, "JUPED: %s", parv[2]);
|
| 150 |
strlcpy(ajupe->info, reason, sizeof(ajupe->info));
|
| 151 |
|
| 152 |
ajupe->servptr = &me;
|
| 153 |
ajupe->hopcount = 1;
|
| 154 |
|
| 155 |
SetServer(ajupe);
|
| 156 |
SetDead(ajupe);
|
| 157 |
|
| 158 |
++Count.myserver;
|
| 159 |
|
| 160 |
hash_add_client(ajupe);
|
| 161 |
|
| 162 |
dlinkAdd(ajupe, &ajupe->lnode, &ajupe->servptr->serv->server_list);
|
| 163 |
dlinkAdd(ajupe, make_dlink_node(), &global_serv_list);
|
| 164 |
dlinkAdd(ajupe, &ajupe->node, &global_client_list);
|
| 165 |
}
|