Initial import (again)
[srvx.git] / patches / ns_tried2reg102403.diff
1 diff -urN services-dist/src/hash.h services/src/hash.h
2 --- services-dist/src/hash.h    Fri Oct 24 20:05:25 2003
3 +++ services/src/hash.h Fri Oct 24 21:35:44 2003
4 @@ -56,6 +56,7 @@
5  #define FLAGS_STAMPED           0x1000 /* for users who have been stamped */
6  #define FLAGS_HIDDEN_HOST       0x2000 /* user's host is masked by their account */
7  #define FLAGS_REGNICK           0x4000 /* user owns their current nick */
8 +#define FLAGS_TRIED2REG                0x8000 /* user has used /msg NickServ@.. register already once this session */
9  
10  #define IsOper(x)               ((x)->modes & FLAGS_OPER)
11  #define IsService(x)            ((x)->modes & FLAGS_SERVICE)
12 @@ -71,6 +72,7 @@
13  #define IsStamped(x)            ((x)->modes & FLAGS_STAMPED)
14  #define IsHiddenHost(x)         ((x)->modes & FLAGS_HIDDEN_HOST)
15  #define IsReggedNick(x)         ((x)->modes & FLAGS_REGNICK)
16 +#define HasTried2Reg(x)                ((x)->modes & FLAGS_TRIED2REG)
17  #define IsLocal(x)              ((x)->uplink == self)
18  
19  #define NICKLEN         30
20 diff -urN services-dist/src/nickserv.c services/src/nickserv.c
21 --- services-dist/src/nickserv.c        Fri Oct 24 20:05:25 2003
22 +++ services/src/nickserv.c     Fri Oct 24 21:36:24 2003
23 @@ -141,6 +141,7 @@
24  #define NSMSG_BAD_MAX_LOGINS    "MaxLogins must be at most %d."
25  #define NSMSG_MAX_LOGINS        "Your account already has its limit of %d user(s) logged in."
26  #define NSMSG_SETTEE_LOGGED_IN  "%s is already logged in, so you cannot do that."
27 +#define NSMSG_TRIED2REG                "You have already attempted to use $bREGISTER$b once this session, you will have to reconnect to use it again."
28  
29  #define NSMSG_STAMPED_REGISTER  "You have already authenticated to an account once this session; you may not register a new account."
30  #define NSMSG_STAMPED_AUTH      "You have already authenticated to an account once this session; you may not authenticate to another."
31 @@ -1063,6 +1064,14 @@
32          return 0;
33      }
34  
35 +    if (HasTried2Reg(user)) {
36 +       /* On networks with email enabled, it is possible to use this cmd repeatedly, making
37 +        * potential damage to services very, very easy. This only allows a user to try once
38 +        * per session -akl */ 
39 +       nickserv_notice(user, NSMSG_TRIED2REG);
40 +       return 0;
41 +    }
42 +    
43      NICKSERV_MIN_PARMS((unsigned)3 + nickserv_conf.email_required);
44  
45      if (!is_valid_handle(argv[1])) {
46 @@ -1136,6 +1145,8 @@
47      /* If they need to do email verification, tell them. */
48      if (no_auth)
49          nickserv_make_cookie(user, hi, ACTIVATION, hi->passwd);
50 +
51 +    user->modes |= FLAGS_TRIED2REG;
52  
53      return 1;
54  }
55 diff -urN services-dist/src/opserv.c services/src/opserv.c
56 --- services-dist/src/opserv.c  Fri Oct 24 20:05:25 2003
57 +++ services/src/opserv.c       Fri Oct 24 21:33:03 2003
58 @@ -1195,6 +1195,7 @@
59         if (IsDeaf(target)) buffer[bpos++] = 'd';
60          if (IsHiddenHost(target)) buffer[bpos++] = 'x';
61          if (IsGagged(target)) buffer_cat(" (gagged)");
62 +       if (HasTried2Reg(target)) buffer_cat(" (registered an account)");
63         buffer[bpos] = 0;
64         if (bpos > 11) opserv_notice(user, buffer);
65      }