1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* m_rehash.c: Re-reads the configuration file. |
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$ |
23 |
*/ |
24 |
|
25 |
#include "stdinc.h" |
26 |
#include "client.h" |
27 |
#include "irc_string.h" |
28 |
#include "ircd.h" |
29 |
#include "list.h" |
30 |
#include "numeric.h" |
31 |
#include "irc_res.h" |
32 |
#include "conf.h" |
33 |
#include "log.h" |
34 |
#include "send.h" |
35 |
#include "parse.h" |
36 |
#include "modules.h" |
37 |
#include "motd.h" |
38 |
|
39 |
|
40 |
/* |
41 |
* mo_rehash - REHASH message handler |
42 |
* |
43 |
*/ |
44 |
static void |
45 |
mo_rehash(struct Client *client_p, struct Client *source_p, |
46 |
int parc, char *parv[]) |
47 |
{ |
48 |
int found = 0; |
49 |
|
50 |
if (!HasOFlag(source_p, OPER_FLAG_REHASH)) |
51 |
{ |
52 |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
53 |
me.name, source_p->name, "rehash"); |
54 |
return; |
55 |
} |
56 |
|
57 |
if (!EmptyString(parv[1])) |
58 |
{ |
59 |
if (irccmp(parv[1], "DNS") == 0) |
60 |
{ |
61 |
sendto_one(source_p, form_str(RPL_REHASHING), me.name, source_p->name, "DNS"); |
62 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
63 |
"%s is rehashing DNS", |
64 |
get_oper_name(source_p)); |
65 |
restart_resolver(); /* re-read /etc/resolv.conf AGAIN? |
66 |
and close/re-open res socket */ |
67 |
found = 1; |
68 |
} |
69 |
else if (irccmp(parv[1], "MOTD") == 0) |
70 |
{ |
71 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
72 |
"%s is forcing re-reading of MOTD files", |
73 |
get_oper_name(source_p)); |
74 |
motd_recache(); |
75 |
found = 1; |
76 |
} |
77 |
|
78 |
if (found) |
79 |
{ |
80 |
ilog(LOG_TYPE_IRCD, "REHASH %s From %s", |
81 |
parv[1], get_client_name(source_p, HIDE_IP)); |
82 |
return; |
83 |
} |
84 |
else |
85 |
{ |
86 |
sendto_one(source_p, ":%s NOTICE %s :%s is not a valid option. " |
87 |
"Choose from DNS, MOTD", |
88 |
me.name, source_p->name, parv[1]); |
89 |
return; |
90 |
} |
91 |
} |
92 |
else |
93 |
{ |
94 |
sendto_one(source_p, form_str(RPL_REHASHING), |
95 |
me.name, source_p->name, ConfigFileEntry.configfile); |
96 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
97 |
"%s is rehashing server config file", |
98 |
get_oper_name(source_p)); |
99 |
ilog(LOG_TYPE_IRCD, "REHASH From %s[%s]", |
100 |
get_oper_name(source_p), source_p->sockhost); |
101 |
rehash(0); |
102 |
} |
103 |
} |
104 |
|
105 |
static struct Message rehash_msgtab = { |
106 |
"REHASH", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
107 |
{m_unregistered, m_not_oper, m_ignore, m_ignore, mo_rehash, m_ignore} |
108 |
}; |
109 |
|
110 |
static void |
111 |
module_init(void) |
112 |
{ |
113 |
mod_add_cmd(&rehash_msgtab); |
114 |
} |
115 |
|
116 |
static void |
117 |
module_exit(void) |
118 |
{ |
119 |
mod_del_cmd(&rehash_msgtab); |
120 |
} |
121 |
|
122 |
struct module module_entry = { |
123 |
.node = { NULL, NULL, NULL }, |
124 |
.name = NULL, |
125 |
.version = "$Revision$", |
126 |
.handle = NULL, |
127 |
.modinit = module_init, |
128 |
.modexit = module_exit, |
129 |
.flags = 0 |
130 |
}; |