Anope IRC Services  Version 1.8
nickserv.c
Go to the documentation of this file.
1 
2 /* NickServ functions.
3  *
4  * (C) 2003-2014 Anope Team
5  * Contact us at team@anope.org
6  *
7  * Please read COPYING and README for further details.
8  *
9  * Based on the original code of Epona by Lara.
10  * Based on the original code of Services by Andy Church.
11  *
12  *
13  */
14 
15 #include "services.h"
16 #include "pseudo.h"
17 
18 /*************************************************************************/
19 
20 #define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))
21 
25 
26 unsigned int guestnum; /* Current guest number */
27 
28 #define TO_COLLIDE 0 /* Collide the user with this nick */
29 #define TO_RELEASE 1 /* Release a collided nick */
30 
31 /*************************************************************************/
32 
33 static void add_ns_timeout(NickAlias * na, int type, time_t delay);
34 
35 /*************************************************************************/
36 /* *INDENT-OFF* */
39 }
40 /* *INDENT-ON* */
41 /*************************************************************************/
42 
43 /* Display total number of registered nicks and info about each; or, if
44  * a specific nick is given, display information about that nick (like
45  * /msg NickServ INFO <nick>). If count_only != 0, then only display the
46  * number of registered nicks (the nick parameter is ignored).
47  */
48 
49 void listnicks(int count_only, const char *nick)
50 {
51  int count = 0;
52  NickAlias *na;
53  int i;
54  char *end;
55 
56  if (count_only) {
57 
58  for (i = 0; i < 1024; i++) {
59  for (na = nalists[i]; na; na = na->next)
60  count++;
61  }
62  printf("%d nicknames registered.\n", count);
63 
64  } else if (nick) {
65 
66  struct tm *tm;
67  char buf[512];
68  static const char commastr[] = ", ";
69  int need_comma = 0;
70 
71  if (!(na = findnick(nick))) {
72  printf("%s not registered.\n", nick);
73  return;
74  } else if (na->status & NS_VERBOTEN) {
75  printf("%s is FORBIDden.\n", nick);
76  return;
77  }
78  printf("%s is %s\n", nick, na->last_realname);
79  printf("Last seen address: %s\n", na->last_usermask);
80  tm = localtime(&na->time_registered);
81  strftime(buf, sizeof(buf),
82  getstring(NULL, STRFTIME_DATE_TIME_FORMAT), tm);
83  printf(" Time registered: %s\n", buf);
84  tm = localtime(&na->last_seen);
85  strftime(buf, sizeof(buf),
86  getstring(NULL, STRFTIME_DATE_TIME_FORMAT), tm);
87  printf(" Last seen time: %s\n", buf);
88  if (na->nc->url)
89  printf(" URL: %s\n", na->nc->url);
90  if (na->nc->email)
91  printf(" E-mail address: %s\n", na->nc->email);
92  if (na->nc->icq)
93  printf(" ICQ #: %d\n", na->nc->icq);
94  if (na->nc->greet)
95  printf(" Greet: %s\n", na->nc->greet);
96  *buf = 0;
97  end = buf;
98  if (na->nc->flags & NI_KILLPROTECT) {
99  end +=
100  snprintf(end, sizeof(buf) - (end - buf),
101  "Kill protection");
102  need_comma = 1;
103  }
104  if (na->nc->flags & NI_SECURE) {
105  end += snprintf(end, sizeof(buf) - (end - buf), "%sSecurity",
106  need_comma ? commastr : "");
107  need_comma = 1;
108  }
109  if (na->nc->flags & NI_PRIVATE) {
110  end += snprintf(end, sizeof(buf) - (end - buf), "%sPrivate",
111  need_comma ? commastr : "");
112  need_comma = 1;
113  }
114  if (na->status & NS_NO_EXPIRE) {
115  end += snprintf(end, sizeof(buf) - (end - buf), "%sNo Expire",
116  need_comma ? commastr : "");
117  need_comma = 1;
118  }
119  printf(" Options: %s\n", *buf ? buf : "None");
120 
121  if (na->nc->flags & NI_SUSPENDED) {
122  if (na->last_quit) {
123  printf
124  ("This nickname is currently suspended, reason: %s\n",
125  na->last_quit);
126  } else {
127  printf("This nickname is currently suspended.\n");
128  }
129  }
130 
131 
132  } else {
133 
134  for (i = 0; i < 1024; i++) {
135  for (na = nalists[i]; na; na = na->next) {
136  printf(" %s %-20s %s\n",
137  na->status & NS_NO_EXPIRE ? "!" : " ",
138  na->nick, na->status & NS_VERBOTEN ?
139  "Disallowed (FORBID)" : (na->nc->
140  flags & NI_SUSPENDED ?
141  "Disallowed (SUSPENDED)" :
142  na->last_usermask));
143  count++;
144  }
145  }
146  printf("%d nicknames registered.\n", count);
147 
148  }
149 }
150 
151 /*************************************************************************/
152 
153 /* Return information on memory use. Assumes pointers are valid. */
154 
155 void get_aliases_stats(long *nrec, long *memuse)
156 {
157  long count = 0, mem = 0;
158  int i;
159  NickAlias *na;
160 
161  for (i = 0; i < 1024; i++) {
162  for (na = nalists[i]; na; na = na->next) {
163  count++;
164  mem += sizeof(*na);
165  if (na->nick)
166  mem += strlen(na->nick) + 1;
167  if (na->last_usermask)
168  mem += strlen(na->last_usermask) + 1;
169  if (na->last_realname)
170  mem += strlen(na->last_realname) + 1;
171  if (na->last_quit)
172  mem += strlen(na->last_quit) + 1;
173  }
174  }
175  *nrec = count;
176  *memuse = mem;
177 }
178 
179 /*************************************************************************/
180 
181 /* Return information on memory use. Assumes pointers are valid. */
182 
183 void get_core_stats(long *nrec, long *memuse)
184 {
185  long count = 0, mem = 0;
186  int i, j;
187  NickCore *nc;
188  char **accptr;
189 
190  for (i = 0; i < 1024; i++) {
191  for (nc = nclists[i]; nc; nc = nc->next) {
192  count++;
193  mem += sizeof(*nc);
194 
195  if (nc->display)
196  mem += strlen(nc->display) + 1;
197  if (nc->pass)
198  mem += strlen(nc->pass) + 1;
199 
200  if (nc->url)
201  mem += strlen(nc->url) + 1;
202  if (nc->email)
203  mem += strlen(nc->email) + 1;
204  if (nc->greet)
205  mem += strlen(nc->greet) + 1;
206 
207  mem += sizeof(char *) * nc->accesscount;
208  for (accptr = nc->access, j = 0; j < nc->accesscount;
209  accptr++, j++) {
210  if (*accptr)
211  mem += strlen(*accptr) + 1;
212  }
213 
214  mem += nc->memos.memocount * sizeof(Memo);
215  for (j = 0; j < nc->memos.memocount; j++) {
216  if (nc->memos.memos[j].text)
217  mem += strlen(nc->memos.memos[j].text) + 1;
218  }
219 
220  mem += sizeof(void *) * nc->aliases.count;
221  }
222  }
223  *nrec = count;
224  *memuse = mem;
225 }
226 
227 /*************************************************************************/
228 /*************************************************************************/
229 
230 /* NickServ initialization. */
231 
232 void ns_init(void)
233 {
235  guestnum = time(NULL);
236  while (guestnum > 9999999)
237  guestnum -= 10000000;
238 }
239 
240 /*************************************************************************/
241 
242 /* Main NickServ routine. */
243 
244 void nickserv(User * u, char *buf)
245 {
246  char *cmd, *s;
247 
248  cmd = strtok(buf, " ");
249 
250  if (!cmd) {
251  return;
252  } else if (stricmp(cmd, "\1PING") == 0) {
253  if (!(s = strtok(NULL, ""))) {
254  s = "";
255  }
256  anope_cmd_ctcp(s_NickServ, u->nick, "PING %s", s);
257  } else if (skeleton) {
258  notice_lang(s_NickServ, u, SERVICE_OFFLINE, s_NickServ);
259  } else {
260  mod_run_cmd(s_NickServ, u, NICKSERV, cmd);
261  }
262 
263 }
264 
265 /*************************************************************************/
266 
267 /* Load/save data files. */
268 
269 
270 #define SAFE(x) do { \
271  if ((x) < 0) { \
272  if (!forceload) \
273  fatal("Read error on %s", NickDBName); \
274  failed = 1; \
275  break; \
276  } \
277 } while (0)
278 
279 /* Loads NickServ database versions 5 to 11 (<= 4 is not supported) */
280 
282 {
283  dbFILE *f;
284  int ver, i, j, c;
285  NickAlias *na, *na2, *next;
286  NickCore *nc;
287  int failed = 0;
288 
289  uint16 tmp16;
290  uint32 tmp32;
291 
292  char bufn[NICKMAX], bufp[PASSMAX];
293  char *email, *greet, *url, *forbidby, *forbidreason;
294  uint32 icq;
295 
296  if (!(f = open_db(s_NickServ, NickDBName, "r", NICK_VERSION)))
297  return;
298 
299  ver = get_file_version(f);
300  if (ver <= 4) {
301  fatal("Unsupported version number (%d) on %s", ver, NickDBName);
302  close_db(f);
303  return;
304  }
305 
306  for (i = 0; i < 256 && !failed; i++) {
307  while ((c = getc_db(f)) == 1) {
308  if (c != 1)
309  fatal("Invalid format in %s", NickDBName);
310 
311  na = scalloc(sizeof(NickAlias), 1);
312 
313  SAFE(read_buffer(bufn, f));
314  na->nick = sstrdup(bufn);
315  SAFE(read_buffer(bufp, f)); /* Will be used later if needed */
316 
317  SAFE(read_string(&url, f));
318  SAFE(read_string(&email, f));
319  if (ver >= 10)
320  SAFE(read_int32(&icq, f));
321  else
322  icq = 0;
323  if (ver >= 9)
324  SAFE(read_string(&greet, f));
325  else
326  greet = NULL;
327 
328  SAFE(read_string(&na->last_usermask, f));
329  SAFE(read_string(&na->last_realname, f));
330  SAFE(read_string(&na->last_quit, f));
331 
332  SAFE(read_int32(&tmp32, f));
333  na->time_registered = tmp32;
334  SAFE(read_int32(&tmp32, f));
335  na->last_seen = tmp32;
336 
337  SAFE(read_int16(&na->status, f));
338  na->status &= ~NS_TEMPORARY;
339 
340  if (ver >= 9) {
341  SAFE(read_string(&forbidby, f));
342  SAFE(read_string(&forbidreason, f));
343  /* Cleanup */
344  if (forbidby && *forbidby == '@') {
345  free(forbidby);
346  forbidby = NULL;
347  }
348  if (forbidreason && *forbidreason == 0) {
349  free(forbidreason);
350  forbidreason = NULL;
351  }
352  } else {
353  forbidby = NULL;
354  forbidreason = NULL;
355  }
356 
357  if (na->status & NS_VERBOTEN) {
358  if (na->last_usermask)
359  free(na->last_usermask);
360  if (na->last_realname)
361  free(na->last_realname);
362 
363  na->last_usermask = forbidby;
364  na->last_realname = forbidreason;
365  } else {
366  if (!na->last_usermask)
367  na->last_usermask = sstrdup("");
368  if (!na->last_realname)
369  na->last_realname = sstrdup("");
370  }
371 
372  /* Store the reference for later resolving */
373  SAFE(read_string((char **) &na->nc, f));
374  SAFE(read_int16(&tmp16, f)); /* Was linkcount */
375 
376  if (na->nc) {
377  SAFE(read_int16(&tmp16, f)); /* Was channelcount */
378  } else {
379  /* This nick was a master nick, so it also has all the
380  * core info! =)
381  */
382  nc = scalloc(1, sizeof(NickCore));
383  slist_init(&nc->aliases);
384 
385  /* The initial display is what used to be the master nick */
386  nc->display = sstrdup(na->nick);
387 
388  /* We grabbed info before; fill the appropriate fields now */
389  if (*bufp)
390  memcpy(nc->pass, bufp, PASSMAX);
391  else
392  memset(nc->pass, 0, PASSMAX); /* Which may be the case for forbidden nicks .. */
393 
394  nc->email = email;
395  nc->greet = greet;
396  nc->icq = icq;
397  nc->url = url;
398 
399  /* We check whether the e-mail is valid because it was not tested
400  * in older versions.
401  */
402  if (ver <= 10 && nc->email && !MailValidate(nc->email)) {
403  free(nc->email);
404  nc->email = NULL;
405  }
406 
407  SAFE(read_int32(&nc->flags, f));
408  if (!NSAllowKillImmed)
409  nc->flags &= ~NI_KILL_IMMED;
410 
411  /* Status flags cleanup */
412  if (na->status & NS_OLD_ENCRYPTEDPW) {
413  nc->flags |= NI_ENCRYPTEDPW;
414  na->status &= ~NS_OLD_ENCRYPTEDPW;
415  }
416 
417  /* Add services opers and admins to the appropriate list, but
418  only if the database version is equal to or more than 10. */
419  if (ver >= 10) {
420  if (nc->flags & NI_SERVICES_ADMIN)
421  slist_add(&servadmins, nc);
422  if (nc->flags & NI_SERVICES_OPER)
423  slist_add(&servopers, nc);
424  }
425 
426  /* Add the Services root flag if needed. */
427  if (nc)
428  for (j = 0; j < RootNumber; j++)
429  if (!stricmp(ServicesRoots[j], na->nick))
430  nc->flags |= NI_SERVICES_ROOT;
431 
432  SAFE(read_int16(&nc->accesscount, f));
433  if (nc->accesscount) {
434  char **access;
435  access = scalloc(sizeof(char *) * nc->accesscount, 1);
436  nc->access = access;
437  for (j = 0; j < nc->accesscount; j++, access++)
438  SAFE(read_string(access, f));
439  }
440 
441  SAFE(read_int16(&tmp16, f));
442  nc->memos.memocount = (int16) tmp16;
443  SAFE(read_int16(&tmp16, f));
444  nc->memos.memomax = (int16) tmp16;
445  if (nc->memos.memocount) {
446  Memo *memos;
447  memos = scalloc(sizeof(Memo) * nc->memos.memocount, 1);
448  nc->memos.memos = memos;
449 
450  for (j = 0; j < nc->memos.memocount; j++, memos++) {
451  SAFE(read_int32(&memos->number, f));
452  SAFE(read_int16(&memos->flags, f));
453  SAFE(read_int32(&tmp32, f));
454  memos->time = tmp32;
455  SAFE(read_buffer(memos->sender, f));
456  SAFE(read_string(&memos->text, f));
457  memos->moduleData = NULL;
458  }
459  }
460 
461  /* We read the channel count, but don't take care of it.
462  load_cs_dbase will regenerate it correctly. */
463  SAFE(read_int16(&tmp16, f));
464  SAFE(read_int16(&nc->channelmax, f));
465  if (ver == 5)
466  nc->channelmax = CSMaxReg;
467 
468  SAFE(read_int16(&nc->language, f));
469 
470  if (ver >= 11 && ver < 13) {
471  char *s;
472 
473  SAFE(read_int16(&tmp16, f));
474  SAFE(read_int32(&tmp32, f));
475  SAFE(read_int16(&tmp16, f));
476  SAFE(read_string(&s, f));
477  }
478 
479  /* Set us as being a master nick; fill the nc field also.
480  The NS_MASTER flag will not be cleared in this function. */
481  na->status |= NS_MASTER;
482  na->nc = nc;
483  slist_add(&nc->aliases, na);
484 
485  /* Insert our new core in the core list */
486  insert_core(nc);
487  }
488 
489  alpha_insert_alias(na);
490 
491  } /* while (getc_db(f) != 0) */
492  } /* for (i) */
493 
494  /* Now resolve what were called links */
495  for (i = 0; i < 1024; i++) {
496  for (na = nalists[i]; na; na = next) {
497  next = na->next;
498 
499  /* Master nicks are already resolved */
500  if (na->status & NS_MASTER)
501  continue;
502 
503  na2 = na;
504  /* While the reference resolves and it's not a master nick */
505  while ((na2 = findnick((char *) na2->nc))
506  && !(na2->status & NS_MASTER));
507 
508  /* It didn't resolve. This is problematic since there is no core. :/
509  We delete the nick. */
510  if (!na2) {
511  alog("%s: while loading database: %s was linked to inexistant %s", s_NickServ, na->nick, (char *) na->nc);
512  delnick(na);
513  continue;
514  }
515 
516  /* OK we have information on the core. We mark the current alias
517  as a master nick because it now contains a valid core. */
518  na->nc = na2->nc;
519  na->status |= NS_MASTER;
520  slist_add(&na->nc->aliases, na);
521  }
522  }
523 
524  close_db(f);
525 }
526 
527 void load_ns_req_db(void)
528 {
529  dbFILE *f;
530  int i, c, ver;
531  NickRequest *nr;
532  uint32 tmp32;
533  int failed = 0, len;
534  char *pass;
535 
537  return;
538  ver = get_file_version(f);
539  for (i = 0; i < 1024 && !failed; i++) {
540  while ((c = getc_db(f)) == 1) {
541  if (c != 1)
542  fatal("Invalid format in %s", PreNickDBName);
543  nr = scalloc(1, sizeof(NickRequest));
544  SAFE(read_string(&nr->nick, f));
545  SAFE(read_string(&nr->passcode, f));
546  if (ver < 2) {
547  SAFE(read_string(&pass, f));
548  len = strlen(pass);
549  enc_encrypt(pass, len, nr->password, PASSMAX);
550  memset(pass, 0, len);
551  free(pass);
552  } else
553  SAFE(read_buffer(nr->password, f));
554  SAFE(read_string(&nr->email, f));
555  SAFE(read_int32(&tmp32, f));
556  nr->requested = tmp32;
557  insert_requestnick(nr);
558  }
559  }
560  close_db(f);
561 }
562 
563 void load_ns_dbase(void)
564 {
565  dbFILE *f;
566  int ver, i, j, c;
567  NickAlias *na, **nalast, *naprev;
568  NickCore *nc, **nclast, *ncprev;
569  int failed = 0;
570  uint16 tmp16;
571  uint32 tmp32;
572  char *s, *pass;
573 
574  if (!(f = open_db(s_NickServ, NickDBName, "r", NICK_VERSION)))
575  return;
576 
577  ver = get_file_version(f);
578 
579  if (ver <= 11) {
580  close_db(f);
582  return;
583  }
584 
585  /* First we load nick cores */
586  for (i = 0; i < 1024 && !failed; i++) {
587  nclast = &nclists[i];
588  ncprev = NULL;
589 
590  while ((c = getc_db(f)) == 1) {
591  if (c != 1)
592  fatal("Invalid format in %s", NickDBName);
593 
594  nc = scalloc(1, sizeof(NickCore));
595  *nclast = nc;
596  nclast = &nc->next;
597  nc->prev = ncprev;
598  ncprev = nc;
599 
600  slist_init(&nc->aliases);
601 
602  SAFE(read_string(&nc->display, f));
603  if (ver < 14) {
604  SAFE(read_string(&pass, f));
605  if (pass) {
606  memset(nc->pass, 0, PASSMAX);
607  memcpy(nc->pass, pass, strlen(pass));
608  } else
609  memset(nc->pass, 0, PASSMAX);
610  } else
611  SAFE(read_buffer(nc->pass, f));
612 
613  SAFE(read_string(&nc->email, f));
614  SAFE(read_string(&nc->greet, f));
615  SAFE(read_int32(&nc->icq, f));
616  SAFE(read_string(&nc->url, f));
617 
618  SAFE(read_int32(&nc->flags, f));
619  if (!NSAllowKillImmed)
620  nc->flags &= ~NI_KILL_IMMED;
621  SAFE(read_int16(&nc->language, f));
622 
623  /* Add services opers and admins to the appropriate list, but
624  only if the database version is more than 10. */
625  if (nc->flags & NI_SERVICES_ADMIN)
626  slist_add(&servadmins, nc);
627  if (nc->flags & NI_SERVICES_OPER)
628  slist_add(&servopers, nc);
629 
630  SAFE(read_int16(&nc->accesscount, f));
631  if (nc->accesscount) {
632  char **access;
633  access = scalloc(sizeof(char *) * nc->accesscount, 1);
634  nc->access = access;
635  for (j = 0; j < nc->accesscount; j++, access++)
636  SAFE(read_string(access, f));
637  }
638 
639  SAFE(read_int16(&tmp16, f));
640  nc->memos.memocount = (int16) tmp16;
641  SAFE(read_int16(&tmp16, f));
642  nc->memos.memomax = (int16) tmp16;
643  if (nc->memos.memocount) {
644  Memo *memos;
645  memos = scalloc(sizeof(Memo) * nc->memos.memocount, 1);
646  nc->memos.memos = memos;
647  for (j = 0; j < nc->memos.memocount; j++, memos++) {
648  SAFE(read_int32(&memos->number, f));
649  SAFE(read_int16(&memos->flags, f));
650  SAFE(read_int32(&tmp32, f));
651  memos->time = tmp32;
652  SAFE(read_buffer(memos->sender, f));
653  SAFE(read_string(&memos->text, f));
654  memos->moduleData = NULL;
655  }
656  }
657 
658  SAFE(read_int16(&nc->channelcount, f));
659  SAFE(read_int16(&tmp16, f));
660  nc->channelmax = CSMaxReg;
661 
662  if (ver < 13) {
663  /* Used to be dead authentication system */
664  SAFE(read_int16(&tmp16, f));
665  SAFE(read_int32(&tmp32, f));
666  SAFE(read_int16(&tmp16, f));
667  SAFE(read_string(&s, f));
668  }
669 
670  } /* while (getc_db(f) != 0) */
671  *nclast = NULL;
672  } /* for (i) */
673 
674  for (i = 0; i < 1024 && !failed; i++) {
675  nalast = &nalists[i];
676  naprev = NULL;
677  while ((c = getc_db(f)) == 1) {
678  if (c != 1)
679  fatal("Invalid format in %s", NickDBName);
680 
681  na = scalloc(1, sizeof(NickAlias));
682 
683  SAFE(read_string(&na->nick, f));
684 
685  SAFE(read_string(&na->last_usermask, f));
686  SAFE(read_string(&na->last_realname, f));
687  SAFE(read_string(&na->last_quit, f));
688 
689  SAFE(read_int32(&tmp32, f));
690  na->time_registered = tmp32;
691  SAFE(read_int32(&tmp32, f));
692  na->last_seen = tmp32;
693  SAFE(read_int16(&na->status, f));
694  na->status &= ~NS_TEMPORARY;
695 
696  SAFE(read_string(&s, f));
697  na->nc = findcore(s);
698  free(s);
699 
700  if (!na->nc)
701  {
702  free(na);
703  continue;
704  }
705 
706  slist_add(&na->nc->aliases, na);
707 
708  if (!(na->status & NS_VERBOTEN)) {
709  if (!na->last_usermask)
710  na->last_usermask = sstrdup("");
711  if (!na->last_realname)
712  na->last_realname = sstrdup("");
713  }
714 
715  na->nc->flags &= ~NI_SERVICES_ROOT;
716 
717  *nalast = na;
718  nalast = &na->next;
719  na->prev = naprev;
720  naprev = na;
721 
722  } /* while (getc_db(f) != 0) */
723 
724  *nalast = NULL;
725  } /* for (i) */
726 
727  close_db(f);
728 
729  for (i = 0; i < 1024; i++) {
730  NickAlias *next;
731 
732  for (na = nalists[i]; na; na = next) {
733  next = na->next;
734  /* We check for coreless nicks (although it should never happen) */
735  if (!na->nc) {
736  alog("%s: while loading database: %s has no core! We delete it.", s_NickServ, na->nick);
737  delnick(na);
738  continue;
739  }
740 
741  /* Add the Services root flag if needed. */
742  for (j = 0; j < RootNumber; j++)
743  if (!stricmp(ServicesRoots[j], na->nick))
744  na->nc->flags |= NI_SERVICES_ROOT;
745  }
746  }
747 }
748 
749 #undef SAFE
750 
751 /*************************************************************************/
752 
753 #define SAFE(x) do { \
754  if ((x) < 0) { \
755  restore_db(f); \
756  log_perror("Write error on %s", NickDBName); \
757  if (time(NULL) - lastwarn > WarningTimeout) { \
758  anope_cmd_global(NULL, "Write error on %s: %s", NickDBName, \
759  strerror(errno)); \
760  lastwarn = time(NULL); \
761  } \
762  return; \
763  } \
764 } while (0)
765 
766 
767 
768 void save_ns_dbase(void)
769 {
770  dbFILE *f;
771  int i, j;
772  NickAlias *na;
773  NickCore *nc;
774  char **access;
775  Memo *memos;
776  static time_t lastwarn = 0;
777 
778  if (!(f = open_db(s_NickServ, NickDBName, "w", NICK_VERSION)))
779  return;
780 
781  for (i = 0; i < 1024; i++) {
782  for (nc = nclists[i]; nc; nc = nc->next) {
783  SAFE(write_int8(1, f));
784 
785  SAFE(write_string(nc->display, f));
786  SAFE(write_buffer(nc->pass, f));
787 
788  SAFE(write_string(nc->email, f));
789  SAFE(write_string(nc->greet, f));
790  SAFE(write_int32(nc->icq, f));
791  SAFE(write_string(nc->url, f));
792 
793  SAFE(write_int32(nc->flags, f));
794  SAFE(write_int16(nc->language, f));
795 
796  SAFE(write_int16(nc->accesscount, f));
797  for (j = 0, access = nc->access; j < nc->accesscount;
798  j++, access++)
799  SAFE(write_string(*access, f));
800 
801  SAFE(write_int16(nc->memos.memocount, f));
802  SAFE(write_int16(nc->memos.memomax, f));
803  memos = nc->memos.memos;
804  for (j = 0; j < nc->memos.memocount; j++, memos++) {
805  SAFE(write_int32(memos->number, f));
806  SAFE(write_int16(memos->flags, f));
807  SAFE(write_int32(memos->time, f));
808  SAFE(write_buffer(memos->sender, f));
809  SAFE(write_string(memos->text, f));
810  }
811 
812  SAFE(write_int16(nc->channelcount, f));
813  SAFE(write_int16(nc->channelmax, f));
814 
815  } /* for (nc) */
816 
817  SAFE(write_int8(0, f));
818 
819  } /* for (i) */
820 
821  for (i = 0; i < 1024; i++) {
822  for (na = nalists[i]; na; na = na->next) {
823  SAFE(write_int8(1, f));
824 
825  SAFE(write_string(na->nick, f));
826 
829  SAFE(write_string(na->last_quit, f));
830 
832  SAFE(write_int32(na->last_seen, f));
833 
834  SAFE(write_int16(na->status, f));
835 
836  SAFE(write_string(na->nc->display, f));
837 
838  } /* for (na) */
839  SAFE(write_int8(0, f));
840  } /* for (i) */
841 
842  close_db(f);
843 
844 }
845 
847 {
848  dbFILE *f;
849  int i;
850  NickRequest *nr;
851  static time_t lastwarn = 0;
852 
854  return;
855 
856  for (i = 0; i < 1024; i++) {
857  for (nr = nrlists[i]; nr; nr = nr->next) {
858  SAFE(write_int8(1, f));
859  SAFE(write_string(nr->nick, f));
860  SAFE(write_string(nr->passcode, f));
861  SAFE(write_buffer(nr->password, f));
862  SAFE(write_string(nr->email, f));
863  SAFE(write_int32(nr->requested, f));
864  SAFE(write_int8(0, f));
865  }
866  }
867  close_db(f);
868 
869 }
870 
871 #undef SAFE
872 
874 {
875 #ifdef USE_RDB
876  int i;
877  NickAlias *na;
878  NickCore *nc;
879 
880  if (!rdb_open())
881  return;
882 
883  if (rdb_tag_table("anope_ns_core") == 0) {
884  alog("Unable to tag 'anope_ns_core' - NickServ RDB save failed.");
885  rdb_close();
886  return;
887  }
888  if (rdb_tag_table("anope_ns_alias") == 0) {
889  alog("Unable to tag 'anope_ns_alias' - NickServ RDB save failed.");
890  rdb_close();
891  return;
892  }
893  if (rdb_tag_table("anope_ns_access") == 0) {
894  alog("Unable to tag 'anope_ns_access' - NickServ RDB save failed.");
895  rdb_close();
896  return;
897  }
898  if (rdb_tag_table_where("anope_ms_info", "serv='NICK'") == 0) {
899  alog("Unable to tag 'anope_ms_info' - NickServ RDB save failed.");
900  rdb_close();
901  return;
902  }
903 
904  for (i = 0; i < 1024; i++) {
905  for (nc = nclists[i]; nc; nc = nc->next) {
906  if (rdb_save_ns_core(nc) == 0) {
907  alog("Unable to save NickCore for '%s' - NickServ RDB save failed.", nc->display);
908  rdb_close();
909  return;
910  }
911  } /* for (nc) */
912  } /* for (i) */
913 
914  for (i = 0; i < 1024; i++) {
915  for (na = nalists[i]; na; na = na->next) {
916  if (rdb_save_ns_alias(na) == 0) {
917  alog("Unable to save NickAlias for '%s' - NickServ RDB save failed.", na->nick);
918  rdb_close();
919  return;
920  }
921  } /* for (na) */
922  } /* for (i) */
923 
924  if (rdb_clean_table("anope_ns_core") == 0) {
925  alog("Unable to clean table 'anope_ns_core' - NickServ RDB save failed.");
926  rdb_close();
927  return;
928  }
929  if (rdb_clean_table("anope_ns_alias") == 0) {
930  alog("Unable to clean table 'anope_ns_alias' - NickServ RDB save failed.");
931  rdb_close();
932  return;
933  }
934  if (rdb_clean_table("anope_ns_access") == 0) {
935  alog("Unable to clean table 'anope_ns_access' - NickServ RDB save failed.");
936  rdb_close();
937  return;
938  }
939  if (rdb_clean_table_where("anope_ms_info", "serv='NICK'") == 0)
940  alog("Unable to clean table 'anope_ms_info' - NickServ RDB save failed.");
941 
942  rdb_close();
943 #endif
944 }
945 
947 {
948 #ifdef USE_RDB
949  int i;
950  NickRequest *nr;
951 
952  if (!rdb_open())
953  return;
954 
955  if (rdb_tag_table("anope_ns_request") == 0) {
956  alog("Unable to tag table 'anope_ns_request' - NickServ Request RDB save failed.");
957  rdb_close();
958  return;
959  }
960 
961  for (i = 0; i < 1024; i++) {
962  for (nr = nrlists[i]; nr; nr = nr->next) {
963  if (rdb_save_ns_req(nr) == 0) {
964  /* Something went wrong - abort saving */
965  alog("Unable to save NickRequest (nick '%s') - NickServ Request RDB save failed.", nr->nick);
966  rdb_close();
967  return;
968  }
969  }
970  }
971 
972  if (rdb_clean_table("anope_ns_request") == 0)
973  alog("Unable to clean table 'anope_ns_request' - NickServ Request RDB save failed.");
974 
975  rdb_close();
976 #endif
977 
978 }
979 
980 /*************************************************************************/
981 
982 /* Check whether a user is on the access list of the nick they're using If
983  * not, send warnings as appropriate. If so (and not NI_SECURE), update
984  * last seen info.
985  * Return 1 if the user is valid and recognized, 0 otherwise (note
986  * that this means an NI_SECURE nick will return 0 from here).
987  * If the user's nick is not registered, 0 is returned.
988  */
989 
991 {
992  NickAlias *na;
993  NickRequest *nr;
994 
995  int on_access;
996 
997  if ((nr = findrequestnick(u->nick))) {
998  notice_lang(s_NickServ, u, NICK_IS_PREREG);
999  }
1000 
1001  if (!(na = u->na))
1002  return 0;
1003 
1004  if (na->status & NS_VERBOTEN) {
1005  notice_lang(s_NickServ, u, NICK_MAY_NOT_BE_USED);
1006  collide(na, 0);
1007  return 0;
1008  }
1009 
1010  if (na->nc->flags & NI_SUSPENDED) {
1011  notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nick);
1012  collide(na, 0);
1013  return 0;
1014  }
1015 
1016  if (na->status & NS_IDENTIFIED)
1017  return 1;
1018 
1019  on_access = is_on_access(u, na->nc);
1020  if (on_access)
1021  na->status |= NS_ON_ACCESS;
1022 
1023  if (!(na->nc->flags & NI_SECURE) && on_access) {
1024  na->status |= NS_RECOGNIZED;
1025  na->last_seen = time(NULL);
1026  if (na->last_usermask)
1027  free(na->last_usermask);
1028  na->last_usermask =
1029  scalloc(strlen(common_get_vident(u)) +
1030  strlen(common_get_vhost(u)) + 2, 1);
1031  sprintf(na->last_usermask, "%s@%s", common_get_vident(u),
1032  common_get_vhost(u));
1033  if (na->last_realname)
1034  free(na->last_realname);
1035  na->last_realname = sstrdup(u->realname);
1036  return 1;
1037  }
1038 
1039  if (on_access || !(na->nc->flags & NI_KILL_IMMED)) {
1040  if (na->nc->flags & NI_SECURE)
1041  notice_lang(s_NickServ, u, NICK_IS_SECURE, s_NickServ);
1042  else
1043  notice_lang(s_NickServ, u, NICK_IS_REGISTERED, s_NickServ);
1044  }
1045 
1046  if ((na->nc->flags & NI_KILLPROTECT) && !on_access) {
1047  if (na->nc->flags & NI_KILL_IMMED) {
1048  notice_lang(s_NickServ, u, FORCENICKCHANGE_NOW);
1049  collide(na, 0);
1050  } else if (na->nc->flags & NI_KILL_QUICK) {
1051  notice_lang(s_NickServ, u, FORCENICKCHANGE_IN_20_SECONDS);
1052  add_ns_timeout(na, TO_COLLIDE, 20);
1053  } else {
1054  notice_lang(s_NickServ, u, FORCENICKCHANGE_IN_1_MINUTE);
1055  add_ns_timeout(na, TO_COLLIDE, 60);
1056  }
1057  }
1058 
1059  return 0;
1060 }
1061 
1062 /*************************************************************************/
1063 
1064 /* Cancel validation flags for a nick (i.e. when the user with that nick
1065  * signs off or changes nicks). Also cancels any impending collide. */
1066 
1068 {
1069  NickAlias *na = u->na;
1070 
1071  if (na) {
1072  if (na->status & NS_GUESTED) {
1073  if (ircd->svshold) {
1074  if (UseSVSHOLD) {
1075  anope_cmd_svshold(na->nick);
1076  } else {
1077  if (ircd->svsnick) {
1080  "Services Enforcer", "+");
1082  } else {
1084  "Killing to enforce nick");
1085  }
1086  }
1087  } else {
1088  if (ircd->svsnick) {
1091  "Services Enforcer", "+");
1093  } else {
1095  "Killing to enforce nick");
1096  }
1097  }
1098  na->status &= ~NS_TEMPORARY;
1099  na->status |= NS_KILL_HELD;
1100  } else {
1101  na->status &= ~NS_TEMPORARY;
1102  }
1104  }
1105 }
1106 
1107 /*************************************************************************/
1108 
1109 /* Return whether a user has identified for their nickname. */
1110 
1112 {
1113  if (u) {
1114  if (u->na) {
1115  if (u->na->status) {
1116  return (u->na->status & NS_IDENTIFIED);
1117  } else {
1118  return 0;
1119  }
1120  } else {
1121  return 0;
1122  }
1123  }
1124  return 0;
1125 }
1126 
1127 /*************************************************************************/
1128 
1129 /* Return whether a user is recognized for their nickname. */
1130 
1132 {
1133  if (u) {
1134  if (u->na) {
1135  if (u->na->status) {
1136  return (u->na->status & (NS_IDENTIFIED | NS_RECOGNIZED));
1137  } else {
1138  return 0;
1139  }
1140  } else {
1141  return 0;
1142  }
1143  }
1144  return 0;
1145 }
1146 
1147 /*************************************************************************/
1148 
1149 /* Returns whether a user is identified AND in the group nc */
1150 
1152 {
1153  return nick_identified(u) && u->na->nc == nc;
1154 }
1155 
1156 /*************************************************************************/
1157 
1158 /* Remove all nicks which have expired. Also update last-seen time for all
1159  * nicks.
1160  */
1161 
1163 {
1164  int i;
1165  NickAlias *na, *next;
1166  time_t now = time(NULL);
1167  char *tmpnick;
1168 
1169  for (i = 0; i < 1024; i++) {
1170  for (na = nalists[i]; na; na = next) {
1171  next = na->next;
1172 
1173  if (na->u
1174  && ((na->nc->flags & NI_SECURE) ? nick_identified(na->u) :
1175  nick_recognized(na->u))) {
1176  if (debug >= 2)
1177  alog("debug: NickServ: updating last seen time for %s",
1178  na->nick);
1179  na->last_seen = now;
1180  continue;
1181  }
1182 
1183  if (NSExpire && now - na->last_seen >= NSExpire
1184  && !(na->status & (NS_VERBOTEN | NS_NO_EXPIRE))
1185  && !(na->nc->flags & (NI_SUSPENDED))) {
1186  alog("Expiring nickname %s (group: %s) (e-mail: %s)",
1187  na->nick, na->nc->display,
1188  (na->nc->email ? na->nc->email : "none"));
1189  tmpnick = sstrdup(na->nick);
1190  delnick(na);
1191  send_event(EVENT_NICK_EXPIRE, 1, tmpnick);
1192  free(tmpnick);
1193  }
1194  }
1195  }
1196 }
1197 
1199 {
1200  int i;
1201  NickRequest *nr, *next;
1202  time_t now = time(NULL);
1203  for (i = 0; i < 1024; i++) {
1204  for (nr = nrlists[i]; nr; nr = next) {
1205  next = nr->next;
1206  if (NSRExpire && now - nr->requested >= NSRExpire) {
1207  alog("Request for nick %s expiring", nr->nick);
1208  delnickrequest(nr);
1209  }
1210  }
1211  }
1212 }
1213 
1214 /*************************************************************************/
1215 /*************************************************************************/
1216 /* Return the NickRequest structire for the given nick, or NULL */
1217 
1218 NickRequest *findrequestnick(const char *nick)
1219 {
1220  NickRequest *nr;
1221 
1222  if (!*nick || !nick) {
1223  if (debug) {
1224  alog("debug: findrequestnick() called with NULL values");
1225  }
1226  return NULL;
1227  }
1228 
1229  for (nr = nrlists[HASH(nick)]; nr; nr = nr->next) {
1230  if (stricmp(nr->nick, nick) == 0)
1231  return nr;
1232  }
1233  return NULL;
1234 }
1235 
1236 /* Return the NickAlias structure for the given nick, or NULL if the nick
1237  * isn't registered. */
1238 
1239 NickAlias *findnick(const char *nick)
1240 {
1241  NickAlias *na;
1242 
1243  if (!nick || !*nick) {
1244  if (debug) {
1245  alog("debug: findnick() called with NULL values");
1246  }
1247  return NULL;
1248  }
1249 
1250  for (na = nalists[HASH(nick)]; na; na = na->next) {
1251  if (stricmp(na->nick, nick) == 0)
1252  return na;
1253  }
1254 
1255  return NULL;
1256 }
1257 
1258 /*************************************************************************/
1259 
1260 /* Return the NickCore structure for the given nick, or NULL if the core
1261  * doesn't exist. */
1262 
1263 NickCore *findcore(const char *nick)
1264 {
1265  NickCore *nc;
1266 
1267  if (!nick || !*nick) {
1268  if (debug) {
1269  alog("debug: findcore() called with NULL values");
1270  }
1271  return NULL;
1272  }
1273 
1274  for (nc = nclists[HASH(nick)]; nc; nc = nc->next) {
1275  if (stricmp(nc->display, nick) == 0)
1276  return nc;
1277  }
1278 
1279  return NULL;
1280 }
1281 
1282 /*************************************************************************/
1283 /*********************** NickServ private routines ***********************/
1284 /*************************************************************************/
1285 
1286 /* Is the given user's address on the given nick's access list? Return 1
1287  * if so, 0 if not. */
1288 
1290 {
1291  int i;
1292  char *buf, *buf2 = NULL, *buf3 = NULL;
1293 
1294  if (nc->accesscount == 0)
1295  return 0;
1296 
1297  buf = scalloc(strlen(u->username) + strlen(u->host) + 2, 1);
1298  sprintf(buf, "%s@%s", u->username, u->host);
1299  if (ircd->vhost) {
1300  if (u->vhost) {
1301  buf2 = scalloc(strlen(u->vident) + strlen(u->vhost) + 2, 1);
1302  sprintf(buf2, "%s@%s", u->vident, u->vhost);
1303  }
1304  if (u->chost)
1305  {
1306  buf3 = scalloc(strlen(u->username) + strlen(u->chost) + 2, 1);
1307  sprintf(buf3, "%s@%s", u->username, u->chost);
1308  }
1309  }
1310 
1311  for (i = 0; i < nc->accesscount; i++) {
1312  if (match_wild_nocase(nc->access[i], buf) || (buf2 && match_wild_nocase(nc->access[i], buf2)) || (buf3 && match_wild_nocase(nc->access[i], buf3)))
1313  {
1314  free(buf);
1315  if (ircd->vhost) {
1316  if (u->vhost) {
1317  free(buf2);
1318  }
1319  if (u->chost)
1320  free(buf3);
1321  }
1322  return 1;
1323  }
1324  }
1325  free(buf);
1326  if (buf2)
1327  free(buf2);
1328  if (buf3)
1329  free(buf3);
1330 
1331  return 0;
1332 }
1333 
1334 /*************************************************************************/
1335 
1336 /* Insert a nick alias alphabetically into the database. */
1337 
1339 {
1340  NickAlias *ptr, *prev;
1341  char *nick;
1342  int index;
1343 
1344  if (!na) {
1345  if (debug) {
1346  alog("debug: alpha_insert_alias called with NULL values");
1347  }
1348  return;
1349  }
1350 
1351  nick = na->nick;
1352  index = HASH(nick);
1353 
1354  for (prev = NULL, ptr = nalists[index];
1355  ptr && stricmp(ptr->nick, nick) < 0; prev = ptr, ptr = ptr->next);
1356  na->prev = prev;
1357  na->next = ptr;
1358  if (!prev)
1359  nalists[index] = na;
1360  else
1361  prev->next = na;
1362  if (ptr)
1363  ptr->prev = na;
1364 }
1365 
1366 /*************************************************************************/
1367 
1368 /* Insert a nick core into the database. */
1369 
1371 {
1372  int index;
1373 
1374  if (!nc) {
1375  if (debug) {
1376  alog("debug: insert_core called with NULL values");
1377  }
1378  return;
1379  }
1380 
1381  index = HASH(nc->display);
1382 
1383  nc->prev = NULL;
1384  nc->next = nclists[index];
1385  if (nc->next)
1386  nc->next->prev = nc;
1387  nclists[index] = nc;
1388 }
1389 
1390 /*************************************************************************/
1392 {
1393  int index;
1394  if (!nr) {
1395  if (debug) {
1396  alog("debug: insert_requestnick called with NULL values");
1397  }
1398  return;
1399  }
1400 
1401  index = HASH(nr->nick);
1402 
1403  nr->prev = NULL;
1404  nr->next = nrlists[index];
1405  if (nr->next)
1406  nr->next->prev = nr;
1407  nrlists[index] = nr;
1408 }
1409 
1410 /*************************************************************************/
1411 
1412 /* Sets nc->display to newdisplay. If newdisplay is NULL, it will change
1413  * it to the first alias in the list.
1414  */
1415 
1416 void change_core_display(NickCore * nc, char *newdisplay)
1417 {
1418  if (!newdisplay) {
1419  NickAlias *na;
1420 
1421  if (nc->aliases.count <= 0)
1422  return;
1423 
1424  na = nc->aliases.list[0];
1425  newdisplay = na->nick;
1426  }
1427 
1428  /* Log ... */
1429  alog("%s: changing %s nickname group display to %s", s_NickServ,
1430  nc->display, newdisplay);
1431  send_event(EVENT_CORE_NEWDISPLAY, 2, nc->display, newdisplay);
1432 
1433 #ifdef USE_RDB
1434  /* Reflect this change in the database right away. This
1435  * ensures that we know how to deal with this "new" nick
1436  * on the next /OS UPDATE might need it on /NS DROP too...
1437  */
1438  if (rdb_open()) {
1439  if (rdb_ns_set_display(newdisplay, nc->display) == 0) {
1440  alog("Unable to update display for %s - Nick Display RDB update failed.", nc->display);
1441  }
1442  rdb_close();
1443  }
1444 #endif
1445 
1446  /* Remove the core from the list */
1447  if (nc->next)
1448  nc->next->prev = nc->prev;
1449  if (nc->prev)
1450  nc->prev->next = nc->next;
1451  else
1452  nclists[HASH(nc->display)] = nc->next;
1453 
1454  free(nc->display);
1455  nc->display = sstrdup(newdisplay);
1456  insert_core(nc);
1457 
1458 }
1459 
1460 /*************************************************************************/
1461 
1462 /* Deletes the core. This must be called only when there is no more
1463  * aliases for it, because no cleanup is done.
1464  * This function removes all references to the core as well.
1465  */
1466 
1467 static int delcore(NickCore * nc)
1468 {
1469  int i;
1470 #ifdef USE_RDB
1471  static char clause[128];
1472  char *q_display;
1473 #endif
1474 
1475  /* Inform everyone we will be deleted..
1476  * Some modules may link to the core and should be told when we
1477  * are no longer around.. ~ Viper */
1479  /* (Hopefully complete) cleanup */
1480  cs_remove_nick(nc);
1481  os_remove_nick(nc);
1482 
1483  /* Remove the core from the list */
1484  if (nc->next)
1485  nc->next->prev = nc->prev;
1486  if (nc->prev)
1487  nc->prev->next = nc->next;
1488  else
1489  nclists[HASH(nc->display)] = nc->next;
1490 
1491  /* Log .. */
1492  alog("%s: deleting nickname group %s", s_NickServ, nc->display);
1493 
1494 #ifdef USE_RDB
1495  /* Reflect this change in the database right away. */
1496  if (rdb_open()) {
1497  q_display = rdb_quote(nc->display);
1498  snprintf(clause, sizeof(clause), "display='%s'", q_display);
1499  if (rdb_scrub_table("anope_ns_access", clause) == 0)
1500  alog("Unable to scrub table 'anope_ns_access' - RDB update failed.");
1501  else if (rdb_scrub_table("anope_ns_core", clause) == 0)
1502  alog("Unable to scrub table 'anope_ns_core' - RDB update failed.");
1503  else if (rdb_scrub_table("anope_cs_access", clause) == 0)
1504  alog("Unable to scrub table 'anope_cs_access' - RDB update failed.");
1505  else {
1506  /* I'm unsure how to clean up the OS ADMIN/OPER list on the db */
1507  /* I wish the "display" primary key would be the same on all tables */
1508  snprintf(clause, sizeof(clause),
1509  "receiver='%s' AND serv='NICK'", q_display);
1510  if (rdb_scrub_table("anope_ms_info", clause) == 0)
1511  alog("Unable to scrub table 'anope_ms_info' - RDB update failed.");
1512  }
1513  rdb_close();
1514  free(q_display);
1515  }
1516 #endif
1517 
1518  /* Now we can safely free it. */
1519  free(nc->display);
1520 
1521  if (nc->email)
1522  free(nc->email);
1523  if (nc->greet)
1524  free(nc->greet);
1525  if (nc->url)
1526  free(nc->url);
1527 
1528  if (nc->access) {
1529  for (i = 0; i < nc->accesscount; i++) {
1530  if (nc->access[i])
1531  free(nc->access[i]);
1532  }
1533  free(nc->access);
1534  }
1535 
1536  if (nc->memos.memos) {
1537  for (i = 0; i < nc->memos.memocount; i++) {
1538  if (nc->memos.memos[i].text)
1539  free(nc->memos.memos[i].text);
1541  }
1542  free(nc->memos.memos);
1543  }
1544 
1546 
1547  free(nc);
1548 
1549  return 1;
1550 }
1551 
1552 
1553 /*************************************************************************/
1555 {
1556  if (nr) {
1557  if (nr->next)
1558  nr->next->prev = nr->prev;
1559  if (nr->prev)
1560  nr->prev->next = nr->next;
1561  else
1562  nrlists[HASH(nr->nick)] = nr->next;
1563 
1564  if (nr->nick)
1565  free(nr->nick);
1566  if (nr->passcode)
1567  free(nr->passcode);
1568  if (nr->email)
1569  free(nr->email);
1570  free(nr);
1571  }
1572 
1573  return 0;
1574 }
1575 
1576 /*************************************************************************/
1577 
1578 /* Deletes an alias. The core will also be deleted if it has no more
1579  * nicks attached to it. Easy but powerful.
1580  * Well, we must also take care that the nick being deleted is not
1581  * the core display, and if so, change it to the next alias in the list,
1582  * otherwise weird things will happen.
1583  * Returns 1 on success, 0 otherwise.
1584  */
1585 
1587 {
1588 #ifdef USE_RDB
1589  static char clause[128];
1590  char *q_nick;
1591 #endif
1592  /* First thing to do: remove any timeout belonging to the nick we're deleting */
1593  clean_ns_timeouts(na);
1594 
1595  /* Second thing to do: look for an user using the alias
1596  * being deleted, and make appropriate changes */
1597 
1598  if (na->u) {
1599  na->u->na = NULL;
1600 
1601  if (ircd->modeonunreg)
1602  common_svsmode(na->u, ircd->modeonunreg, "1");
1603 
1604  }
1605 
1606  delHostCore(na->nick); /* delete any vHost's for this nick */
1607 
1608  /* Accept nicks that have no core, because of database load functions */
1609  if (na->nc) {
1610  /* Next: see if our core is still useful. */
1611  slist_remove(&na->nc->aliases, na);
1612  if (na->nc->aliases.count == 0) {
1613  if (!delcore(na->nc))
1614  return 0;
1615  na->nc = NULL;
1616  } else {
1617  /* Display updating stuff */
1618  if (!stricmp(na->nick, na->nc->display))
1619  change_core_display(na->nc, NULL);
1620  }
1621  }
1622 
1623  /* Remove us from the aliases list */
1624  if (na->next)
1625  na->next->prev = na->prev;
1626  if (na->prev)
1627  na->prev->next = na->next;
1628  else
1629  nalists[HASH(na->nick)] = na->next;
1630 
1631 #ifdef USE_RDB
1632  /* Reflect this change in the database right away. */
1633  if (rdb_open()) {
1634  q_nick = rdb_quote(na->nick);
1635  snprintf(clause, sizeof(clause), "nick='%s'", q_nick);
1636  if (rdb_scrub_table("anope_ns_alias", clause) == 0)
1637  alog("Unable to scrub table 'anope_ns_alias' - RDB update failed");
1638  rdb_close();
1639  free(q_nick);
1640  }
1641 #endif
1642 
1643  free(na->nick);
1644  if (na->last_usermask)
1645  free(na->last_usermask);
1646  if (na->last_realname)
1647  free(na->last_realname);
1648  if (na->last_quit)
1649  free(na->last_quit);
1650 
1652 
1653  free(na);
1654 
1655 
1656  return 1;
1657 }
1658 
1659 /*************************************************************************/
1660 /*************************************************************************/
1661 
1662 /* Collide a nick.
1663  *
1664  * When connected to a network using DALnet servers, version 4.4.15 and above,
1665  * Services is now able to force a nick change instead of killing the user.
1666  * The new nick takes the form "Guest######". If a nick change is forced, we
1667  * do not introduce the enforcer nick until the user's nick actually changes.
1668  * This is watched for and done in cancel_user(). -TheShadow
1669  */
1670 
1671 void collide(NickAlias * na, int from_timeout)
1672 {
1673  char guestnick[NICKMAX];
1674 
1675  if (!from_timeout)
1677 
1678  /* Old system was unsure since there can be more than one collide
1679  * per second. So let use another safer method.
1680  * --lara
1681  */
1682  /* So you should check the length of NSGuestNickPrefix, eh Lara?
1683  * --Certus
1684  */
1685 
1686  if (ircd->svsnick) {
1687  /* We need to make sure the guestnick is free -- heinz */
1688  do {
1689  snprintf(guestnick, sizeof(guestnick), "%s%d",
1691  } while (finduser(guestnick));
1692  notice_lang(s_NickServ, na->u, FORCENICKCHANGE_CHANGING,
1693  guestnick);
1694  anope_cmd_svsnick(na->nick, guestnick, time(NULL));
1695  na->status |= NS_GUESTED;
1696  } else {
1697  kill_user(s_NickServ, na->nick, "Services nickname-enforcer kill");
1698  }
1699 }
1700 
1701 /*************************************************************************/
1702 
1703 /* Release hold on a nick. */
1704 
1705 void release(NickAlias * na, int from_timeout)
1706 {
1707  if (!from_timeout)
1709  if (ircd->svshold) {
1710  if (UseSVSHOLD) {
1712  } else {
1713  anope_cmd_quit(na->nick, NULL);
1714  }
1715  } else {
1716  anope_cmd_quit(na->nick, NULL);
1717  }
1718  na->status &= ~NS_KILL_HELD;
1719 }
1720 
1721 /*************************************************************************/
1722 /*************************************************************************/
1723 
1724 static struct my_timeout {
1725  struct my_timeout *next, *prev;
1728  int type;
1729 } *my_timeouts;
1730 
1731 /*************************************************************************/
1732 
1733 /* Remove a collide/release timeout from our private list. */
1734 
1735 static void rem_ns_timeout(NickAlias * na, int type)
1736 {
1737  struct my_timeout *t, *t2;
1738 
1739  t = my_timeouts;
1740  while (t) {
1741  if (t->na == na && t->type == type) {
1742  t2 = t->next;
1743  if (t->next)
1744  t->next->prev = t->prev;
1745  if (t->prev)
1746  t->prev->next = t->next;
1747  else
1748  my_timeouts = t->next;
1749  free(t);
1750  t = t2;
1751  } else {
1752  t = t->next;
1753  }
1754  }
1755 }
1756 
1757 /*************************************************************************/
1758 
1759 /* Collide a nick on timeout. */
1760 
1761 static void timeout_collide(Timeout * t)
1762 {
1763  NickAlias *na = t->data;
1764 
1766  /* If they identified or don't exist anymore, don't kill them. */
1767  if ((na->status & NS_IDENTIFIED) || !na->u
1768  || na->u->my_signon > t->settime)
1769  return;
1770  /* The RELEASE timeout will always add to the beginning of the
1771  * list, so we won't see it. Which is fine because it can't be
1772  * triggered yet anyway. */
1773  collide(na, 1);
1774 }
1775 
1776 /*************************************************************************/
1777 
1778 /* Release a nick on timeout. */
1779 
1780 static void timeout_release(Timeout * t)
1781 {
1782  NickAlias *na = t->data;
1783 
1785  release(na, 1);
1786 }
1787 
1788 /*************************************************************************/
1789 
1790 /* Add a collide/release timeout. */
1791 
1792 static void add_ns_timeout(NickAlias * na, int type, time_t delay)
1793 {
1794  Timeout *to;
1795  struct my_timeout *t;
1796  void (*timeout_routine) (Timeout *);
1797 
1798  if (type == TO_COLLIDE)
1799  timeout_routine = timeout_collide;
1800  else if (type == TO_RELEASE)
1801  timeout_routine = timeout_release;
1802  else {
1803  alog("NickServ: unknown timeout type %d! na=0x%p (%s), delay=%ld",
1804  type, (void *) na, na->nick, (long int) delay);
1805  return;
1806  }
1807 
1808  to = add_timeout(delay, timeout_routine, 0);
1809  to->data = na;
1810 
1811  t = scalloc(sizeof(struct my_timeout), 1);
1812  t->na = na;
1813  t->to = to;
1814  t->type = type;
1815 
1816  t->prev = NULL;
1817  t->next = my_timeouts;
1818  my_timeouts = t;
1819  /* Andy Church should stop coding while being drunk.
1820  * Here's the two lines he forgot that produced the timed_update evil bug
1821  * and a *big* memory leak.
1822  */
1823  if (t->next)
1824  t->next->prev = t;
1825 }
1826 
1827 /*************************************************************************/
1828 
1829 /* Delete a collide/release timeout. */
1830 
1832 {
1833  struct my_timeout *t, *t2;
1834 
1835  t = my_timeouts;
1836  while (t) {
1837  if (t->na == na && t->type == type) {
1838  t2 = t->next;
1839  if (t->next)
1840  t->next->prev = t->prev;
1841  if (t->prev)
1842  t->prev->next = t->next;
1843  else
1844  my_timeouts = t->next;
1845  del_timeout(t->to);
1846  free(t);
1847  t = t2;
1848  } else {
1849  t = t->next;
1850  }
1851  }
1852 }
1853 
1854 /*************************************************************************/
1855 
1856 /* Deletes all timeouts belonging to a given nick.
1857  * This should only be called before nick deletion.
1858  */
1859 
1861 {
1862  struct my_timeout *t, *next;
1863 
1864  for (t = my_timeouts; t; t = next) {
1865  next = t->next;
1866  if (t->na == na) {
1867  if (debug)
1868  alog("debug: %s deleting timeout type %d from %s",
1869  s_NickServ, t->type, t->na->nick);
1870  /* If the timeout has the TO_RELEASE type, we should release the user */
1871  if (t->type == TO_RELEASE)
1872  release(na, 1);
1873  if (t->next)
1874  t->next->prev = t->prev;
1875  if (t->prev)
1876  t->prev->next = t->next;
1877  else
1878  my_timeouts = t->next;
1879  del_timeout(t->to);
1880  free(t);
1881  }
1882  }
1883 }
1884 
1885 /*************************************************************************/
1886 /*********************** NickServ command routines ***********************/
1887 /*************************************************************************/
1888 
1889 
1890 /* We don't use this function but we keep it for module coders -certus */
1891 int should_mode_change(int16 status, int16 mode)
1892 {
1893  switch (mode) {
1894  case CUS_OP:
1895  if (status & CUS_OP) {
1896  return 0;
1897  }
1898  break;
1899  case CUS_VOICE:
1900  if (status & CUS_OP) {
1901  return 0;
1902  }
1903  if (status & CUS_HALFOP) {
1904  return 0;
1905  }
1906  if (status & CUS_VOICE) {
1907  return 0;
1908  }
1909  return 1;
1910  break;
1911  case CUS_HALFOP:
1912  if (status & CUS_OP) {
1913  return 0;
1914  }
1915  if (status & CUS_HALFOP) {
1916  return 0;
1917  }
1918  return 1;
1919  break;
1920  case CUS_OWNER:
1921  if (ircd->owner) {
1922  if (status & CUS_OWNER) {
1923  return 0;
1924  }
1925  }
1926  break;
1927  case CUS_PROTECT:
1928  if (ircd->protect) {
1929  if (status & CUS_PROTECT) {
1930  return 0;
1931  }
1932  }
1933  break;
1934  }
1935  return 1;
1936 }
1937 
1938 /*************************************************************************/
1939 
1941 {
1942  struct u_chanlist *uc;
1943  Channel *c;
1944 
1945  /* Walk users current channels */
1946  for (uc = u->chans; uc; uc = uc->next) {
1947  if ((c = uc->chan))
1948  chan_set_correct_modes(u, c, 1);
1949  }
1950  return MOD_CONT;
1951 }
1952 
1953 /*************************************************************************/
1954 /*
1955  * Nick tracking
1956  */
1957 
1963 {
1964  NickCore *nc;
1965 
1966  /* We only track identified users */
1967  if (nick_identified(u)) {
1968  nc = u->na->nc;
1969 
1970  /* Release memory if needed */
1971  if (u->nickTrack)
1972  free(u->nickTrack);
1973 
1974  /* Copy the nick core displayed nick to
1975  the user structure for further checks */
1976  u->nickTrack = sstrdup(nc->display);
1977  }
1978 }
1979 
1985 {
1986  /* Simple enough. If its there, release it */
1987  if (u->nickTrack) {
1988  free(u->nickTrack);
1989  u->nickTrack = NULL;
1990  }
1991 }
1992 
1999 {
2000  NickCore *nc;
2001  NickAlias *na;
2002  char *nick;
2003 
2004  /* No nick alias or nick return false by default */
2005  if ((!(na = u->na)) || (!(nick = na->nick))) {
2006  return 0;
2007  }
2008 
2009  /* nick is forbidden best return 0 */
2010  if (na->status & NS_VERBOTEN) {
2011  return 0;
2012  }
2013 
2014  /* Get the core for the requested nick */
2015  nc = na->nc;
2016 
2017  /* If the core and the tracking displayed nick are there,
2018  * and they match, return true
2019  */
2020  if (nc && u->nickTrack && (strcmp(nc->display, u->nickTrack) == 0))
2021  return 1;
2022  else
2023  return 0;
2024 }
void save_ns_rdb_dbase(void)
Definition: nickserv.c:873
E int CSMaxReg
Definition: extern.h:403
NickCore * prev
Definition: services.h:540
void collide(NickAlias *na, int from_timeout)
Definition: nickserv.c:1671
char * email
Definition: services.h:519
int nick_recognized(User *u)
Definition: nickserv.c:1131
#define NI_SERVICES_ROOT
Definition: services.h:1305
E void cs_remove_nick(const NickCore *nc)
Definition: chanserv.c:1814
E void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes)
Definition: ircd.c:205
char sender[NICKMAX]
Definition: services.h:494
void expire_nicks()
Definition: nickserv.c:1162
#define NI_KILL_IMMED
Definition: services.h:1301
NickRequest * findrequestnick(const char *nick)
Definition: nickserv.c:1218
char ** access
Definition: services.h:551
NickRequest * prev
Definition: services.h:515
E int match_wild_nocase(const char *pattern, const char *str)
Definition: misc.c:268
struct my_timeout * next
Definition: nickserv.c:1725
#define NS_KILL_HELD
Definition: services.h:1278
char nick[NICKMAX]
Definition: services.h:875
static void timeout_collide(Timeout *t)
Definition: nickserv.c:1761
E int snprintf(char *buf, size_t size, const char *fmt,...)
Definition: compat.c:37
void save_ns_req_dbase(void)
Definition: nickserv.c:846
char * url
Definition: services.h:547
struct u_chanlist * next
Definition: services.h:899
E u_int16_t getrandom16(void)
Definition: misc.c:1061
#define NI_SUSPENDED
Definition: services.h:1308
void load_old_ns_dbase(void)
Definition: nickserv.c:281
int is_on_access(User *u, NickCore *nc)
Definition: nickserv.c:1289
E void anope_cmd_svshold(char *nick)
Definition: ircd.c:564
E IRCDVar * ircd
Definition: extern.h:39
E int NickServCoreNumber
Definition: extern.h:498
char * passcode
Definition: services.h:517
int rdb_clean_table_where(char *table, char *clause)
Definition: rdb.c:123
E SList servadmins
Definition: extern.h:971
Timeout * add_timeout(int delay, void(*code)(Timeout *), int repeat)
Definition: timeout.c:93
E char * PreNickDBName
Definition: extern.h:333
void load_ns_req_db(void)
Definition: nickserv.c:527
#define SAFE(x)
Definition: nickserv.c:753
char * last_quit
Definition: services.h:527
E void send_event(const char *name, int argc,...)
Definition: events.c:37
char * vhost
Definition: services.h:880
unsigned int guestnum
Definition: nickserv.c:26
int vhost
Definition: services.h:301
int should_mode_change(int16 status, int16 mode)
Definition: nickserv.c:1891
void save_ns_req_rdb_dbase(void)
Definition: nickserv.c:946
int rdb_save_ns_req(NickRequest *nr)
Definition: rdb.c:277
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
E int NSExpire
Definition: extern.h:381
char * chost
Definition: services.h:881
E char * NickDBName
Definition: extern.h:332
NickCore * nclists[1024]
Definition: nickserv.c:23
#define read_buffer(buf, f)
Definition: datafiles.h:61
E void modules_core_init(int number, char **list)
Definition: modules.c:127
E void moduleCleanStruct(ModuleData **moduleData)
Definition: modules.c:2439
#define NS_RECOGNIZED
Definition: services.h:1276
E char * NSEnforcerUser
Definition: extern.h:386
ModuleData * moduleData
Definition: services.h:557
int delnickrequest(NickRequest *nr)
Definition: nickserv.c:1554
#define NS_VERBOTEN
Definition: services.h:1273
NickAlias * next
Definition: services.h:525
uint16 language
Definition: services.h:549
#define getstring(na, index)
Definition: extern.h:731
NickAlias * findnick(const char *nick)
Definition: nickserv.c:1239
E int NSRExpire
Definition: extern.h:382
char password[PASSMAX]
Definition: services.h:518
E void anope_cmd_release_svshold(char *nick)
Definition: ircd.c:569
char * host
Definition: services.h:878
char * rdb_quote(char *str)
Definition: rdb.c:60
void alpha_insert_alias(NickAlias *na)
Definition: nickserv.c:1338
NickAlias * nalists[1024]
Definition: nickserv.c:22
#define CUS_VOICE
Definition: services.h:1342
#define write_int8(val, f)
Definition: datafiles.h:60
struct user_::u_chanlist * chans
uint16 accesscount
Definition: services.h:550
MemoInfo memos
Definition: services.h:552
int16 memocount
Definition: services.h:505
#define NI_KILLPROTECT
Definition: services.h:1290
#define EVENT_CORE_DROPPED
Definition: events.h:48
int validate_user(User *u)
Definition: nickserv.c:990
E char * NSEnforcerHost
Definition: extern.h:387
void moduleAddNickServCmds(void)
Definition: nickserv.c:37
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
static struct my_timeout * my_timeouts
#define NI_PRIVATE
Definition: services.h:1296
void nsStopNickTracking(User *u)
Definition: nickserv.c:1984
E int read_int16(uint16 *ret, dbFILE *f)
Definition: datafiles.c:405
E void kill_user(char *source, char *user, char *reason)
Definition: actions.c:51
E void os_remove_nick(NickCore *nc)
Definition: operserv.c:566
E char * sstrdup(const char *s)
Definition: memory.c:105
time_t requested
Definition: services.h:520
NickCore * nc
Definition: services.h:533
ModuleData * moduleData
Definition: services.h:535
int rdb_close()
Definition: rdb.c:47
E void * scalloc(long elsize, long els)
Definition: memory.c:55
int nick_identified(User *u)
Definition: nickserv.c:1111
NickRequest * next
Definition: services.h:515
char * display
Definition: services.h:542
uint16 flags
Definition: services.h:492
NickCore * findcore(const char *nick)
Definition: nickserv.c:1263
E void E void E void fatal(const char *fmt,...) FORMAT(printf
struct memo_ Memo
Definition: services.h:224
int rdb_save_ns_core(NickCore *nc)
Definition: rdb.c:253
void ** list
Definition: slist.h:21
time_t my_signon
Definition: services.h:887
E int enc_encrypt(const char *src, int len, char *dest, int size)
Definition: encrypt.c:50
#define getc_db(f)
Definition: datafiles.h:48
#define EVENT_NICK_EXPIRE
Definition: events.h:47
E int read_string(char **ret, dbFILE *f)
Definition: db-merger.c:1806
ModuleData * moduleData
Definition: services.h:496
int rdb_save_ns_alias(NickAlias *na)
Definition: rdb.c:265
int16 memomax
Definition: services.h:505
Timeout * to
Definition: nickserv.c:1727
char * text
Definition: services.h:495
int16 count
Definition: slist.h:23
int do_setmodes(User *u)
Definition: nickserv.c:1940
void nickserv(User *u, char *buf)
Definition: nickserv.c:244
int nsCheckNickTracking(User *u)
Definition: nickserv.c:1998
E int get_file_version(dbFILE *f)
Definition: datafiles.c:30
#define PASSMAX
Definition: config.h:65
#define NS_ON_ACCESS
Definition: services.h:1277
E int write_int16(uint16 val, dbFILE *f)
Definition: db-merger.c:1737
E User * finduser(const char *nick)
Definition: users.c:323
NickCore * next
Definition: services.h:540
E void anope_cmd_svskill(char *source, char *user, const char *fmt,...)
Definition: ircd.c:162
int rdb_ns_set_display(char *newnick, char *oldnick)
Definition: rdb.c:171
uint16 status
Definition: services.h:532
void expire_requests()
Definition: nickserv.c:1198
#define HASH(nick)
Definition: nickserv.c:20
E void close_db(dbFILE *f)
Definition: db-merger.c:1706
uint16 channelcount
Definition: services.h:553
void change_core_display(NickCore *nc, char *newdisplay)
Definition: nickserv.c:1416
int rdb_scrub_table(char *table, char *clause)
Definition: rdb.c:138
NickAlias * na
Definition: nickserv.c:1726
#define CUS_HALFOP
Definition: services.h:1343
void nsStartNickTracking(User *u)
Definition: nickserv.c:1962
#define CUS_PROTECT
Definition: services.h:1345
int svsnick
Definition: services.h:300
Command * c
Definition: ns_recover.c:17
int protect
Definition: services.h:333
#define PRE_NICK_VERSION
Definition: services.h:466
time_t settime
Definition: timeout.h:24
u_int32_t uint32
Definition: db-merger.c:123
#define NICK_VERSION
Definition: services.h:465
E dbFILE * open_db(const char *service, const char *filename, const char *mode, uint32 version)
Definition: datafiles.c:295
E void alog(const char *fmt,...) FORMAT(printf
int svshold
Definition: services.h:338
uint32 number
Definition: services.h:491
#define MOD_CONT
Definition: modules.h:54
void get_core_stats(long *nrec, long *memuse)
Definition: nickserv.c:183
#define NS_TEMPORARY
Definition: services.h:1285
int16_t int16
Definition: db-merger.c:120
#define TO_COLLIDE
Definition: nickserv.c:28
time_t time_registered
Definition: services.h:530
E char ** NickServCoreModules
Definition: extern.h:497
E void delHostCore(char *nick)
Definition: hostserv.c:345
E int debug
Definition: extern.h:775
static time_t lastwarn
Definition: datafiles.c:19
void del_ns_timeout(NickAlias *na, int type)
Definition: nickserv.c:1831
void cancel_user(User *u)
Definition: nickserv.c:1067
#define CUS_OWNER
Definition: services.h:1344
void insert_requestnick(NickRequest *nr)
Definition: nickserv.c:1391
char * nick
Definition: services.h:526
char * username
Definition: services.h:877
uint16 channelmax
Definition: services.h:554
E int skeleton
Definition: extern.h:778
#define NI_SERVICES_OPER
Definition: services.h:1302
char * last_realname
Definition: services.h:528
char * vident
Definition: services.h:882
E char * NSGuestNickPrefix
Definition: extern.h:393
#define NI_SECURE
Definition: services.h:1291
int rdb_clean_table(char *table)
Definition: rdb.c:113
static void rem_ns_timeout(NickAlias *na, int type)
Definition: nickserv.c:1735
E int NSAllowKillImmed
Definition: extern.h:389
void get_aliases_stats(long *nrec, long *memuse)
Definition: nickserv.c:155
void del_timeout(Timeout *t)
Definition: timeout.c:112
void ns_init(void)
Definition: nickserv.c:232
E char ** ServicesRoots
Definition: extern.h:434
#define NICKMAX
Definition: config.h:62
E int NSReleaseTimeout
Definition: extern.h:388
static int delcore(NickCore *nc)
Definition: nickserv.c:1467
char pass[PASSMAX]
Definition: services.h:543
void listnicks(int count_only, const char *nick)
Definition: nickserv.c:49
E int UseSVSHOLD
Definition: extern.h:357
int rdb_open()
Definition: rdb.c:31
#define NS_IDENTIFIED
Definition: services.h:1275
int delnick(NickAlias *na)
Definition: nickserv.c:1586
int rdb_tag_table_where(char *table, char *clause)
Definition: rdb.c:86
SList aliases
Definition: services.h:559
void * data
Definition: timeout.h:27
E void slist_init(SList *slist)
Definition: slist.c:302
int owner
Definition: services.h:302
void clean_ns_timeouts(NickAlias *na)
Definition: nickserv.c:1860
uint32 flags
Definition: services.h:548
NickRequest * nrlists[1024]
Definition: nickserv.c:24
int rdb_tag_table(char *table)
Definition: rdb.c:75
E void common_svsmode(User *u, char *modes, char *arg)
Definition: actions.c:228
#define EVENT_CORE_NEWDISPLAY
Definition: events.h:49
#define NI_SERVICES_ADMIN
Definition: services.h:1303
E void chan_set_correct_modes(User *user, Channel *c, int give_modes)
Definition: channels.c:1436
NickAlias * prev
Definition: services.h:525
time_t time
Definition: services.h:493
time_t last_seen
Definition: services.h:531
void save_ns_dbase(void)
Definition: nickserv.c:768
char * greet
Definition: services.h:545
#define NS_NO_EXPIRE
Definition: services.h:1274
E int slist_add(SList *slist, void *item)
Definition: slist.c:29
#define NS_OLD_ENCRYPTEDPW
Definition: services.h:1287
Memo * memos
Definition: services.h:506
E int read_int32(uint32 *ret, dbFILE *f)
Definition: datafiles.c:444
MDE void mod_run_cmd(char *service, User *u, CommandHash *cmdTable[], const char *cmd)
Definition: commands.c:67
void insert_core(NickCore *nc)
Definition: nickserv.c:1370
User * u
Definition: services.h:536
char * nick
Definition: services.h:516
E int write_string(const char *s, dbFILE *f)
Definition: db-merger.c:1826
E char * s_NickServ
Definition: extern.h:284
int group_identified(User *u, NickCore *nc)
Definition: nickserv.c:1151
#define TO_RELEASE
Definition: nickserv.c:29
struct my_timeout * prev
Definition: nickserv.c:1725
E SList servopers
Definition: extern.h:972
E void anope_cmd_ctcp(char *source, char *dest, const char *fmt,...)
Definition: ircd.c:672
#define NI_ENCRYPTEDPW
Definition: services.h:1304
#define write_buffer(buf, f)
Definition: datafiles.h:62
char * last_usermask
Definition: services.h:529
E int write_int32(uint32 val, dbFILE *f)
Definition: db-merger.c:1773
E void anope_cmd_quit(char *source, const char *fmt,...)
Definition: ircd.c:334
static void timeout_release(Timeout *t)
Definition: nickserv.c:1780
void load_ns_dbase(void)
Definition: nickserv.c:563
#define NS_GUESTED
Definition: services.h:1279
E int slist_remove(SList *slist, void *item)
Definition: slist.c:362
char * modeonunreg
Definition: services.h:311
void release(NickAlias *na, int from_timeout)
Definition: nickserv.c:1705
uint32 icq
Definition: services.h:546
E char * common_get_vhost(User *u)
Definition: actions.c:251
E int MailValidate(const char *email)
Definition: mail.c:296
char * nickTrack
Definition: services.h:885
#define NI_KILL_QUICK
Definition: services.h:1300
E int RootNumber
Definition: extern.h:435
static void add_ns_timeout(NickAlias *na, int type, time_t delay)
Definition: nickserv.c:1792
#define NICKSERV
Definition: modules.h:59
#define CUS_OP
Definition: services.h:1341
char * realname
Definition: services.h:883
E char * common_get_vident(User *u)
Definition: actions.c:272
NickAlias * na
Definition: services.h:892
char * email
Definition: services.h:544
#define NS_MASTER
Definition: services.h:1282
E void anope_cmd_svsnick(char *nick, char *newnick, time_t when)
Definition: ircd.c:544
u_int16_t uint16
Definition: db-merger.c:121