1 |
adx |
30 |
/* |
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 |
knight |
31 |
* $Id$ |
23 |
adx |
30 |
*/ |
24 |
|
|
|
25 |
|
|
#include "stdinc.h" |
26 |
|
|
#include "handlers.h" |
27 |
|
|
#include "client.h" |
28 |
|
|
#include "common.h" |
29 |
|
|
#include "irc_string.h" |
30 |
|
|
#include "ircd.h" |
31 |
|
|
#include "list.h" |
32 |
|
|
#include "numeric.h" |
33 |
|
|
#include "irc_res.h" |
34 |
|
|
#include "s_conf.h" |
35 |
|
|
#include "s_log.h" |
36 |
|
|
#include "send.h" |
37 |
|
|
#include "msg.h" |
38 |
|
|
#include "parse.h" |
39 |
|
|
#include "modules.h" |
40 |
|
|
|
41 |
|
|
static void mo_rehash(struct Client *, struct Client *, int, char **); |
42 |
|
|
|
43 |
|
|
struct Message rehash_msgtab = { |
44 |
|
|
"REHASH", 0, 0, 0, 0, MFLG_SLOW, 0, |
45 |
|
|
{m_unregistered, m_not_oper, m_ignore, m_ignore, mo_rehash, m_ignore} |
46 |
|
|
}; |
47 |
|
|
|
48 |
|
|
#ifndef STATIC_MODULES |
49 |
|
|
void |
50 |
|
|
_modinit(void) |
51 |
|
|
{ |
52 |
|
|
mod_add_cmd(&rehash_msgtab); |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
void |
56 |
|
|
_moddeinit(void) |
57 |
|
|
{ |
58 |
|
|
mod_del_cmd(&rehash_msgtab); |
59 |
|
|
} |
60 |
|
|
|
61 |
knight |
31 |
const char *_version = "$Revision$"; |
62 |
adx |
30 |
#endif |
63 |
|
|
|
64 |
|
|
/* |
65 |
|
|
* mo_rehash - REHASH message handler |
66 |
|
|
* |
67 |
|
|
*/ |
68 |
|
|
static void |
69 |
|
|
mo_rehash(struct Client *client_p, struct Client *source_p, |
70 |
|
|
int parc, char *parv[]) |
71 |
|
|
{ |
72 |
|
|
int found = 0; |
73 |
|
|
|
74 |
|
|
if (!IsOperRehash(source_p)) |
75 |
|
|
{ |
76 |
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
77 |
|
|
me.name, source_p->name, "rehash"); |
78 |
|
|
return; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
if (parc > 1) |
82 |
|
|
{ |
83 |
|
|
#ifndef _WIN32 |
84 |
|
|
if (irccmp(parv[1], "DNS") == 0) |
85 |
|
|
{ |
86 |
|
|
sendto_one(source_p, form_str(RPL_REHASHING), me.name, parv[0], "DNS"); |
87 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, "%s is rehashing DNS", |
88 |
|
|
get_oper_name(source_p)); |
89 |
|
|
restart_resolver(); /* re-read /etc/resolv.conf AGAIN? |
90 |
|
|
and close/re-open res socket */ |
91 |
|
|
found = 1; |
92 |
|
|
} |
93 |
|
|
else if (irccmp(parv[1], "FDLIMIT") == 0) |
94 |
|
|
{ |
95 |
|
|
sendto_one(source_p, form_str(RPL_REHASHING), me.name, |
96 |
|
|
parv[0], "FDLIMIT"); |
97 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, "%s is updating FDLIMIT", |
98 |
|
|
get_oper_name(source_p)); |
99 |
|
|
recalc_fdlimit(NULL); |
100 |
|
|
found = 1; |
101 |
|
|
} |
102 |
|
|
else |
103 |
|
|
#endif |
104 |
|
|
if (irccmp(parv[1], "MOTD") == 0) |
105 |
|
|
{ |
106 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
107 |
|
|
"%s is forcing re-reading of MOTD file", |
108 |
|
|
get_oper_name(source_p)); |
109 |
|
|
read_message_file(&ConfigFileEntry.motd); |
110 |
|
|
found = 1; |
111 |
|
|
} |
112 |
|
|
else if (irccmp(parv[1], "OMOTD") == 0) |
113 |
|
|
{ |
114 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
115 |
|
|
"%s is forcing re-reading of OPER MOTD file", |
116 |
|
|
get_oper_name(source_p)); |
117 |
|
|
read_message_file(&ConfigFileEntry.opermotd); |
118 |
|
|
found = 1; |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
if (found) |
122 |
|
|
{ |
123 |
|
|
ilog(L_NOTICE, "REHASH %s From %s", |
124 |
|
|
parv[1], get_client_name(source_p, HIDE_IP)); |
125 |
|
|
return; |
126 |
|
|
} |
127 |
|
|
else |
128 |
|
|
{ |
129 |
|
|
#ifdef _WIN32 |
130 |
|
|
sendto_one(source_p, ":%s NOTICE %s :rehash one of :MOTD OMOTD", |
131 |
|
|
me.name, source_p->name); |
132 |
|
|
#else |
133 |
|
|
sendto_one(source_p, ":%s NOTICE %s :rehash one of :DNS FDLIMIT " |
134 |
|
|
"MOTD OMOTD", me.name, source_p->name); |
135 |
|
|
#endif |
136 |
|
|
return; |
137 |
|
|
} |
138 |
|
|
} |
139 |
|
|
else |
140 |
|
|
{ |
141 |
|
|
sendto_one(source_p, form_str(RPL_REHASHING), |
142 |
|
|
me.name, source_p->name, ConfigFileEntry.configfile); |
143 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
144 |
|
|
"%s is rehashing server config file", |
145 |
|
|
get_oper_name(source_p)); |
146 |
|
|
ilog(L_NOTICE, "REHASH From %s[%s]", |
147 |
|
|
get_oper_name(source_p), source_p->sockhost); |
148 |
|
|
rehash(0); |
149 |
|
|
} |
150 |
|
|
} |
151 |
|
|
|