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

Comparing:
ircd-hybrid-8/modules/m_set.c (file contents), Revision 1243 by michael, Fri Sep 30 10:47:53 2011 UTC vs.
ircd-hybrid/trunk/modules/m_set.c (file contents), Revision 2433 by michael, Fri Aug 2 18:43:00 2013 UTC

# Line 35 | Line 35
35   #include "s_serv.h"
36   #include "send.h"
37   #include "channel.h"
38 < #include "s_log.h"
39 < #include "s_conf.h"
38 > #include "conf.h"
39   #include "parse.h"
40   #include "modules.h"
41   #include "s_user.h"
42   #include "s_misc.h"
43  
44  
46 – /* Structure used for the SET table itself */
47 – struct SetStruct
48 – {
49 –  const char *name;
50 –  void (*handler)();
51 –  const int wants_char; /* 1 if it expects (char *, [int]) */
52 –  const int wants_int;  /* 1 if it expects ([char *], int) */
53 –  /* eg:  0, 1 == only an int arg
54 –   * eg:  1, 1 == char and int args */
55 – };
56 –
57 – static void quote_autoconn(struct Client *, const char *, int);
58 – static void quote_autoconnall(struct Client *, int);
59 – static void quote_floodcount(struct Client *, int);
60 – static void quote_identtimeout(struct Client *, int);
61 – static void quote_log(struct Client *, int);
62 – static void quote_max(struct Client *, int);
63 – static void quote_msglocale(struct Client *, char *);
64 – static void quote_spamnum(struct Client *, int);
65 – static void quote_spamtime(struct Client *, int);
66 – static void quote_splitmode(struct Client *, char *);
67 – static void quote_splitnum(struct Client *, int);
68 – static void quote_splitusers(struct Client *, int);
69 – static void list_quote_commands(struct Client *);
70 – static void quote_jfloodtime(struct Client *, int);
71 – static void quote_jfloodcount(struct Client *, int);
72 – static void quote_rejecttime(struct Client *, int);
73 –
74 – /*
75 – * If this ever needs to be expanded to more than one arg of each
76 – * type, want_char/want_int could be the count of the arguments,
77 – * instead of just a boolean flag...
78 – *
79 – * -davidt
80 – */
81 –
82 – static const struct SetStruct set_cmd_table[] =
83 – {
84 –  /* name               function        string arg  int arg */
85 –  /* -------------------------------------------------------- */
86 –  { "AUTOCONN",         quote_autoconn,         1,      1 },
87 –  { "AUTOCONNALL",      quote_autoconnall,      0,      1 },
88 –  { "FLOODCOUNT",       quote_floodcount,       0,      1 },
89 –  { "IDENTTIMEOUT",     quote_identtimeout,     0,      1 },
90 –  { "LOG",              quote_log,              0,      1 },
91 –  { "MAX",              quote_max,              0,      1 },
92 –  { "MSGLOCALE",        quote_msglocale,        1,      0 },
93 –  { "SPAMNUM",          quote_spamnum,          0,      1 },
94 –  { "SPAMTIME",         quote_spamtime,         0,      1 },
95 –  { "SPLITMODE",        quote_splitmode,        1,      0 },
96 –  { "SPLITNUM",         quote_splitnum,         0,      1 },
97 –  { "SPLITUSERS",       quote_splitusers,       0,      1 },
98 –  { "JFLOODTIME",       quote_jfloodtime,       0,      1 },
99 –  { "JFLOODCOUNT",      quote_jfloodcount,      0,      1 },
100 –  { "REJECTTIME",       quote_rejecttime,       0,      1 },
101 –  /* -------------------------------------------------------- */
102 –  { NULL,               NULL,                   0,      0 }
103 – };
104 –
105 – /*
106 – * list_quote_commands() sends the client all the available commands.
107 – * Four to a line for now.
108 – */
109 – static void
110 – list_quote_commands(struct Client *source_p)
111 – {
112 –  int j = 0;
113 –  const struct SetStruct *tab = set_cmd_table;
114 –  const char *names[4] = { "", "", "", "" };
115 –
116 –  sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:",
117 –             me.name, source_p->name);
118 –
119 –  for (; tab->handler; ++tab)
120 –  {
121 –    names[j++] = tab->name;
122 –
123 –    if (j > 3)
124 –    {
125 –      sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
126 –                 me.name, source_p->name,
127 –                 names[0], names[1],
128 –                 names[2], names[3]);
129 –      j = 0;
130 –      names[0] = names[1] = names[2] = names[3] = "";
131 –    }
132 –
133 –  }
134 –
135 –  if (j)
136 –    sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
137 –               me.name, source_p->name,
138 –               names[0], names[1],
139 –               names[2], names[3]);
140 – }
141 –
45   /* SET AUTOCONN */
46   static void
47   quote_autoconn(struct Client *source_p, const char *arg, int newval)
48   {
146 –  struct AccessItem *aconf;
147 –
49    if (arg != NULL)
50    {
51 <    struct ConfItem *conf = find_exact_name_conf(SERVER_TYPE, arg, NULL, NULL);
51 >    struct MaskItem *conf = find_exact_name_conf(CONF_SERVER, NULL, arg, NULL, NULL);
52  
53      if (conf != NULL)
54      {
154 –      aconf = map_to_conf(conf);
55        if (newval)
56 <        SetConfAllowAutoConn(aconf);
56 >        SetConfAllowAutoConn(conf);
57        else
58 <        ClearConfAllowAutoConn(aconf);
58 >        ClearConfAllowAutoConn(conf);
59  
60 <      sendto_realops_flags(UMODE_ALL, L_ALL,
60 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
61                             "%s has changed AUTOCONN for %s to %i",
62                             get_oper_name(source_p), arg, newval);
63        sendto_one(source_p,
# Line 183 | Line 83 | quote_autoconnall(struct Client *source_
83   {
84    if (newval >= 0)
85    {
86 <    sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed AUTOCONNALL to %i",
86 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
87 >                         "%s has changed AUTOCONNALL to %i",
88                           get_oper_name(source_p), newval);
89  
90      GlobalSetOptions.autoconn = newval;
# Line 200 | Line 101 | quote_floodcount(struct Client *source_p
101    if (newval >= 0)
102    {
103      GlobalSetOptions.floodcount = newval;
104 <    sendto_realops_flags(UMODE_ALL, L_ALL,
104 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
105                           "%s has changed FLOODCOUNT to %i",
106                           get_oper_name(source_p), GlobalSetOptions.floodcount);
107    }
# Line 222 | Line 123 | quote_identtimeout(struct Client *source
123  
124    if (newval > 0)
125    {
126 <    sendto_realops_flags(UMODE_ALL, L_ALL,
127 <                         "%s has changed IDENTTIMEOUT to %d",
128 <                         get_oper_name(source_p), newval);
126 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
127 >                         "%s has changed IDENTTIMEOUT to %d",
128 >                         get_oper_name(source_p), newval);
129      GlobalSetOptions.ident_timeout = newval;
130    }
131    else
132      sendto_one(source_p, ":%s NOTICE %s :IDENTTIMEOUT is currently %d",
133 <               me.name, source_p->name, GlobalSetOptions.ident_timeout);
233 < }
234 <
235 < /* SET LOG */
236 < static void
237 < quote_log(struct Client *source_p, int newval)
238 < {
239 <  if (newval >= 0)
240 <  {
241 <    if (newval < L_WARN)
242 <    {
243 <      sendto_one(source_p, ":%s NOTICE %s :LOG must be > %d (L_WARN)",
244 <                 me.name, source_p->name, L_WARN);
245 <      return;
246 <    }
247 <
248 <    if (newval > L_DEBUG)
249 <      newval = L_DEBUG;
250 <
251 <    set_log_level(newval);
252 <    sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed LOG level to %i (%s)",
253 <                         get_oper_name(source_p), get_log_level(),
254 <                         get_log_level_as_string(get_log_level()));
255 <  }
256 <  else
257 <    sendto_one(source_p, ":%s NOTICE %s :LOG level is currently %i (%s)",
258 <               me.name, source_p->name, get_log_level(),
259 <               get_log_level_as_string(get_log_level()));
133 >               me.name, source_p->name, GlobalSetOptions.ident_timeout);
134   }
135  
136   /* SET MAX */
# Line 265 | Line 139 | quote_max(struct Client *source_p, int n
139   {
140    if (newval > 0)
141    {
268 –    recalc_fdlimit(NULL);
269 –
142      if (newval > MAXCLIENTS_MAX)
143      {
144        sendto_one(source_p,
145          ":%s NOTICE %s :You cannot set MAXCLIENTS to > %d, restoring to %d",
146 <        me.name, source_p->name, MAXCLIENTS_MAX, ServerInfo.max_clients);
146 >        me.name, source_p->name, MAXCLIENTS_MAX, ServerInfo.max_clients);
147        return;
148      }
149  
150      if (newval < MAXCLIENTS_MIN)
151      {
152        sendto_one(source_p,
153 <        ":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d",
154 <        me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients);
153 >        ":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d",
154 >        me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients);
155        return;
156      }
157  
158      ServerInfo.max_clients = newval;
159  
160 <    sendto_realops_flags(UMODE_ALL, L_ALL,
161 <        "%s set new MAXCLIENTS to %d (%d current)",
162 <        get_oper_name(source_p), ServerInfo.max_clients, Count.local);
160 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
161 >        "%s set new MAXCLIENTS to %d (%d current)",
162 >        get_oper_name(source_p), ServerInfo.max_clients, Count.local);
163    }
164    else
165      sendto_one(source_p, ":%s NOTICE %s :Current MAXCLIENTS = %d (%d)",
166                 me.name, source_p->name, ServerInfo.max_clients, Count.local);
167   }
168  
297 – /* SET MSGLOCALE */
298 – static void
299 – quote_msglocale(struct Client *source_p, char *locale)
300 – {
301 –  if (locale != NULL)
302 –  {
303 –    set_locale(locale);
304 –    rebuild_isupport_message_line();
305 –    sendto_one(source_p, ":%s NOTICE %s :Set MSGLOCALE to '%s'",
306 –               me.name, source_p->name, get_locale());
307 –  }
308 –  else
309 –    sendto_one(source_p, ":%s NOTICE %s :MSGLOCALE is currently '%s'",
310 –               me.name, source_p->name, get_locale());
311 – }
312 –
169   /* SET SPAMNUM */
170   static void
171   quote_spamnum(struct Client *source_p, int newval)
# Line 318 | Line 174 | quote_spamnum(struct Client *source_p, i
174    {
175      if (newval == 0)
176      {
177 <      sendto_realops_flags(UMODE_ALL, L_ALL,
177 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
178                             "%s has disabled ANTI_SPAMBOT", source_p->name);
179        GlobalSetOptions.spam_num = newval;
180        return;
181      }
182  
183      GlobalSetOptions.spam_num = IRCD_MAX(newval, MIN_SPAM_NUM);
184 <    sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMNUM to %i",
184 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
185 >                         "%s has changed SPAMNUM to %i",
186                           get_oper_name(source_p), GlobalSetOptions.spam_num);
187    }
188    else
# Line 340 | Line 197 | quote_spamtime(struct Client *source_p,
197    if (newval > 0)
198    {
199      GlobalSetOptions.spam_time = IRCD_MAX(newval, MIN_SPAM_TIME);
200 <    sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMTIME to %i",
200 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
201 >                         "%s has changed SPAMTIME to %i",
202                           get_oper_name(source_p), GlobalSetOptions.spam_time);
203    }
204    else
# Line 382 | Line 240 | quote_splitmode(struct Client *source_p,
240      /* OFF */
241      if (newval == 0)
242      {
243 <      sendto_realops_flags(UMODE_ALL, L_ALL,
243 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
244                             "%s is disabling splitmode",
245                             get_oper_name(source_p));
246  
# Line 394 | Line 252 | quote_splitmode(struct Client *source_p,
252      /* ON */
253      else if (newval == 1)
254      {
255 <      sendto_realops_flags(UMODE_ALL, L_ALL,
255 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
256                             "%s is enabling and activating splitmode",
257 <                           get_oper_name(source_p));
258 <                
257 >                           get_oper_name(source_p));
258 >
259        splitmode = 1;
260        splitchecking = 0;
261  
# Line 407 | Line 265 | quote_splitmode(struct Client *source_p,
265      /* AUTO */
266      else if (newval == 2)
267      {
268 <      sendto_realops_flags(UMODE_ALL, L_ALL,
268 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
269                             "%s is enabling automatic splitmode",
270 <                           get_oper_name(source_p));
270 >                           get_oper_name(source_p));
271  
272        splitchecking = 1;
273        check_splitmode(NULL);
# Line 422 | Line 280 | quote_splitmode(struct Client *source_p,
280       */
281      sendto_one(source_p, ":%s NOTICE %s :SPLITMODE is currently %s",
282                 me.name, source_p->name,
283 <               splitmode_status[(splitchecking + (splitmode * 2))]);
283 >               splitmode_status[(splitchecking + (splitmode * 2))]);
284   }
285  
286   /* SET SPLITNUM */
# Line 431 | Line 289 | quote_splitnum(struct Client *source_p,
289   {
290    if (newval >= 0)
291    {
292 <    sendto_realops_flags(UMODE_ALL, L_ALL,
292 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
293                           "%s has changed SPLITNUM to %i",
294 <                         get_oper_name(source_p), newval);
294 >                         get_oper_name(source_p), newval);
295      split_servers = newval;
296  
297      if (splitchecking)
# Line 450 | Line 308 | quote_splitusers(struct Client *source_p
308   {
309    if (newval >= 0)
310    {
311 <    sendto_realops_flags(UMODE_ALL, L_ALL,
311 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
312                           "%s has changed SPLITUSERS to %i",
313 <                         get_oper_name(source_p), newval);
313 >                         get_oper_name(source_p), newval);
314      split_users = newval;
315  
316      if (splitchecking)
# Line 469 | Line 327 | quote_jfloodtime(struct Client *source_p
327   {
328    if (newval >= 0)
329    {
330 <    sendto_realops_flags(UMODE_ALL, L_ALL,
330 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
331                           "%s has changed JFLOODTIME to %i",
332 <                         get_oper_name(source_p), newval);
332 >                         get_oper_name(source_p), newval);
333      GlobalSetOptions.joinfloodtime = newval;
334    }
335    else
# Line 485 | Line 343 | quote_jfloodcount(struct Client *source_
343   {
344    if (newval >= 0)
345    {
346 <    sendto_realops_flags(UMODE_ALL, L_ALL,
346 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
347                           "%s has changed JFLOODCOUNT to %i",
348 <                         get_oper_name(source_p), newval);
348 >                         get_oper_name(source_p), newval);
349      GlobalSetOptions.joinfloodcount = newval;
350    }
351    else
# Line 495 | Line 353 | quote_jfloodcount(struct Client *source_
353                 me.name, source_p->name, GlobalSetOptions.joinfloodcount);
354   }
355  
356 < /* SET REJECTTIME */
356 > /* Structure used for the SET table itself */
357 > struct SetStruct
358 > {
359 >  const char *name;
360 >  void (*handler)();
361 >  const int wants_char; /* 1 if it expects (char *, [int]) */
362 >  const int wants_int;  /* 1 if it expects ([char *], int) */
363 >  /* eg:  0, 1 == only an int arg
364 >   * eg:  1, 1 == char and int args */
365 > };
366 >
367 > /*
368 > * If this ever needs to be expanded to more than one arg of each
369 > * type, want_char/want_int could be the count of the arguments,
370 > * instead of just a boolean flag...
371 > *
372 > * -davidt
373 > */
374 > static const struct SetStruct set_cmd_table[] =
375 > {
376 >  /* name               function        string arg  int arg */
377 >  /* -------------------------------------------------------- */
378 >  { "AUTOCONN",         quote_autoconn,         1,      1 },
379 >  { "AUTOCONNALL",      quote_autoconnall,      0,      1 },
380 >  { "FLOODCOUNT",       quote_floodcount,       0,      1 },
381 >  { "IDENTTIMEOUT",     quote_identtimeout,     0,      1 },
382 >  { "MAX",              quote_max,              0,      1 },
383 >  { "SPAMNUM",          quote_spamnum,          0,      1 },
384 >  { "SPAMTIME",         quote_spamtime,         0,      1 },
385 >  { "SPLITMODE",        quote_splitmode,        1,      0 },
386 >  { "SPLITNUM",         quote_splitnum,         0,      1 },
387 >  { "SPLITUSERS",       quote_splitusers,       0,      1 },
388 >  { "JFLOODTIME",       quote_jfloodtime,       0,      1 },
389 >  { "JFLOODCOUNT",      quote_jfloodcount,      0,      1 },
390 >  /* -------------------------------------------------------- */
391 >  { NULL,               NULL,                   0,      0 }
392 > };
393 >
394 > /*
395 > * list_quote_commands() sends the client all the available commands.
396 > * Four to a line for now.
397 > */
398   static void
399 < quote_rejecttime(struct Client *source_p, int newval)
399 > list_quote_commands(struct Client *source_p)
400   {
401 <  if (newval >= 0)
401 >  int j = 0;
402 >  const struct SetStruct *tab = set_cmd_table;
403 >  const char *names[4] = { "", "", "", "" };
404 >
405 >  sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:",
406 >             me.name, source_p->name);
407 >
408 >  for (; tab->handler; ++tab)
409    {
410 <    sendto_realops_flags(UMODE_ALL, L_ALL,
411 <                         "%s has changed REJECTTIME to %i seconds",
412 <                         get_oper_name(source_p), newval);
413 <    GlobalSetOptions.rejecttime = newval;
410 >    names[j++] = tab->name;
411 >
412 >    if (j > 3)
413 >    {
414 >      sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
415 >                 me.name, source_p->name,
416 >                 names[0], names[1],
417 >                 names[2], names[3]);
418 >      j = 0;
419 >      names[0] = names[1] = names[2] = names[3] = "";
420 >    }
421 >
422    }
423 <  else
424 <    sendto_one(source_p, ":%s NOTICE %s :REJECTTIME is currently %i seconds",
425 <               me.name, source_p->name, GlobalSetOptions.rejecttime);
423 >
424 >  if (j)
425 >    sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
426 >               me.name, source_p->name,
427 >               names[0], names[1],
428 >               names[2], names[3]);
429   }
430  
431   /*
# Line 525 | Line 442 | mo_set(struct Client *client_p, struct C
442    const char *intarg = NULL;
443    const struct SetStruct *tab = set_cmd_table;
444  
445 +  if (!HasOFlag(source_p, OPER_FLAG_SET))
446 +  {
447 +    sendto_one(source_p, form_str(ERR_NOPRIVS),
448 +               me.name, source_p->name, "set");
449 +    return;
450 +  }
451 +
452    if (parc > 1)
453    {
454      /*
# Line 581 | Line 505 | mo_set(struct Client *client_p, struct C
505                newval = atoi(intarg);
506            }
507            else
584 –          {
508              newval = -1;
586 –          }
509  
510            if (newval < 0)
511            {
# Line 633 | Line 555 | mo_set(struct Client *client_p, struct C
555  
556   static struct Message set_msgtab = {
557    "SET", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
558 <  {m_unregistered, m_not_oper, rfc1459_command_send_error, m_ignore, mo_set, m_ignore}
558 >  {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_set, m_ignore}
559   };
560  
561   static void

Diff Legend

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