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 "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, MAXPARA, MFLG_SLOW, 0, |
45 |
{m_unregistered, m_not_oper, m_ignore, m_ignore, mo_rehash, m_ignore} |
46 |
}; |
47 |
|
48 |
void |
49 |
_modinit(void) |
50 |
{ |
51 |
mod_add_cmd(&rehash_msgtab); |
52 |
} |
53 |
|
54 |
void |
55 |
_moddeinit(void) |
56 |
{ |
57 |
mod_del_cmd(&rehash_msgtab); |
58 |
} |
59 |
|
60 |
const char *_version = "$Revision$"; |
61 |
|
62 |
/* |
63 |
* mo_rehash - REHASH message handler |
64 |
* |
65 |
*/ |
66 |
static void |
67 |
mo_rehash(struct Client *client_p, struct Client *source_p, |
68 |
int parc, char *parv[]) |
69 |
{ |
70 |
int found = 0; |
71 |
|
72 |
if (!IsOperRehash(source_p)) |
73 |
{ |
74 |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
75 |
me.name, source_p->name, "rehash"); |
76 |
return; |
77 |
} |
78 |
|
79 |
if (parc > 1) |
80 |
{ |
81 |
if (irccmp(parv[1], "DNS") == 0) |
82 |
{ |
83 |
sendto_one(source_p, form_str(RPL_REHASHING), me.name, parv[0], "DNS"); |
84 |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s is rehashing DNS", |
85 |
get_oper_name(source_p)); |
86 |
restart_resolver(); /* re-read /etc/resolv.conf AGAIN? |
87 |
and close/re-open res socket */ |
88 |
found = 1; |
89 |
} |
90 |
else if (irccmp(parv[1], "FDLIMIT") == 0) |
91 |
{ |
92 |
sendto_one(source_p, form_str(RPL_REHASHING), me.name, |
93 |
parv[0], "FDLIMIT"); |
94 |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s is updating FDLIMIT", |
95 |
get_oper_name(source_p)); |
96 |
recalc_fdlimit(NULL); |
97 |
found = 1; |
98 |
} |
99 |
else if (irccmp(parv[1], "MOTD") == 0) |
100 |
{ |
101 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
102 |
"%s is forcing re-reading of MOTD file", |
103 |
get_oper_name(source_p)); |
104 |
read_message_file(&ConfigFileEntry.motd); |
105 |
found = 1; |
106 |
} |
107 |
else if (irccmp(parv[1], "OMOTD") == 0) |
108 |
{ |
109 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
110 |
"%s is forcing re-reading of OPER MOTD file", |
111 |
get_oper_name(source_p)); |
112 |
read_message_file(&ConfigFileEntry.opermotd); |
113 |
found = 1; |
114 |
} |
115 |
|
116 |
if (found) |
117 |
{ |
118 |
ilog(L_NOTICE, "REHASH %s From %s", |
119 |
parv[1], get_client_name(source_p, HIDE_IP)); |
120 |
return; |
121 |
} |
122 |
else |
123 |
{ |
124 |
sendto_one(source_p, ":%s NOTICE %s :rehash one of :DNS FDLIMIT " |
125 |
"MOTD OMOTD", me.name, source_p->name); |
126 |
return; |
127 |
} |
128 |
} |
129 |
else |
130 |
{ |
131 |
sendto_one(source_p, form_str(RPL_REHASHING), |
132 |
me.name, source_p->name, ConfigFileEntry.configfile); |
133 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
134 |
"%s is rehashing server config file", |
135 |
get_oper_name(source_p)); |
136 |
ilog(L_NOTICE, "REHASH From %s[%s]", |
137 |
get_oper_name(source_p), source_p->sockhost); |
138 |
rehash(0); |
139 |
} |
140 |
} |