ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_etrace.c
Revision: 171
Committed: Fri Oct 21 22:02:41 2005 UTC (20 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 4633 byte(s)
Log Message:
- ETRACE should spit out an error if used by a non-oper.  Reported by nenolod

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_etrace.c: Traces a path to a client/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 "handlers.h"
27 #include "client.h"
28 #include "hash.h"
29 #include "common.h"
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "s_serv.h"
33 #include "send.h"
34 #include "msg.h"
35 #include "parse.h"
36 #include "modules.h"
37 #include "s_conf.h"
38
39 #define FORM_STR_RPL_ETRACE ":%s 709 %s %s %s %s %s %s :%s"
40
41 static void do_etrace(struct Client *, int, char **);
42 static void mo_etrace(struct Client *, struct Client *, int, char *[]);
43
44 struct Message etrace_msgtab = {
45 "ETRACE", 0, 0, 0, 0, MFLG_SLOW, 0,
46 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_etrace, m_ignore}
47 };
48
49 #ifndef STATIC_MODULES
50 const char *_version = "$Revision$";
51 static struct Callback *etrace_cb;
52
53 static void *
54 va_etrace(va_list args)
55 {
56 struct Client *source_p = va_arg(args, struct Client *);
57 int parc = va_arg(args, int);
58 char **parv = va_arg(args, char **);
59
60 do_etrace(source_p, parc, parv);
61 return NULL;
62 }
63
64 void
65 _modinit(void)
66 {
67 etrace_cb = register_callback("doing_etrace", va_etrace);
68 mod_add_cmd(&etrace_msgtab);
69 }
70
71 void
72 _moddeinit(void)
73 {
74 mod_del_cmd(&etrace_msgtab);
75 uninstall_hook(etrace_cb, va_etrace);
76 }
77 #endif
78
79 static void report_this_status(struct Client *, struct Client *);
80
81 /*
82 * do_etrace()
83 */
84 static void
85 do_etrace(struct Client *source_p, int parc, char **parv)
86 {
87 const char *tname = NULL;
88 struct Client *target_p = NULL;
89 int wilds = 0;
90 int do_all = 0;
91 dlink_node *ptr;
92
93 if (parc > 0)
94 {
95 tname = parv[1];
96 if (tname != NULL)
97 wilds = strchr(tname, '*') || strchr(tname, '?');
98 else
99 tname = "*";
100 }
101 else
102 {
103 do_all = 1;
104 tname = "*";
105 }
106
107 if (!wilds && !do_all)
108 {
109 target_p = find_client(tname);
110
111 if (target_p && MyClient(target_p))
112 report_this_status(source_p, target_p);
113
114 sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
115 source_p->name, tname);
116 return;
117 }
118
119 DLINK_FOREACH(ptr, local_client_list.head)
120 {
121 target_p = ptr->data;
122
123 if (wilds)
124 {
125 if (match(tname, target_p->name) || match(target_p->name, tname))
126 report_this_status(source_p, target_p);
127 }
128 else
129 report_this_status(source_p, target_p);
130 }
131
132 sendto_one(source_p, form_str(RPL_ENDOFTRACE), me.name,
133 source_p->name, tname);
134 }
135
136 /* mo_etrace()
137 * parv[0] = sender prefix
138 * parv[1] = servername
139 */
140 static void
141 mo_etrace(struct Client *client_p, struct Client *source_p,
142 int parc, char *parv[])
143 {
144 #ifdef STATIC_MODULES
145 do_etrace(source_p, parc, parv);
146 #else
147 execute_callback(etrace_cb, source_p, parc, parv);
148 #endif
149 }
150
151 /* report_this_status()
152 *
153 * inputs - pointer to client to report to
154 * - pointer to client to report about
155 * output - NONE
156 * side effects - NONE
157 */
158 static void
159 report_this_status(struct Client *source_p, struct Client *target_p)
160 {
161 const char *name;
162 const char *class_name;
163 char ip[HOSTIPLEN];
164
165 /* Should this be sockhost? - stu */
166 irc_getnameinfo((struct sockaddr*)&target_p->localClient->ip,
167 target_p->localClient->ip.ss_len, ip, HOSTIPLEN, NULL, 0,
168 NI_NUMERICHOST);
169
170 name = get_client_name(target_p, HIDE_IP);
171 class_name = get_client_className(target_p);
172
173 set_time();
174
175 if (target_p->status == STAT_CLIENT)
176 {
177 if (ConfigFileEntry.hide_spoof_ips)
178 sendto_one(source_p, FORM_STR_RPL_ETRACE,
179 me.name, source_p->name,
180 IsOper(target_p) ? "Oper" : "User",
181 class_name,
182 target_p->name, target_p->username,
183 IsIPSpoof(target_p) ? "255.255.255.255" : ip,
184 target_p->info);
185 else
186 sendto_one(source_p, FORM_STR_RPL_ETRACE,
187 me.name, source_p->name,
188 IsOper(target_p) ? "Oper" : "User",
189 class_name,
190 target_p->name, target_p->username, ip,
191 target_p->info);
192 }
193 }

Properties

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