Anope IRC Services  Version 1.8
cs_set.c
Go to the documentation of this file.
1 /* ChanServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 /*************************************************************************/
14 
15 #include "module.h"
16 #include "encrypt.h"
17 
18 static int do_set(User * u);
19 static int do_set_founder(User * u, ChannelInfo * ci, char *param);
20 static int do_set_successor(User * u, ChannelInfo * ci, char *param);
21 static int do_set_password(User * u, ChannelInfo * ci, char *param);
22 static int do_set_desc(User * u, ChannelInfo * ci, char *param);
23 static int do_set_url(User * u, ChannelInfo * ci, char *param);
24 static int do_set_email(User * u, ChannelInfo * ci, char *param);
25 static int do_set_entrymsg(User * u, ChannelInfo * ci, char *param);
26 static int do_set_bantype(User * u, ChannelInfo * ci, char *param);
27 static int do_set_mlock(User * u, ChannelInfo * ci, char *param);
28 static int do_set_keeptopic(User * u, ChannelInfo * ci, char *param);
29 static int do_set_topiclock(User * u, ChannelInfo * ci, char *param);
30 static int do_set_private(User * u, ChannelInfo * ci, char *param);
31 static int do_set_secureops(User * u, ChannelInfo * ci, char *param);
32 static int do_set_securefounder(User * u, ChannelInfo * ci, char *param);
33 static int do_set_restricted(User * u, ChannelInfo * ci, char *param);
34 static int do_set_secure(User * u, ChannelInfo * ci, char *param);
35 static int do_set_signkick(User * u, ChannelInfo * ci, char *param);
36 static int do_set_opnotice(User * u, ChannelInfo * ci, char *param);
37 static int do_set_xop(User * u, ChannelInfo * ci, char *param);
38 static int do_set_peace(User * u, ChannelInfo * ci, char *param);
39 static int do_set_noexpire(User * u, ChannelInfo * ci, char *param);
40 static void myChanServHelp(User * u);
41 
48 int AnopeInit(int argc, char **argv)
49 {
50  Command *c;
51 
52  moduleAddAuthor("Anope");
53  moduleAddVersion(VERSION_STRING);
55 
56  c = createCommand("SET", do_set, NULL, CHAN_HELP_SET, -1, -1,
57  CHAN_SERVADMIN_HELP_SET, CHAN_SERVADMIN_HELP_SET);
59  c = createCommand("SET FOUNDER", NULL, NULL, CHAN_HELP_SET_FOUNDER, -1,
60  -1, -1, -1);
62  c = createCommand("SET SUCCESSOR", NULL, NULL, CHAN_HELP_SET_SUCCESSOR,
63  -1, -1, -1, -1);
64  c->help_param1 = (char *) (long) CSMaxReg;
66  c = createCommand("SET PASSWORD", NULL, NULL, CHAN_HELP_SET_PASSWORD,
67  -1, -1, -1, -1);
69  c = createCommand("SET DESC", NULL, NULL, CHAN_HELP_SET_DESC, -1, -1,
70  -1, -1);
72  c = createCommand("SET URL", NULL, NULL, CHAN_HELP_SET_URL, -1, -1, -1,
73  -1);
75  c = createCommand("SET EMAIL", NULL, NULL, CHAN_HELP_SET_EMAIL, -1, -1,
76  -1, -1);
78  c = createCommand("SET ENTRYMSG", NULL, NULL, CHAN_HELP_SET_ENTRYMSG,
79  -1, -1, -1, -1);
81  c = createCommand("SET BANTYPE", NULL, NULL, CHAN_HELP_SET_BANTYPE, -1,
82  -1, -1, -1);
84  c = createCommand("SET PRIVATE", NULL, NULL, CHAN_HELP_SET_PRIVATE, -1,
85  -1, -1, -1);
87  c = createCommand("SET KEEPTOPIC", NULL, NULL, CHAN_HELP_SET_KEEPTOPIC,
88  -1, -1, -1, -1);
90  c = createCommand("SET TOPICLOCK", NULL, NULL, CHAN_HELP_SET_TOPICLOCK,
91  -1, -1, -1, -1);
93  c = createCommand("SET MLOCK", NULL, NULL, CHAN_HELP_SET_MLOCK, -1, -1,
94  -1, -1);
96  c = createCommand("SET RESTRICTED", NULL, NULL,
97  CHAN_HELP_SET_RESTRICTED, -1, -1, -1, -1);
99  c = createCommand("SET SECURE", NULL, NULL, CHAN_HELP_SET_SECURE, -1,
100  -1, -1, -1);
101  c->help_param1 = s_NickServ;
103  c = createCommand("SET SECUREOPS", NULL, NULL, CHAN_HELP_SET_SECUREOPS,
104  -1, -1, -1, -1);
106  c = createCommand("SET SECUREFOUNDER", NULL, NULL,
107  CHAN_HELP_SET_SECUREFOUNDER, -1, -1, -1, -1);
109  c = createCommand("SET SIGNKICK", NULL, NULL, CHAN_HELP_SET_SIGNKICK,
110  -1, -1, -1, -1);
112  c = createCommand("SET OPNOTICE", NULL, NULL, CHAN_HELP_SET_OPNOTICE,
113  -1, -1, -1, -1);
115  c = createCommand("SET XOP", NULL, NULL, CHAN_HELP_SET_XOP, -1, -1, -1,
116  -1);
118  c = createCommand("SET PEACE", NULL, NULL, CHAN_HELP_SET_PEACE, -1, -1,
119  -1, -1);
121  c = createCommand("SET NOEXPIRE", NULL, NULL, -1, -1, -1,
122  CHAN_SERVADMIN_HELP_SET_NOEXPIRE,
123  CHAN_SERVADMIN_HELP_SET_NOEXPIRE);
125 
127 
128  return MOD_CONT;
129 }
130 
134 void AnopeFini(void)
135 {
136 
137 }
138 
143 static void myChanServHelp(User * u)
144 {
145  notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SET);
146 }
147 
154 /* Main SET routine. Calls other routines as follows:
155  * do_set_command(User *command_sender, ChannelInfo *ci, char *param);
156  * The parameter passed is the first space-delimited parameter after the
157  * option name, except in the case of DESC, TOPIC, and ENTRYMSG, in which
158  * it is the entire remainder of the line. Additional parameters beyond
159  * the first passed in the function call can be retrieved using
160  * strtok(NULL, toks).
161  */
162 static int do_set(User * u)
163 {
164  char *chan = strtok(NULL, " ");
165  char *cmd = strtok(NULL, " ");
166  char *param;
167  ChannelInfo *ci;
168  int is_servadmin = is_services_admin(u);
169 
170  if (readonly) {
171  notice_lang(s_ChanServ, u, CHAN_SET_DISABLED);
172  return MOD_CONT;
173  }
174 
175  if (cmd) {
176  if (stricmp(cmd, "DESC") == 0 || stricmp(cmd, "ENTRYMSG") == 0)
177  param = strtok(NULL, "");
178  else
179  param = strtok(NULL, " ");
180  } else {
181  param = NULL;
182  }
183 
184  if (!param && (!cmd || (stricmp(cmd, "SUCCESSOR") != 0 &&
185  stricmp(cmd, "URL") != 0 &&
186  stricmp(cmd, "EMAIL") != 0 &&
187  stricmp(cmd, "ENTRYMSG") != 0 &&
188  stricmp(cmd, "MLOCK") != 0))) {
189  syntax_error(s_ChanServ, u, "SET", CHAN_SET_SYNTAX);
190  } else if (!(ci = cs_findchan(chan))) {
191  notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
192  } else if (ci->flags & CI_VERBOTEN) {
193  notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
194  } else if (!is_servadmin && !check_access(u, ci, CA_SET)) {
195  notice_lang(s_ChanServ, u, ACCESS_DENIED);
196  } else if (stricmp(cmd, "FOUNDER") == 0) {
197  if (!is_servadmin
198  && (ci->
199  flags & CI_SECUREFOUNDER ? !is_real_founder(u,
200  ci) :
201  !is_founder(u, ci))) {
202  notice_lang(s_ChanServ, u, ACCESS_DENIED);
203  } else {
204  do_set_founder(u, ci, param);
205  }
206  } else if (stricmp(cmd, "SUCCESSOR") == 0) {
207  if (!is_servadmin
208  && (ci->
209  flags & CI_SECUREFOUNDER ? !is_real_founder(u,
210  ci) :
211  !is_founder(u, ci))) {
212  notice_lang(s_ChanServ, u, ACCESS_DENIED);
213  } else {
214  do_set_successor(u, ci, param);
215  }
216  } else if (stricmp(cmd, "PASSWORD") == 0) {
217  if (!is_servadmin
218  && (ci->
219  flags & CI_SECUREFOUNDER ? !is_real_founder(u,
220  ci) :
221  !is_founder(u, ci))) {
222  notice_lang(s_ChanServ, u, ACCESS_DENIED);
223  } else {
224  do_set_password(u, ci, param);
225  }
226  } else if (stricmp(cmd, "DESC") == 0) {
227  do_set_desc(u, ci, param);
228  } else if (stricmp(cmd, "URL") == 0) {
229  do_set_url(u, ci, param);
230  } else if (stricmp(cmd, "EMAIL") == 0) {
231  do_set_email(u, ci, param);
232  } else if (stricmp(cmd, "ENTRYMSG") == 0) {
233  do_set_entrymsg(u, ci, param);
234  } else if (stricmp(cmd, "TOPIC") == 0) {
235  notice_lang(s_ChanServ, u, OBSOLETE_COMMAND, "TOPIC");
236  } else if (stricmp(cmd, "BANTYPE") == 0) {
237  do_set_bantype(u, ci, param);
238  } else if (stricmp(cmd, "MLOCK") == 0) {
239  do_set_mlock(u, ci, param);
240  } else if (stricmp(cmd, "KEEPTOPIC") == 0) {
241  do_set_keeptopic(u, ci, param);
242  } else if (stricmp(cmd, "TOPICLOCK") == 0) {
243  do_set_topiclock(u, ci, param);
244  } else if (stricmp(cmd, "PRIVATE") == 0) {
245  do_set_private(u, ci, param);
246  } else if (stricmp(cmd, "SECUREOPS") == 0) {
247  do_set_secureops(u, ci, param);
248  } else if (stricmp(cmd, "SECUREFOUNDER") == 0) {
249  if (!is_servadmin
250  && (ci->
251  flags & CI_SECUREFOUNDER ? !is_real_founder(u,
252  ci) :
253  !is_founder(u, ci))) {
254  notice_lang(s_ChanServ, u, ACCESS_DENIED);
255  } else {
256  do_set_securefounder(u, ci, param);
257  }
258  } else if (stricmp(cmd, "RESTRICTED") == 0) {
259  do_set_restricted(u, ci, param);
260  } else if (stricmp(cmd, "SECURE") == 0) {
261  do_set_secure(u, ci, param);
262  } else if (stricmp(cmd, "SIGNKICK") == 0) {
263  do_set_signkick(u, ci, param);
264  } else if (stricmp(cmd, "OPNOTICE") == 0) {
265  do_set_opnotice(u, ci, param);
266  } else if (stricmp(cmd, "XOP") == 0) {
267  if (!(findModule("cs_xop"))) {
268  notice_lang(s_ChanServ, u, CHAN_XOP_NOT_AVAILABLE, cmd);
269  } else {
270  do_set_xop(u, ci, param);
271  }
272  } else if (stricmp(cmd, "PEACE") == 0) {
273  do_set_peace(u, ci, param);
274  } else if (stricmp(cmd, "NOEXPIRE") == 0) {
275  do_set_noexpire(u, ci, param);
276  } else {
277  notice_lang(s_ChanServ, u, CHAN_SET_UNKNOWN_OPTION, cmd);
278  notice_lang(s_ChanServ, u, MORE_INFO, s_ChanServ, "SET");
279  }
280  return MOD_CONT;
281 }
282 
283 /*************************************************************************/
284 
285 static int do_set_founder(User * u, ChannelInfo * ci, char *param)
286 {
287  NickAlias *na = findnick(param);
288  NickCore *nc, *nc0 = ci->founder;
289 
290  if (!na) {
291  notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param);
292  return MOD_CONT;
293  } else if (na->status & NS_VERBOTEN) {
294  notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param);
295  return MOD_CONT;
296  }
297 
298  nc = na->nc;
299  if (nc->channelmax > 0 && nc->channelcount >= nc->channelmax
300  && !is_services_admin(u)) {
301  notice_lang(s_ChanServ, u, CHAN_SET_FOUNDER_TOO_MANY_CHANS, param);
302  return MOD_CONT;
303  }
304 
305  alog("%s: Changing founder of %s from %s to %s by %s!%s@%s",
306  s_ChanServ, ci->name, ci->founder->display, nc->display, u->nick,
307  u->username, u->host);
308 
309  /* Founder and successor must not be the same group */
310  if (nc == ci->successor)
311  ci->successor = NULL;
312 
313  nc0->channelcount--;
314  ci->founder = nc;
315  nc->channelcount++;
316 
317  notice_lang(s_ChanServ, u, CHAN_FOUNDER_CHANGED, ci->name, param);
318  return MOD_CONT;
319 }
320 
321 /*************************************************************************/
322 
323 static int do_set_successor(User * u, ChannelInfo * ci, char *param)
324 {
325  NickAlias *na;
326  NickCore *nc;
327 
328  if (param) {
329  na = findnick(param);
330 
331  if (!na) {
332  notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param);
333  return MOD_CONT;
334  }
335  if (na->status & NS_VERBOTEN) {
336  notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param);
337  return MOD_CONT;
338  }
339  if (na->nc == ci->founder) {
340  notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_IS_FOUNDER, param,
341  ci->name);
342  return MOD_CONT;
343  }
344  nc = na->nc;
345 
346  } else {
347  nc = NULL;
348  }
349 
350  alog("%s: Changing successor of %s from %s to %s by %s!%s@%s",
351  s_ChanServ, ci->name,
352  (ci->successor ? ci->successor->display : "none"),
353  (nc ? nc->display : "none"), u->nick, u->username, u->host);
354 
355  ci->successor = nc;
356 
357  if (nc)
358  notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_CHANGED, ci->name,
359  param);
360  else
361  notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_UNSET, ci->name);
362  return MOD_CONT;
363 }
364 
365 /*************************************************************************/
366 
367 static int do_set_password(User * u, ChannelInfo * ci, char *param)
368 {
369  int len = strlen(param);
370 
371  if (stricmp(u->nick, param) == 0 || (StrictPasswords && len < 5)) {
372  notice_lang(s_ChanServ, u, MORE_OBSCURE_PASSWORD);
373  return MOD_CONT;
374  }
375 
376  if (enc_encrypt_check_len(len ,PASSMAX - 1)) {
377  notice_lang(s_ChanServ, u, PASSWORD_TOO_LONG);
378  return MOD_CONT;
379  }
380 
381  if (enc_encrypt(param, len, ci->founderpass, PASSMAX -1) < 0) {
382  memset(param, 0, strlen(param));
383  alog("%s: Failed to encrypt password for %s (set)", s_ChanServ,
384  ci->name);
385  notice_lang(s_ChanServ, u, CHAN_SET_PASSWORD_FAILED);
386  return MOD_CONT;
387  }
388 
389  memset(param, 0, strlen(param));
390  notice_lang(s_ChanServ, u, CHAN_PASSWORD_CHANGED, ci->name);
391 
392  if (get_access(u, ci) < ACCESS_FOUNDER) {
393  alog("%s: %s!%s@%s set password as Services admin for %s",
394  s_ChanServ, u->nick, u->username, u->host, ci->name);
395  if (WallSetpass)
397  "\2%s\2 set password as Services admin for channel \2%s\2",
398  u->nick, ci->name);
399  } else {
400  alog("%s: %s!%s@%s changed password of %s (founder: %s)",
401  s_ChanServ, u->nick, u->username, u->host,
402  ci->name, ci->founder->display);
403  }
404  return MOD_CONT;
405 }
406 
407 /*************************************************************************/
408 
409 static int do_set_desc(User * u, ChannelInfo * ci, char *param)
410 {
411  if (ci->desc)
412  free(ci->desc);
413  ci->desc = sstrdup(param);
414  alog("%s: %s!%s@%s set description of %s to: %s",
415  s_ChanServ, u->nick, u->username, u->host, ci->name, ci->desc);
416  notice_lang(s_ChanServ, u, CHAN_DESC_CHANGED, ci->name, param);
417  return MOD_CONT;
418 }
419 
420 /*************************************************************************/
421 
422 static int do_set_url(User * u, ChannelInfo * ci, char *param)
423 {
424  if (ci->url)
425  free(ci->url);
426  if (param) {
427  ci->url = sstrdup(param);
428  alog("%s: %s!%s@%s set url for %s to: %s",
429  s_ChanServ, u->nick, u->username, u->host, ci->name, ci->url);
430  notice_lang(s_ChanServ, u, CHAN_URL_CHANGED, ci->name, param);
431  } else {
432  ci->url = NULL;
433  alog("%s: %s!%s@%s unset url for %s",
434  s_ChanServ, u->nick, u->username, u->host, ci->name);
435  notice_lang(s_ChanServ, u, CHAN_URL_UNSET, ci->name);
436  }
437  return MOD_CONT;
438 }
439 
440 /*************************************************************************/
441 
442 static int do_set_email(User * u, ChannelInfo * ci, char *param)
443 {
444  if (ci->email)
445  free(ci->email);
446  if (param) {
447  ci->email = sstrdup(param);
448  alog("%s: %s!%s@%s set email for %s to: %s",
449  s_ChanServ, u->nick, u->username, u->host, ci->name, ci->email);
450  notice_lang(s_ChanServ, u, CHAN_EMAIL_CHANGED, ci->name, param);
451  } else {
452  ci->email = NULL;
453  alog("%s: %s!%s@%s unset email for %s",
454  s_ChanServ, u->nick, u->username, u->host, ci->name);
455  notice_lang(s_ChanServ, u, CHAN_EMAIL_UNSET, ci->name);
456  }
457  return MOD_CONT;
458 }
459 
460 /*************************************************************************/
461 
462 static int do_set_entrymsg(User * u, ChannelInfo * ci, char *param)
463 {
464  if (ci->entry_message)
465  free(ci->entry_message);
466  if (param) {
467  ci->entry_message = sstrdup(param);
468  alog("%s: %s!%s@%s set entrymsg for %s to: %s",
469  s_ChanServ, u->nick, u->username, u->host, ci->name, ci->entry_message);
470  notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_CHANGED, ci->name,
471  param);
472  } else {
473  ci->entry_message = NULL;
474  alog("%s: %s!%s@%s unset entrymsg for %s",
475  s_ChanServ, u->nick, u->username, u->host, ci->name);
476  notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_UNSET, ci->name);
477  }
478  return MOD_CONT;
479 }
480 
481 /*************************************************************************/
482 
483 static int do_set_mlock(User * u, ChannelInfo * ci, char *param)
484 {
485  int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */
486  unsigned char mode;
487  CBMode *cbm;
488 
490  notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED);
491  return MOD_CONT;
492  }
493 
494  /* Reinitialize everything */
495  if (ircd->chanreg) {
496  ci->mlock_on = ircd->regmode;
497  } else {
498  ci->mlock_on = 0;
499  }
500  ci->mlock_off = ci->mlock_limit = 0;
501  ci->mlock_key = NULL;
502  if (ircd->fmode) {
503  ci->mlock_flood = NULL;
504  }
505  if (ircd->Lmode) {
506  ci->mlock_redirect = NULL;
507  }
508 
509  while (param && (mode = *param++)) {
510  switch (mode) {
511  case '+':
512  add = 1;
513  continue;
514  case '-':
515  add = 0;
516  continue;
517  default:
518  if (add < 0)
519  continue;
520  }
521 
522  if ((int) mode < 128 && (cbm = &cbmodes[(int) mode])->flag != 0) {
523  if ((cbm->flags & CBM_NO_MLOCK)
524  || ((cbm->flags & CBM_NO_USER_MLOCK) && !is_oper(u))) {
525  notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_IMPOSSIBLE_CHAR,
526  mode);
527  } else if (add) {
528  ci->mlock_on |= cbm->flag;
529  ci->mlock_off &= ~cbm->flag;
530  if (cbm->cssetvalue)
531  cbm->cssetvalue(ci, strtok(NULL, " "));
532  } else {
533  ci->mlock_off |= cbm->flag;
534  if (ci->mlock_on & cbm->flag) {
535  ci->mlock_on &= ~cbm->flag;
536  if (cbm->cssetvalue)
537  cbm->cssetvalue(ci, NULL);
538  }
539  }
540  } else {
541  notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_UNKNOWN_CHAR, mode);
542  }
543  } /* while (*param) */
544 
545  if (ircd->Lmode) {
546  /* We can't mlock +L if +l is not mlocked as well. */
547  if ((ci->mlock_on & ircd->chan_lmode)
548  && !(ci->mlock_on & anope_get_limit_mode())) {
549  ci->mlock_on &= ~ircd->chan_lmode;
550  free(ci->mlock_redirect);
551  notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_L_REQUIRED);
552  }
553  }
554 
555  /* Some ircd we can't set NOKNOCK without INVITE */
556  /* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */
557  if (ircd->noknock && ircd->knock_needs_i) {
558  if ((ci->mlock_on & ircd->noknock)
559  && !(ci->mlock_on & anope_get_invite_mode())) {
560  ci->mlock_on &= ~ircd->noknock;
561  notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_K_REQUIRED);
562  }
563  }
564 
565  /* Since we always enforce mode r there is no way to have no
566  * mode lock at all.
567  */
568  if (get_mlock_modes(ci, 0)) {
569  alog("%s: %s!%s@%s set mlock for %s to: %s",
570  s_ChanServ, u->nick, u->username, u->host, ci->name, get_mlock_modes(ci, 0));
571  notice_lang(s_ChanServ, u, CHAN_MLOCK_CHANGED, ci->name,
572  get_mlock_modes(ci, 0));
573  }
574 
575  /* Implement the new lock. */
576  if (ci->c)
577  check_modes(ci->c);
578  return MOD_CONT;
579 }
580 
581 /*************************************************************************/
582 
583 static int do_set_bantype(User * u, ChannelInfo * ci, char *param)
584 {
585  char *endptr;
586 
587  int16 bantype = strtol(param, &endptr, 10);
588 
589  if (*endptr != 0 || bantype < 0 || bantype > 3) {
590  notice_lang(s_ChanServ, u, CHAN_SET_BANTYPE_INVALID, param);
591  } else {
592  ci->bantype = bantype;
593  alog("%s: %s!%s@%s set ban type for %s to: %d",
594  s_ChanServ, u->nick, u->username, u->host, ci->name, ci->bantype);
595  notice_lang(s_ChanServ, u, CHAN_SET_BANTYPE_CHANGED, ci->name,
596  ci->bantype);
597  }
598  return MOD_CONT;
599 }
600 
601 /*************************************************************************/
602 
603 static int do_set_keeptopic(User * u, ChannelInfo * ci, char *param)
604 {
605  if (stricmp(param, "ON") == 0) {
606  ci->flags |= CI_KEEPTOPIC;
607  alog("%s: %s!%s@%s set keeptopic ON for %s",
608  s_ChanServ, u->nick, u->username, u->host, ci->name);
609  notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_ON, ci->name);
610  } else if (stricmp(param, "OFF") == 0) {
611  ci->flags &= ~CI_KEEPTOPIC;
612  alog("%s: %s!%s@%s set keeptopic OFF for %s",
613  s_ChanServ, u->nick, u->username, u->host, ci->name);
614  notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_OFF, ci->name);
615  } else {
616  syntax_error(s_ChanServ, u, "SET KEEPTOPIC",
617  CHAN_SET_KEEPTOPIC_SYNTAX);
618  }
619  return MOD_CONT;
620 }
621 
622 /*************************************************************************/
623 
624 static int do_set_topiclock(User * u, ChannelInfo * ci, char *param)
625 {
626  if (stricmp(param, "ON") == 0) {
627  ci->flags |= CI_TOPICLOCK;
628  alog("%s: %s!%s@%s set topiclock ON for %s",
629  s_ChanServ, u->nick, u->username, u->host, ci->name);
630  notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_ON, ci->name);
631  } else if (stricmp(param, "OFF") == 0) {
632  ci->flags &= ~CI_TOPICLOCK;
633  alog("%s: %s!%s@%s set topiclock OFF for %s",
634  s_ChanServ, u->nick, u->username, u->host, ci->name);
635  notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_OFF, ci->name);
636  } else {
637  syntax_error(s_ChanServ, u, "SET TOPICLOCK",
638  CHAN_SET_TOPICLOCK_SYNTAX);
639  }
640  return MOD_CONT;
641 }
642 
643 /*************************************************************************/
644 
645 static int do_set_private(User * u, ChannelInfo * ci, char *param)
646 {
647  if (stricmp(param, "ON") == 0) {
648  ci->flags |= CI_PRIVATE;
649  alog("%s: %s!%s@%s set private ON for %s",
650  s_ChanServ, u->nick, u->username, u->host, ci->name);
651  notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_ON, ci->name);
652  } else if (stricmp(param, "OFF") == 0) {
653  ci->flags &= ~CI_PRIVATE;
654  alog("%s: %s!%s@%s set private OFF for %s",
655  s_ChanServ, u->nick, u->username, u->host, ci->name);
656  notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_OFF, ci->name);
657  } else {
658  syntax_error(s_ChanServ, u, "SET PRIVATE",
659  CHAN_SET_PRIVATE_SYNTAX);
660  }
661  return MOD_CONT;
662 }
663 
664 /*************************************************************************/
665 
666 static int do_set_secureops(User * u, ChannelInfo * ci, char *param)
667 {
668  if (stricmp(param, "ON") == 0) {
669  ci->flags |= CI_SECUREOPS;
670  alog("%s: %s!%s@%s set secureops ON for %s",
671  s_ChanServ, u->nick, u->username, u->host, ci->name);
672  notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_ON, ci->name);
673  } else if (stricmp(param, "OFF") == 0) {
674  ci->flags &= ~CI_SECUREOPS;
675  alog("%s: %s!%s@%s set secureops OFF for %s",
676  s_ChanServ, u->nick, u->username, u->host, ci->name);
677  notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_OFF, ci->name);
678  } else {
679  syntax_error(s_ChanServ, u, "SET SECUREOPS",
680  CHAN_SET_SECUREOPS_SYNTAX);
681  }
682  return MOD_CONT;
683 }
684 
685 /*************************************************************************/
686 
687 static int do_set_securefounder(User * u, ChannelInfo * ci, char *param)
688 {
689  if (stricmp(param, "ON") == 0) {
690  ci->flags |= CI_SECUREFOUNDER;
691  alog("%s: %s!%s@%s set securefounder ON for %s",
692  s_ChanServ, u->nick, u->username, u->host, ci->name);
693  notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_ON, ci->name);
694  } else if (stricmp(param, "OFF") == 0) {
695  ci->flags &= ~CI_SECUREFOUNDER;
696  alog("%s: %s!%s@%s set securefounder OFF for %s",
697  s_ChanServ, u->nick, u->username, u->host, ci->name);
698  notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_OFF, ci->name);
699  } else {
700  syntax_error(s_ChanServ, u, "SET SECUREFOUNDER",
701  CHAN_SET_SECUREFOUNDER_SYNTAX);
702  }
703  return MOD_CONT;
704 }
705 
706 /*************************************************************************/
707 
708 static int do_set_restricted(User * u, ChannelInfo * ci, char *param)
709 {
710  if (stricmp(param, "ON") == 0) {
711  ci->flags |= CI_RESTRICTED;
712  if (ci->levels[CA_NOJOIN] < 0)
713  ci->levels[CA_NOJOIN] = 0;
714  alog("%s: %s!%s@%s set restricted ON for %s",
715  s_ChanServ, u->nick, u->username, u->host, ci->name);
716  notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_ON, ci->name);
717  } else if (stricmp(param, "OFF") == 0) {
718  ci->flags &= ~CI_RESTRICTED;
719  if (ci->levels[CA_NOJOIN] >= 0)
720  ci->levels[CA_NOJOIN] = -2;
721  alog("%s: %s!%s@%s set restricted OFF for %s",
722  s_ChanServ, u->nick, u->username, u->host, ci->name);
723  notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_OFF, ci->name);
724  } else {
725  syntax_error(s_ChanServ, u, "SET RESTRICTED",
726  CHAN_SET_RESTRICTED_SYNTAX);
727  }
728  return MOD_CONT;
729 }
730 
731 /*************************************************************************/
732 
733 static int do_set_secure(User * u, ChannelInfo * ci, char *param)
734 {
735  if (stricmp(param, "ON") == 0) {
736  ci->flags |= CI_SECURE;
737  alog("%s: %s!%s@%s set secure ON for %s",
738  s_ChanServ, u->nick, u->username, u->host, ci->name);
739  notice_lang(s_ChanServ, u, CHAN_SET_SECURE_ON, ci->name);
740  } else if (stricmp(param, "OFF") == 0) {
741  ci->flags &= ~CI_SECURE;
742  alog("%s: %s!%s@%s set secure OFF for %s",
743  s_ChanServ, u->nick, u->username, u->host, ci->name);
744  notice_lang(s_ChanServ, u, CHAN_SET_SECURE_OFF, ci->name);
745  } else {
746  syntax_error(s_ChanServ, u, "SET SECURE", CHAN_SET_SECURE_SYNTAX);
747  }
748  return MOD_CONT;
749 }
750 
751 /*************************************************************************/
752 
753 static int do_set_signkick(User * u, ChannelInfo * ci, char *param)
754 {
755  if (stricmp(param, "ON") == 0) {
756  ci->flags |= CI_SIGNKICK;
757  ci->flags &= ~CI_SIGNKICK_LEVEL;
758  alog("%s: %s!%s@%s set signkick ON for %s",
759  s_ChanServ, u->nick, u->username, u->host, ci->name);
760  notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_ON, ci->name);
761  } else if (stricmp(param, "LEVEL") == 0) {
762  ci->flags |= CI_SIGNKICK_LEVEL;
763  ci->flags &= ~CI_SIGNKICK;
764  alog("%s: %s!%s@%s set signkick LEVEL for %s",
765  s_ChanServ, u->nick, u->username, u->host, ci->name);
766  notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_LEVEL, ci->name);
767  } else if (stricmp(param, "OFF") == 0) {
768  ci->flags &= ~(CI_SIGNKICK | CI_SIGNKICK_LEVEL);
769  alog("%s: %s!%s@%s set signkick OFF for %s",
770  s_ChanServ, u->nick, u->username, u->host, ci->name);
771  notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_OFF, ci->name);
772  } else {
773  syntax_error(s_ChanServ, u, "SET SIGNKICK",
774  CHAN_SET_SIGNKICK_SYNTAX);
775  }
776  return MOD_CONT;
777 }
778 
779 /*************************************************************************/
780 
781 static int do_set_opnotice(User * u, ChannelInfo * ci, char *param)
782 {
783  if (stricmp(param, "ON") == 0) {
784  ci->flags |= CI_OPNOTICE;
785  alog("%s: %s!%s@%s set opnotice ON for %s",
786  s_ChanServ, u->nick, u->username, u->host, ci->name);
787  notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_ON, ci->name);
788  } else if (stricmp(param, "OFF") == 0) {
789  ci->flags &= ~CI_OPNOTICE;
790  alog("%s: %s!%s@%s set opnotice OFF for %s",
791  s_ChanServ, u->nick, u->username, u->host, ci->name);
792  notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_OFF, ci->name);
793  } else {
794  syntax_error(s_ChanServ, u, "SET OPNOTICE",
795  CHAN_SET_OPNOTICE_SYNTAX);
796  }
797  return MOD_CONT;
798 }
799 
800 /*************************************************************************/
801 
802 #define CHECKLEV(lev) ((ci->levels[(lev)] != ACCESS_INVALID) && (access->level >= ci->levels[(lev)]))
803 
804 static int do_set_xop(User * u, ChannelInfo * ci, char *param)
805 {
806  if (stricmp(param, "ON") == 0) {
807  if (!(ci->flags & CI_XOP)) {
808  int i;
809  ChanAccess *access;
810 
811  for (access = ci->access, i = 0; i < ci->accesscount;
812  access++, i++) {
813  if (!access->in_use)
814  continue;
815  /* This will probably cause wrong levels to be set, but hey,
816  * it's better than losing it altogether.
817  */
818  if (CHECKLEV(CA_AKICK) || CHECKLEV(CA_SET)) {
819  access->level = ACCESS_SOP;
820  } else if (CHECKLEV(CA_AUTOOP) || CHECKLEV(CA_OPDEOP)
821  || CHECKLEV(CA_OPDEOPME)) {
822  access->level = ACCESS_AOP;
823  } else if (ircd->halfop && (CHECKLEV(CA_AUTOHALFOP) || CHECKLEV(CA_HALFOP)
824  || CHECKLEV(CA_HALFOPME))) {
825  access->level = ACCESS_HOP;
826  } else if (CHECKLEV(CA_AUTOVOICE) || CHECKLEV(CA_VOICE)
827  || CHECKLEV(CA_VOICEME)) {
828  access->level = ACCESS_VOP;
829  } else {
830  access->in_use = 0;
831  access->nc = NULL;
832  }
833  }
834  CleanAccess(ci);
835 
836  reset_levels(ci);
837  ci->flags |= CI_XOP;
838  }
839 
840  alog("%s: %s!%s@%s enabled XOP for %s", s_ChanServ, u->nick,
841  u->username, u->host, ci->name);
842  notice_lang(s_ChanServ, u, CHAN_SET_XOP_ON, ci->name);
843  } else if (stricmp(param, "OFF") == 0) {
844  ci->flags &= ~CI_XOP;
845 
846  alog("%s: %s!%s@%s disabled XOP for %s", s_ChanServ, u->nick,
847  u->username, u->host, ci->name);
848  notice_lang(s_ChanServ, u, CHAN_SET_XOP_OFF, ci->name);
849  } else {
850  syntax_error(s_ChanServ, u, "SET XOP", CHAN_SET_XOP_SYNTAX);
851  }
852  return MOD_CONT;
853 }
854 
855 #undef CHECKLEV
856 
857 /*************************************************************************/
858 
859 static int do_set_peace(User * u, ChannelInfo * ci, char *param)
860 {
861  if (stricmp(param, "ON") == 0) {
862  ci->flags |= CI_PEACE;
863  alog("%s: %s!%s@%s set peace ON for %s",
864  s_ChanServ, u->nick, u->username, u->host, ci->name);
865  notice_lang(s_ChanServ, u, CHAN_SET_PEACE_ON, ci->name);
866  } else if (stricmp(param, "OFF") == 0) {
867  ci->flags &= ~CI_PEACE;
868  alog("%s: %s!%s@%s set peace OFF for %s",
869  s_ChanServ, u->nick, u->username, u->host, ci->name);
870  notice_lang(s_ChanServ, u, CHAN_SET_PEACE_OFF, ci->name);
871  } else {
872  syntax_error(s_ChanServ, u, "SET PEACE", CHAN_SET_PEACE_SYNTAX);
873  }
874  return MOD_CONT;
875 }
876 
877 /*************************************************************************/
878 
879 static int do_set_noexpire(User * u, ChannelInfo * ci, char *param)
880 {
881  if (!is_services_admin(u)) {
882  notice_lang(s_ChanServ, u, PERMISSION_DENIED);
883  return MOD_CONT;
884  }
885  if (stricmp(param, "ON") == 0) {
886  ci->flags |= CI_NO_EXPIRE;
887  alog("%s: %s!%s@%s set noexpire ON for %s",
888  s_ChanServ, u->nick, u->username, u->host, ci->name);
889  notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_ON, ci->name);
890  } else if (stricmp(param, "OFF") == 0) {
891  ci->flags &= ~CI_NO_EXPIRE;
892  alog("%s: %s!%s@%s set noexpire OFF for %s",
893  s_ChanServ, u->nick, u->username, u->host, ci->name);
894  notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_OFF, ci->name);
895  } else {
896  syntax_error(s_ChanServ, u, "SET NOEXPIRE",
897  CHAN_SET_NOEXPIRE_SYNTAX);
898  }
899  return MOD_CONT;
900 }
901 
char * url
Definition: services.h:660
E int is_oper(User *user)
Definition: users.c:937
E int CSMaxReg
Definition: extern.h:403
#define CA_AUTOVOICE
Definition: services.h:755
E CBMode cbmodes[128]
Definition: extern.h:47
static int do_set_password(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:367
void(* cssetvalue)(ChannelInfo *ci, char *value)
Definition: services.h:925
static int do_set(User *u)
Definition: cs_set.c:162
#define CA_AUTOOP
Definition: services.h:753
static int do_set_secure(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:733
#define CHECKLEV(lev)
Definition: cs_set.c:802
static int do_set_topiclock(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:624
E int readonly
Definition: extern.h:776
char nick[NICKMAX]
Definition: services.h:875
E NickAlias * findnick(const char *nick)
Definition: db-merger.c:1857
uint32 flag
Definition: services.h:920
#define CI_OPNOTICE
Definition: services.h:733
int Lmode
Definition: services.h:350
E int checkDefCon(int level)
Definition: operserv.c:1608
E IRCDVar * ircd
Definition: extern.h:39
#define CI_RESTRICTED
Definition: services.h:719
static int do_set_successor(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:323
char * mlock_redirect
Definition: services.h:685
#define CI_NO_EXPIRE
Definition: services.h:729
E int check_access(User *user, ChannelInfo *ci, int what)
Definition: chanserv.c:1974
char * mlock_flood
Definition: services.h:684
#define CBM_NO_MLOCK
Definition: services.h:929
uint32 regmode
Definition: services.h:336
char founderpass[PASSMAX]
Definition: services.h:658
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
static int do_set_noexpire(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:879
int16 level
Definition: services.h:594
static int do_set_mlock(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:483
#define CI_SECURE
Definition: services.h:723
#define NS_VERBOTEN
Definition: services.h:1273
#define CI_VERBOTEN
Definition: services.h:725
uint16 flags
Definition: services.h:921
#define CI_SECUREFOUNDER
Definition: services.h:735
static int do_set_entrymsg(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:462
#define CI_SECUREOPS
Definition: services.h:713
char * host
Definition: services.h:878
#define ACCESS_VOP
Definition: services.h:614
E int anope_get_limit_mode()
Definition: ircd.c:1241
#define CA_AKICK
Definition: services.h:750
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E char * get_mlock_modes(ChannelInfo *ci, int complete)
Definition: chanserv.c:130
E void syntax_error(char *service, User *u, const char *command, int msgnum)
Definition: language.c:295
char name[CHANMAX]
Definition: services.h:654
#define CA_NOJOIN
Definition: services.h:759
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
#define DEFCON_NO_MLOCK_CHANGE
Definition: services.h:1256
#define CA_AUTOHALFOP
Definition: services.h:771
E char * sstrdup(const char *s)
Definition: memory.c:105
char * help_param1
Definition: modules.h:187
#define CI_PRIVATE
Definition: services.h:715
NickCore * nc
Definition: services.h:533
int16 bantype
Definition: services.h:673
#define CI_PEACE
Definition: services.h:721
char * email
Definition: services.h:661
#define ACCESS_SOP
Definition: services.h:617
char * display
Definition: services.h:542
#define ACCESS_FOUNDER
Definition: services.h:604
int knock_needs_i
Definition: services.h:354
static int do_set_keeptopic(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:603
E int enc_encrypt(const char *src, int len, char *dest, int size)
Definition: encrypt.c:50
uint32 flags
Definition: services.h:669
char * entry_message
Definition: services.h:688
#define CA_OPDEOP
Definition: services.h:756
static int do_set_opnotice(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:781
MDE Module * findModule(char *name)
Definition: modules.c:473
E int WallSetpass
Definition: extern.h:469
#define PASSMAX
Definition: config.h:65
static int do_set_securefounder(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:687
static int do_set_url(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:422
uint32 noknock
Definition: services.h:345
uint16 status
Definition: services.h:532
uint16 channelcount
Definition: services.h:553
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
int AnopeInit(int argc, char **argv)
Definition: cs_set.c:48
struct channel_ * c
Definition: services.h:692
uint32 mlock_off
Definition: services.h:681
MDE void moduleSetChanHelp(void(*func)(User *u))
Definition: modules.c:2090
#define CI_KEEPTOPIC
Definition: services.h:711
static int do_set_founder(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:285
E int is_real_founder(User *user, ChannelInfo *ci)
Definition: chanserv.c:2277
Command * c
Definition: ns_recover.c:17
#define CHANSERV
Definition: modules.h:60
E void alog(const char *fmt,...) FORMAT(printf
#define CI_XOP
Definition: services.h:741
#define MOD_CONT
Definition: modules.h:54
NickCore * nc
Definition: services.h:595
E void reset_levels(ChannelInfo *ci)
Definition: chanserv.c:2233
uint32 mlock_limit
Definition: services.h:682
int16_t int16
Definition: db-merger.c:120
E void CleanAccess(ChannelInfo *ci)
Definition: chanserv.c:2755
E int is_founder(User *user, ChannelInfo *ci)
Definition: chanserv.c:2255
E void check_modes(Channel *c)
Definition: chanserv.c:1081
void AnopeFini(void)
Definition: cs_set.c:134
E int is_services_admin(User *u)
Definition: operserv.c:591
E int enc_encrypt_check_len(int passlen, int bufsize)
Definition: encrypt.c:66
#define CI_SIGNKICK
Definition: services.h:737
#define ACCESS_HOP
Definition: services.h:615
#define CI_SIGNKICK_LEVEL
Definition: services.h:739
char * username
Definition: services.h:877
uint16 channelmax
Definition: services.h:554
#define CA_VOICE
Definition: services.h:769
static void myChanServHelp(User *u)
Definition: cs_set.c:143
#define CA_VOICEME
Definition: services.h:768
static int do_set_signkick(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:753
Definition: modules.h:99
static int do_set_xop(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:804
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
static int do_set_private(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:645
static int do_set_peace(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:859
static int do_set_email(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:442
static int do_set_desc(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:409
char * mlock_key
Definition: services.h:683
#define CI_TOPICLOCK
Definition: services.h:717
#define CA_OPDEOPME
Definition: services.h:773
static int do_set_secureops(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:666
E int StrictPasswords
Definition: extern.h:341
#define CBM_NO_USER_MLOCK
Definition: services.h:930
E ChannelInfo * cs_findchan(const char *chan)
Definition: db-merger.c:2000
#define CA_HALFOPME
Definition: services.h:774
#define CA_HALFOP
Definition: services.h:775
ChanAccess * access
Definition: services.h:677
int16 * levels
Definition: services.h:674
E char * s_ChanServ
Definition: extern.h:285
char * desc
Definition: services.h:659
E int get_access(User *user, ChannelInfo *ci)
Definition: chanserv.c:2332
E char * s_NickServ
Definition: extern.h:284
uint16 in_use
Definition: services.h:593
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
int halfop
Definition: services.h:316
int chanreg
Definition: services.h:335
NickCore * founder
Definition: services.h:655
static int do_set_bantype(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:583
uint32 chan_lmode
Definition: services.h:352
static int do_set_restricted(User *u, ChannelInfo *ci, char *param)
Definition: cs_set.c:708
#define ACCESS_AOP
Definition: services.h:616
E int anope_get_invite_mode()
Definition: ircd.c:1221
#define CA_SET
Definition: services.h:751
int fmode
Definition: services.h:349
uint32 mlock_on
Definition: services.h:681
#define MOD_UNIQUE
Definition: module.h:11
E void anope_cmd_global(char *source, const char *fmt,...)
Definition: ircd.c:506
NickCore * successor
Definition: services.h:656