ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/contrib/m_jupe.c
Revision: 34
Committed: Sun Oct 2 21:05:51 2005 UTC (18 years, 5 months ago) by lusky
Content type: text/x-csrc
File size: 5082 byte(s)
Log Message:
create 7.2 branch, we can move/rename it as needed.


File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_jupe.c: Jupes a server.
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 "tools.h"
27 #include "irc_string.h"
28 #include "sprintf_irc.h"
29 #include "handlers.h"
30 #include "channel.h"
31 #include "client.h"
32 #include "ircd.h"
33 #include "numeric.h"
34 #include "s_log.h"
35 #include "s_serv.h"
36 #include "send.h"
37 #include "whowas.h"
38 #include "hash.h"
39 #include "msg.h"
40 #include "parse.h"
41 #include "modules.h"
42 #include "common.h"
43 #include "event.h"
44 #include "fdlist.h"
45 #include "list.h"
46 #include "s_conf.h"
47
48 static void mo_jupe(struct Client *, struct Client *, int, char *[]);
49 static int bogus_host(char *);
50
51 struct Message jupe_msgtab = {
52 "JUPE", 0, 0, 3, 0, MFLG_SLOW, 0,
53 {m_unregistered, m_not_oper, mo_jupe, m_ignore, mo_jupe, m_ignore}
54 };
55
56 #ifndef STATIC_MODULES
57 void
58 _modinit(void)
59 {
60 mod_add_cmd(&jupe_msgtab);
61 }
62
63 void
64 _moddeinit(void)
65 {
66 mod_del_cmd(&jupe_msgtab);
67 }
68
69 const char *_version = "$Revision$";
70 #endif
71
72 /*
73 * mo_jupe()
74 * parv[0] = sender prefix
75 * parv[1] = server we're juping
76 * parv[2] = reason for jupe
77 */
78 static void
79 mo_jupe(struct Client *client_p, struct Client *source_p,
80 int parc, char *parv[])
81 {
82 struct Client *target_p = NULL;
83 struct Client *ajupe = NULL;
84 dlink_node *m = NULL;
85 char reason[REALLEN + 1];
86
87 if (!IsAdmin(source_p))
88 {
89 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
90 me.name, source_p->name);
91 return;
92 }
93
94 if (*parv[2] == '\0')
95 {
96 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
97 me.name, source_p->name, "JUPE");
98 return;
99 }
100
101 if (!ServerInfo.hub)
102 {
103 sendto_one(source_p, ":%s NOTICE %s :Must be used from a hub server",
104 me.name, source_p->name);
105 return;
106 }
107
108 if (bogus_host(parv[1]))
109 {
110 sendto_one(source_p, ":%s NOTICE %s :Invalid servername: %s",
111 me.name, source_p->name, parv[1]);
112 return;
113 }
114
115 if (match(parv[1], me.name))
116 {
117 sendto_one(source_p, ":%s NOTICE %s :I can't jupe myself!",
118 me.name, source_p->name);
119 return;
120 }
121
122 /* we need to give 7 chars to prepend "JUPED: " */
123 if (strlen(parv[2]) > (REALLEN - 7))
124 parv[2][REALLEN - 7] = '\0';
125
126 sendto_wallops_flags(UMODE_WALLOP, &me,
127 "JUPE for %s requested by %s: %s",
128 parv[1], get_oper_name(source_p), parv[2]);
129
130 sendto_server(NULL, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
131 ":%s WALLOPS :JUPE for %s requested by %s!%s@%s: %s",
132 me.name, parv[1], source_p->name,
133 source_p->username, source_p->host, parv[2]);
134 ilog(L_NOTICE, "JUPE for %s requested by %s: %s",
135 parv[1], get_oper_name(source_p), parv[2]);
136
137 if ((target_p = find_server(parv[1])) != NULL)
138 exit_client(target_p, &me, parv[2]);
139
140 sendto_server(NULL, NULL, NULL, NOCAPS, NOCAPS, NOFLAGS,
141 ":%s SERVER %s 1 :JUPED: %s",
142 me.name, parv[1], parv[2]);
143
144 sendto_realops_flags(UMODE_ALL, L_ALL,
145 "Link with %s established: (JUPED) link",
146 parv[1]);
147
148 ajupe = make_client(NULL);
149
150 /* make_client() adds client to unknown_list */
151 if ((m = dlinkFindDelete(&unknown_list, ajupe)) != NULL)
152 free_dlink_node(m);
153
154 make_server(ajupe);
155
156 strlcpy(ajupe->name, parv[1], sizeof(ajupe->name));
157 ircsprintf(reason, "JUPED: %s", parv[2]);
158 strlcpy(ajupe->info, reason, sizeof(ajupe->info));
159
160 ajupe->servptr = &me;
161 ajupe->hopcount = 1;
162
163 SetServer(ajupe);
164 SetDead(ajupe);
165
166 Count.myserver++;
167
168 hash_add_client(ajupe);
169 dlinkAdd(ajupe, &ajupe->lnode, &ajupe->servptr->serv->servers);
170 dlinkAdd(ajupe, make_dlink_node(), &global_serv_list);
171
172 /* XXX is this really necessary?
173 * for now, 'cause of the way squit works
174 */
175 dlinkAdd(ajupe, &ajupe->node, &global_client_list);
176 }
177
178 /* bogus_host()
179 *
180 * inputs - hostname
181 * output - 1 if a bogus hostname input,
182 * - 0 if its valid
183 * side effects - none
184 */
185 static int
186 bogus_host(char *host)
187 {
188 unsigned int length = 0;
189 unsigned int dots = 0;
190 char *s = host;
191
192 for (; *s; s++)
193 {
194 if (!IsServChar(*s))
195 return 1;
196
197 ++length;
198
199 if ('.' == *s)
200 ++dots;
201 }
202
203 return !dots || length > HOSTLEN;
204 }

Properties

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