ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_userhost.c
Revision: 1405
Committed: Thu May 10 20:56:39 2012 UTC (14 years, 5 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_userhost.c
File size: 3772 byte(s)
Log Message:
- m_userhost(): don't leak irc operator status in case the status is hidden

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_userhost.c: Shows a user's host.
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 "ircd.h"
28 #include "numeric.h"
29 #include "s_serv.h"
30 #include "send.h"
31 #include "irc_string.h"
32 #include "sprintf_irc.h"
33 #include "parse.h"
34 #include "modules.h"
35
36
37 /*
38 * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
39 * the need for complicated requests like WHOIS. It returns user/host
40 * information only (no spurious AWAY labels or channels).
41 */
42 static void
43 m_userhost(struct Client *client_p, struct Client *source_p,
44 int parc, char *parv[])
45 {
46 struct Client *target_p;
47 char buf[IRCD_BUFSIZE];
48 char response[NICKLEN*2+USERLEN+HOSTLEN+30];
49 char *t = NULL, *p = NULL, *nick = NULL;
50 int i = 0; /* loop counter */
51 int cur_len;
52 int rl;
53
54 cur_len = snprintf(buf, sizeof(buf), form_str(RPL_USERHOST), me.name, source_p->name, "");
55 t = buf + cur_len;
56
57 for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;
58 nick = strtoken(&p, NULL, " "))
59 {
60 if ((target_p = find_person(client_p, nick)) != NULL)
61 {
62 /*
63 * Show real IP for USERHOST on yourself.
64 * This is needed for things like mIRC, which do a server-based
65 * lookup (USERHOST) to figure out what the clients' local IP
66 * is. Useful for things like NAT, and dynamic dial-up users.
67 */
68 if (MyClient(target_p) && (target_p == source_p))
69 {
70 rl = ircsprintf(response, "%s%s=%c%s@%s ",
71 target_p->name,
72 HasUMode(target_p, UMODE_OPER) ? "*" : "",
73 (target_p->away) ? '-' : '+',
74 target_p->username,
75 target_p->sockhost);
76 }
77 else
78 {
79 rl = ircsprintf(response, "%s%s=%c%s@%s ",
80 target_p->name, (HasUMode(target_p, UMODE_OPER) &&
81 (!HasUMode(target_p, UMODE_HIDDEN) ||
82 HasUMode(source_p, UMODE_OPER))) ? "*" : "",
83 (target_p->away) ? '-' : '+',
84 target_p->username,
85 target_p->host);
86 }
87
88 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
89 {
90 ircsprintf(t, "%s", response);
91 t += rl;
92 cur_len += rl;
93 }
94 else
95 break;
96 }
97 }
98
99 sendto_one(source_p, "%s", buf);
100 }
101
102 static struct Message userhost_msgtab = {
103 "USERHOST", 0, 0, 1, 1, MFLG_SLOW, 0,
104 {m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore}
105 };
106
107 static void
108 module_init(void)
109 {
110 mod_add_cmd(&userhost_msgtab);
111 }
112
113 static void
114 module_exit(void)
115 {
116 mod_del_cmd(&userhost_msgtab);
117 }
118
119 struct module module_entry = {
120 .node = { NULL, NULL, NULL },
121 .name = NULL,
122 .version = "$Revision$",
123 .handle = NULL,
124 .modinit = module_init,
125 .modexit = module_exit,
126 .flags = 0
127 };

Properties

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