2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* m_admin.c: Sends administrative information to a user.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
2016-07-01 05:04:00 +02:00
|
|
|
#include <ircd/stdinc.h>
|
|
|
|
#include <ircd/client.h>
|
|
|
|
#include <ircd/ircd.h>
|
|
|
|
#include <ircd/numeric.h>
|
|
|
|
#include <ircd/s_conf.h>
|
|
|
|
#include <ircd/s_serv.h>
|
|
|
|
#include <ircd/send.h>
|
|
|
|
#include <ircd/msg.h>
|
|
|
|
#include <ircd/parse.h>
|
|
|
|
#include <ircd/hook.h>
|
|
|
|
#include <ircd/modules.h>
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
const char admin_desc[] =
|
|
|
|
"Provides the ADMIN command to show server administrator information";
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static void m_admin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
|
|
|
|
static void mr_admin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
|
|
|
|
static void ms_admin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
|
2007-01-25 07:40:21 +01:00
|
|
|
static void do_admin(struct Client *source_p);
|
|
|
|
|
|
|
|
static void admin_spy(struct Client *);
|
|
|
|
|
|
|
|
struct Message admin_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"ADMIN", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{{mr_admin, 0}, {m_admin, 0}, {ms_admin, 0}, mg_ignore, mg_ignore, {ms_admin, 0}}
|
|
|
|
};
|
|
|
|
|
|
|
|
int doing_admin_hook;
|
|
|
|
|
|
|
|
mapi_clist_av1 admin_clist[] = { &admin_msgtab, NULL };
|
2014-03-03 05:25:47 +01:00
|
|
|
mapi_hlist_av1 admin_hlist[] = {
|
2007-01-25 07:40:21 +01:00
|
|
|
{ "doing_admin", &doing_admin_hook },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2016-03-07 08:38:14 +01:00
|
|
|
DECLARE_MODULE_AV2(admin, NULL, NULL, admin_clist, admin_hlist, NULL, NULL, NULL, admin_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* mr_admin - ADMIN command handler
|
2014-03-03 05:25:47 +01:00
|
|
|
* parv[1] = servername
|
2007-01-25 07:40:21 +01:00
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-02-11 03:54:17 +01:00
|
|
|
mr_admin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
static time_t last_used = 0L;
|
|
|
|
|
2008-04-02 01:53:20 +02:00
|
|
|
if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2014-03-03 05:25:47 +01:00
|
|
|
sendto_one(source_p, form_str(RPL_LOAD2HI),
|
|
|
|
me.name,
|
|
|
|
EmptyString(source_p->name) ? "*" : source_p->name,
|
2007-01-25 07:40:21 +01:00
|
|
|
"ADMIN");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
2008-04-02 01:53:20 +02:00
|
|
|
last_used = rb_current_time();
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
do_admin(source_p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* m_admin - ADMIN command handler
|
|
|
|
* parv[1] = servername
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-02-11 03:54:17 +01:00
|
|
|
m_admin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
static time_t last_used = 0L;
|
|
|
|
|
|
|
|
if(parc > 1)
|
|
|
|
{
|
2008-04-02 01:53:20 +02:00
|
|
|
if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(RPL_LOAD2HI),
|
|
|
|
me.name, source_p->name, "ADMIN");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
2008-04-02 01:53:20 +02:00
|
|
|
last_used = rb_current_time();
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
do_admin(source_p);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ms_admin - ADMIN command handler, used for OPERS as well
|
|
|
|
* parv[1] = servername
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-02-11 03:54:17 +01:00
|
|
|
ms_admin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
do_admin(source_p);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* do_admin
|
|
|
|
*
|
|
|
|
* inputs - pointer to client to report to
|
|
|
|
* output - none
|
|
|
|
* side effects - admin info is sent to client given
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
do_admin(struct Client *source_p)
|
|
|
|
{
|
|
|
|
if(IsPerson(source_p))
|
|
|
|
admin_spy(source_p);
|
|
|
|
|
2007-04-03 12:11:06 +02:00
|
|
|
sendto_one_numeric(source_p, RPL_ADMINME, form_str(RPL_ADMINME), me.name);
|
2007-01-25 07:40:21 +01:00
|
|
|
if(AdminInfo.name != NULL)
|
2007-04-03 12:11:06 +02:00
|
|
|
sendto_one_numeric(source_p, RPL_ADMINLOC1, form_str(RPL_ADMINLOC1), AdminInfo.name);
|
2007-01-25 07:40:21 +01:00
|
|
|
if(AdminInfo.description != NULL)
|
2007-04-03 12:11:06 +02:00
|
|
|
sendto_one_numeric(source_p, RPL_ADMINLOC2, form_str(RPL_ADMINLOC2), AdminInfo.description);
|
2007-01-25 07:40:21 +01:00
|
|
|
if(AdminInfo.email != NULL)
|
2007-04-03 12:11:06 +02:00
|
|
|
sendto_one_numeric(source_p, RPL_ADMINEMAIL, form_str(RPL_ADMINEMAIL), AdminInfo.email);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* admin_spy()
|
|
|
|
*
|
|
|
|
* input - pointer to client
|
|
|
|
* output - none
|
|
|
|
* side effects - event doing_admin is called
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
admin_spy(struct Client *source_p)
|
|
|
|
{
|
|
|
|
hook_data hd;
|
|
|
|
|
|
|
|
hd.client = source_p;
|
|
|
|
hd.arg1 = hd.arg2 = NULL;
|
|
|
|
|
|
|
|
call_hook(doing_admin_hook, &hd);
|
|
|
|
}
|