/[svn]/ircd-hybrid-7.2/modules/m_motd.c
ViewVC logotype

Contents of /ircd-hybrid-7.2/modules/m_motd.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 589 - (show annotations)
Mon May 8 18:40:00 2006 UTC (13 years, 6 months ago) by michael
File MIME type: text/x-chdr
File size: 4036 byte(s)
- Clear the TS6 CAPAB bit possibly set on an unregistered client connection
  in mr_motd(), mr_admin() and register_local_user(). This is a kludge for now.

1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_motd.c: Shows the current message of the day.
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 "tools.h"
28 #include "motd.h"
29 #include "ircd.h"
30 #include "send.h"
31 #include "numeric.h"
32 #include "handlers.h"
33 #include "hook.h"
34 #include "msg.h"
35 #include "s_serv.h" /* hunt_server */
36 #include "parse.h"
37 #include "modules.h"
38 #include "s_conf.h"
39
40 static void mr_motd(struct Client *, struct Client *, int, char *[]);
41 static void m_motd(struct Client*, struct Client*, int, char *[]);
42 static void mo_motd(struct Client*, struct Client*, int, char *[]);
43
44 /*
45 * note regarding mo_motd being used twice:
46 * this is not a kludge. any rate limiting, shide, or whatever
47 * other access restrictions should be done by the source's server.
48 * for security's sake, still check that the source is an oper
49 * for 'oper only' information in the mo_ function(s).
50 */
51 struct Message motd_msgtab = {
52 "MOTD", 0, 0, 0, 1, MFLG_SLOW, 0,
53 {mr_motd, m_motd, mo_motd, m_ignore, mo_motd, m_ignore}
54 };
55
56 #ifndef STATIC_MODULES
57 const char *_version = "$Revision$";
58 static struct Callback *motd_cb;
59
60 static void *
61 do_motd(va_list args)
62 {
63 struct Client *source_p = va_arg(args, struct Client *);
64
65 send_message_file(source_p, &ConfigFileEntry.motd);
66 return NULL;
67 }
68
69 void
70 _modinit(void)
71 {
72 motd_cb = register_callback("doing_motd", do_motd);
73 mod_add_cmd(&motd_msgtab);
74 }
75
76 void
77 _moddeinit(void)
78 {
79 mod_del_cmd(&motd_msgtab);
80 uninstall_hook(motd_cb, do_motd);
81 }
82 #endif
83
84 /* mr_motd()
85 *
86 * parv[0] = sender prefix
87 */
88 static void
89 mr_motd(struct Client *client_p, struct Client *source_p,
90 int parc, char *parv[])
91 {
92 ClearCap(client_p, CAP_TS6);
93 /* allow unregistered clients to see the motd, but exit them */
94 send_message_file(source_p, &ConfigFileEntry.motd);
95 exit_client(source_p, source_p, "Client Exit after MOTD");
96 }
97
98 /*
99 ** m_motd
100 ** parv[0] = sender prefix
101 ** parv[1] = servername
102 */
103 static void
104 m_motd(struct Client *client_p, struct Client *source_p,
105 int parc, char *parv[])
106 {
107 static time_t last_used = 0;
108
109 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
110 {
111 /* safe enough to give this on a local connect only */
112 sendto_one(source_p, form_str(RPL_LOAD2HI),
113 me.name, source_p->name);
114 return;
115 }
116
117 last_used = CurrentTime;
118
119 /* This is safe enough to use during non hidden server mode */
120 if (!ConfigFileEntry.disable_remote && !ConfigServerHide.hide_servers)
121 if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv)
122 != HUNTED_ISME)
123 return;
124
125 #ifdef STATIC_MODULES
126 send_message_file(source_p, &ConfigFileEntry.motd);
127 #else
128 execute_callback(motd_cb, source_p, parc, parv);
129 #endif
130 }
131
132 /*
133 ** mo_motd
134 ** parv[0] = sender prefix
135 ** parv[1] = servername
136 */
137 static void
138 mo_motd(struct Client *client_p, struct Client *source_p,
139 int parc, char *parv[])
140 {
141 if (!IsClient(source_p))
142 return;
143
144 if (hunt_server(client_p, source_p, ":%s MOTD :%s",1,parc,parv)!=HUNTED_ISME)
145 return;
146
147 #ifdef STATIC_MODULES
148 send_message_file(source_p, &ConfigFileEntry.motd);
149 #else
150 execute_callback(motd_cb, source_p, parc, parv);
151 #endif
152 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26