ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_admin.c
(Generate patch)

Comparing:
ircd-hybrid-7.2/modules/m_admin.c (file contents), Revision 1007 by michael, Tue Sep 1 15:25:26 2009 UTC vs.
ircd-hybrid/trunk/modules/m_admin.c (file contents), Revision 3300 by michael, Sat Apr 12 18:26:22 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 25 | Line 25
25   */
26  
27   #include "stdinc.h"
28 #include "handlers.h"
28   #include "client.h"
29 + #include "irc_string.h"
30   #include "ircd.h"
31   #include "numeric.h"
32 < #include "s_conf.h"
32 > #include "conf.h"
33   #include "s_serv.h"
34   #include "send.h"
35 #include "msg.h"
35   #include "parse.h"
37 #include "hook.h"
36   #include "modules.h"
39 #include "irc_string.h"
40
41 static void m_admin(struct Client *, struct Client *, int, char *[]);
42 static void mr_admin(struct Client *, struct Client *, int, char *[]);
43 static void ms_admin(struct Client *, struct Client *, int, char *[]);
44 static void do_admin(struct Client *);
45
46 struct Message admin_msgtab = {
47  "ADMIN", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
48  {mr_admin, m_admin, ms_admin, m_ignore, ms_admin, m_ignore}
49 };
37  
51 #ifndef STATIC_MODULES
52 static struct Callback *admin_cb;
53 const char *_version = "$Revision$";
54
55 static void *
56 va_admin(va_list args)
57 {
58  do_admin(va_arg(args, struct Client *));
59  return NULL;
60 }
38  
62 void
63 _modinit(void)
64 {
65  admin_cb = register_callback("doing_admin", va_admin);
66  mod_add_cmd(&admin_msgtab);
67 }
68
69 void
70 _moddeinit(void)
71 {
72  mod_del_cmd(&admin_msgtab);
73  uninstall_hook(admin_cb, va_admin);
74 }
75 #endif
39  
40 < /*! \brief ADMIN command handler (called by unregistered,
78 < *         locally connected clients)
40 > /*! \brief Sends administrative information about this server.
41   *
42 < * \param client_p Pointer to allocated Client struct with physical connection
81 < *                 to this server, i.e. with an open socket connected.
82 < * \param source_p Pointer to allocated Client struct from which the message
83 < *                 originally comes from.  This can be a local or remote client.
84 < * \param parc     Integer holding the number of supplied arguments.
85 < * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
86 < *                 pointers.
87 < * \note Valid arguments for this command are:
88 < *      - parv[0] = sender prefix
42 > * \param source_p Pointer to client to report to
43   */
44   static void
45 < mr_admin(struct Client *client_p, struct Client *source_p,
92 <         int parc, char *parv[])
45 > do_admin(struct Client *source_p)
46   {
47 <  static time_t last_used = 0;
48 <
49 <  ClearCap(client_p, CAP_TS6);
50 <
51 <  if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
52 <  {
53 <    sendto_one(source_p, form_str(RPL_LOAD2HI),
54 <               me.name, EmptyString(parv[0]) ? "*" : parv[0]);
55 <    return;
56 <  }
57 <
58 <  last_used = CurrentTime;
59 <
107 < #ifdef STATIC_MODULES
108 <  do_admin(client_p);
109 < #else
110 <  execute_callback(admin_cb, source_p, parc, parv);
111 < #endif
47 >  sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
48 >                       "ADMIN requested by %s (%s@%s) [%s]",
49 >                       source_p->name, source_p->username,
50 >                       source_p->host, source_p->servptr->name);
51 >
52 >  sendto_one_numeric(source_p, &me, RPL_ADMINME, me.name);
53 >
54 >  if (!EmptyString(AdminInfo.name))
55 >    sendto_one_numeric(source_p, &me, RPL_ADMINLOC1, AdminInfo.name);
56 >  if (!EmptyString(AdminInfo.description))
57 >    sendto_one_numeric(source_p, &me, RPL_ADMINLOC2, AdminInfo.description);
58 >  if (!EmptyString(AdminInfo.email))
59 >    sendto_one_numeric(source_p, &me, RPL_ADMINEMAIL, AdminInfo.email);
60   }
61  
62 < /*! \brief NICK command handler (called by already registered,
115 < *         locally connected clients)
62 > /*! \brief ADMIN command handler
63   *
117 * \param client_p Pointer to allocated Client struct with physical connection
118 *                 to this server, i.e. with an open socket connected.
64   * \param source_p Pointer to allocated Client struct from which the message
65   *                 originally comes from.  This can be a local or remote client.
66   * \param parc     Integer holding the number of supplied arguments.
67   * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
68   *                 pointers.
69   * \note Valid arguments for this command are:
70 < *      - parv[0] = sender prefix
70 > *      - parv[0] = command
71   *      - parv[1] = nickname/servername
72   */
73 < static void
74 < m_admin(struct Client *client_p, struct Client *source_p,
130 <        int parc, char *parv[])
73 > static int
74 > m_admin(struct Client *source_p, int parc, char *parv[])
75   {
76    static time_t last_used = 0;
77  
78    if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
79    {
80 <    sendto_one(source_p,form_str(RPL_LOAD2HI),
81 <               me.name, source_p->name);
138 <    return;
80 >    sendto_one_numeric(source_p, &me, RPL_LOAD2HI);
81 >    return 0;
82    }
83  
84    last_used = CurrentTime;
85  
86 <  if (!ConfigFileEntry.disable_remote)
87 <    if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
86 >  if (!ConfigServerHide.disable_remote_commands)
87 >    if (hunt_server(source_p, ":%s ADMIN :%s", 1,
88                      parc, parv) != HUNTED_ISME)
89 <      return;
89 >      return 0;
90  
91 < #ifdef STATIC_MODULES
92 <  do_admin(client_p);
150 < #else
151 <  execute_callback(admin_cb, source_p, parc, parv);
152 < #endif
91 >  do_admin(source_p);
92 >  return 0;
93   }
94  
95 < /*! \brief ADMIN command handler (called by operators and
156 < *         remotely connected clients)
95 > /*! \brief ADMIN command handler
96   *
158 * \param client_p Pointer to allocated Client struct with physical connection
159 *                 to this server, i.e. with an open socket connected.
97   * \param source_p Pointer to allocated Client struct from which the message
98   *                 originally comes from.  This can be a local or remote client.
99   * \param parc     Integer holding the number of supplied arguments.
100   * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
101   *                 pointers.
102   * \note Valid arguments for this command are:
103 < *      - parv[0] = sender prefix
103 > *      - parv[0] = command
104   *      - parv[1] = nickname/servername
105   */
106 < static void
107 < ms_admin(struct Client *client_p, struct Client *source_p,
171 <         int parc, char *parv[])
106 > static int
107 > ms_admin(struct Client *source_p, int parc, char *parv[])
108   {
109 <  if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv)
110 <                  != HUNTED_ISME)
111 <    return;
112 <
113 <  if (IsClient(source_p))
114 < #ifdef STATIC_MODULES
179 <    do_admin(source_p);
180 < #else
181 <    execute_callback(admin_cb, source_p, parc, parv);
182 < #endif
109 >  if (hunt_server(source_p, ":%s ADMIN :%s", 1,
110 >                  parc, parv) != HUNTED_ISME)
111 >    return 0;
112 >
113 >  do_admin(source_p);
114 >  return 0;
115   }
116  
117 < /*! \brief Sends administrative information about this server.
186 < *
187 < * \param source_p Pointer to client to report to
188 < */
189 < static void
190 < do_admin(struct Client *source_p)
117 > static struct Message admin_msgtab =
118   {
119 <  const char *me_name;
120 <  const char *nick;
119 >  "ADMIN", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
120 >  { m_unregistered, m_admin, ms_admin, m_ignore, ms_admin, m_ignore }
121 > };
122  
123 <  me_name = ID_or_name(&me, source_p->from);
124 <  nick = ID_or_name(source_p, source_p->from);
123 > static void
124 > module_init(void)
125 > {
126 >  mod_add_cmd(&admin_msgtab);
127 > }
128  
129 <  sendto_one(source_p, form_str(RPL_ADMINME),
130 <             me_name, nick, me.name);
131 <  if (AdminInfo.name != NULL)
132 <    sendto_one(source_p, form_str(RPL_ADMINLOC1),
202 <               me_name, nick, AdminInfo.name);
203 <  if (AdminInfo.description != NULL)
204 <    sendto_one(source_p, form_str(RPL_ADMINLOC2),
205 <               me_name, nick, AdminInfo.description);
206 <  if (AdminInfo.email != NULL)
207 <    sendto_one(source_p, form_str(RPL_ADMINEMAIL),
208 <               me_name, nick, AdminInfo.email);
129 > static void
130 > module_exit(void)
131 > {
132 >  mod_del_cmd(&admin_msgtab);
133   }
134 +
135 + struct module module_entry =
136 + {
137 +  .node    = { NULL, NULL, NULL },
138 +  .name    = NULL,
139 +  .version = "$Revision$",
140 +  .handle  = NULL,
141 +  .modinit = module_init,
142 +  .modexit = module_exit,
143 +  .flags   = 0
144 + };

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)