1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file m_rehash.c |
23 |
* \brief Includes required functions for processing the REHASH command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "client.h" |
29 |
#include "irc_string.h" |
30 |
#include "ircd.h" |
31 |
#include "list.h" |
32 |
#include "numeric.h" |
33 |
#include "res.h" |
34 |
#include "conf.h" |
35 |
#include "log.h" |
36 |
#include "send.h" |
37 |
#include "parse.h" |
38 |
#include "modules.h" |
39 |
#include "motd.h" |
40 |
|
41 |
|
42 |
/*! \brief REHASH command handler |
43 |
* |
44 |
* \param source_p Pointer to allocated Client struct from which the message |
45 |
* originally comes from. This can be a local or remote client. |
46 |
* \param parc Integer holding the number of supplied arguments. |
47 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
48 |
* pointers. |
49 |
* \note Valid arguments for this command are: |
50 |
* - parv[0] = command |
51 |
* - parv[1] = additional option |
52 |
*/ |
53 |
static int |
54 |
mo_rehash(struct Client *source_p, int parc, char *parv[]) |
55 |
{ |
56 |
int found = 0; |
57 |
|
58 |
if (!HasOFlag(source_p, OPER_FLAG_REHASH)) |
59 |
{ |
60 |
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "rehash"); |
61 |
return 0; |
62 |
} |
63 |
|
64 |
if (!EmptyString(parv[1])) |
65 |
{ |
66 |
if (!irccmp(parv[1], "DNS")) |
67 |
{ |
68 |
sendto_one_numeric(source_p, &me, RPL_REHASHING, "DNS"); |
69 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
70 |
"%s is rehashing DNS", |
71 |
get_oper_name(source_p)); |
72 |
restart_resolver(); |
73 |
found = 1; |
74 |
} |
75 |
else if (!irccmp(parv[1], "MOTD")) |
76 |
{ |
77 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
78 |
"%s is forcing re-reading of MOTD files", |
79 |
get_oper_name(source_p)); |
80 |
motd_recache(); |
81 |
found = 1; |
82 |
} |
83 |
|
84 |
if (found) |
85 |
ilog(LOG_TYPE_IRCD, "REHASH %s From %s", |
86 |
parv[1], get_oper_name(source_p)); |
87 |
else |
88 |
sendto_one_notice(source_p, &me, ":%s is not a valid option. " |
89 |
"Choose from DNS, MOTD", parv[1]); |
90 |
} |
91 |
else |
92 |
{ |
93 |
sendto_one_numeric(source_p, &me, RPL_REHASHING, ConfigGeneral.configfile); |
94 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
95 |
"%s is rehashing configuration file(s)", |
96 |
get_oper_name(source_p)); |
97 |
ilog(LOG_TYPE_IRCD, "REHASH From %s", |
98 |
get_oper_name(source_p)); |
99 |
rehash(0); |
100 |
} |
101 |
|
102 |
return 0; |
103 |
} |
104 |
|
105 |
static struct Message rehash_msgtab = |
106 |
{ |
107 |
"REHASH", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
108 |
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_rehash, m_ignore } |
109 |
}; |
110 |
|
111 |
static void |
112 |
module_init(void) |
113 |
{ |
114 |
mod_add_cmd(&rehash_msgtab); |
115 |
} |
116 |
|
117 |
static void |
118 |
module_exit(void) |
119 |
{ |
120 |
mod_del_cmd(&rehash_msgtab); |
121 |
} |
122 |
|
123 |
struct module module_entry = |
124 |
{ |
125 |
.node = { NULL, NULL, NULL }, |
126 |
.name = NULL, |
127 |
.version = "$Revision$", |
128 |
.handle = NULL, |
129 |
.modinit = module_init, |
130 |
.modexit = module_exit, |
131 |
.flags = 0 |
132 |
}; |