]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: hello | |
5 | * CMDLEVEL: QCMD_NOTAUTHED | |
6 | * CMDARGS: 2 | |
7 | * CMDDESC: Creates a new user account. | |
8 | * CMDFUNC: csa_dohello | |
9 | * CMDPROTO: int csa_dohello(void *source, int cargc, char **cargv); | |
50cd26d6 | 10 | * CMDHELP: Usage: HELLO <email> <email> |
11 | * CMDHELP: Creates a new user account for yourself. Your current nickname will be used | |
12 | * CMDHELP: for the name of the account, and may only contain letters, numbers and | |
13 | * CMDHELP: hyphens (-). An email containing password details will be sent to the email | |
14 | * CMDHELP: address supplied. Where: | |
15 | * CMDHELP: email - your email address. Must be entered the same way both times. | |
1dd6d55d | 16 | */ |
17 | ||
18 | #include "../chanserv.h" | |
19 | #include "../authlib.h" | |
20 | #include "../../lib/irc_string.h" | |
21 | #include <stdio.h> | |
22 | #include <string.h> | |
23 | ||
24 | int csa_dohello(void *source, int cargc, char **cargv) { | |
25 | nick *sender=source; | |
26 | reguser *rup; | |
27 | char userhost[USERLEN+HOSTLEN+2]; | |
e3805f60 P |
28 | maildomain *mdp, *smdp; |
29 | char *local; | |
bbc9e3a6 P |
30 | reguser *ruh; |
31 | int found=0; | |
32 | char *dupemail; | |
bd87ef68 | 33 | activeuser *aup; |
1dd6d55d | 34 | |
35 | if (getreguserfromnick(sender)) | |
36 | return CMD_ERROR; | |
37 | ||
38 | if (cargc<2) { | |
39 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "hello"); | |
40 | return CMD_ERROR; | |
41 | } | |
42 | ||
43 | if (findreguserbynick(sender->nick)) { | |
44 | chanservstdmessage(sender, QM_AUTHNAMEINUSE, sender->nick); | |
45 | return CMD_ERROR; | |
46 | } | |
47 | ||
bd87ef68 CP |
48 | if (!(aup = getactiveuserfromnick(sender))) |
49 | return CMD_ERROR; | |
50 | ||
51 | if (aup->helloattempts > MAXHELLOS) { | |
52 | chanservstdmessage(sender, QM_MAXHELLOLIMIT); | |
53 | return CMD_ERROR; | |
54 | } | |
55 | ||
1dd6d55d | 56 | if (strcmp(cargv[0],cargv[1])) { |
57 | chanservstdmessage(sender, QM_EMAILDONTMATCH); | |
58 | cs_log(sender,"HELLO FAIL username %s email don't match (%s vs %s)",sender->nick,cargv[0],cargv[1]); | |
59 | return CMD_ERROR; | |
60 | } | |
61 | ||
62 | if (csa_checkeboy(sender, cargv[0])) | |
63 | return CMD_ERROR; | |
64 | ||
dc9548f4 CP |
65 | if (csa_checkaccountname(sender, sender->nick)) |
66 | return CMD_ERROR; | |
67 | ||
bbc9e3a6 P |
68 | dupemail = strdup(cargv[0]); |
69 | local=strchr(dupemail, '@'); | |
96e1f81d CP |
70 | if(!local) |
71 | return CMD_ERROR; | |
e3805f60 | 72 | *(local++)='\0'; |
96e1f81d CP |
73 | |
74 | mdp=findnearestmaildomain(local); | |
75 | if(mdp) { | |
76 | for(smdp=mdp; smdp; smdp=smdp->parent) { | |
77 | if(MDIsBanned(smdp)) { | |
78 | free(dupemail); | |
79 | chanservstdmessage(sender, QM_DOMAINBANNED); | |
80 | return CMD_ERROR; | |
e3805f60 | 81 | } |
96e1f81d CP |
82 | if((smdp->count >= smdp->limit) && (smdp->limit > 0)) { |
83 | free(dupemail); | |
84 | chanservstdmessage(sender, QM_DOMAINLIMIT); | |
85 | return CMD_ERROR; | |
86 | } | |
87 | } | |
e3805f60 P |
88 | } |
89 | ||
96e1f81d CP |
90 | mdp=findmaildomainbydomain(local); |
91 | if(mdp) { | |
92 | for (ruh=mdp->users; ruh; ruh=ruh->nextbydomain) { | |
93 | if (ruh->localpart) | |
94 | if (!strcasecmp(dupemail, ruh->localpart->content)) { | |
95 | found++; | |
96 | } | |
97 | } | |
98 | ||
99 | if((found >= mdp->actlimit) && (mdp->actlimit > 0)) { | |
100 | free(dupemail); | |
101 | chanservstdmessage(sender, QM_ADDRESSLIMIT); | |
102 | return CMD_ERROR; | |
103 | } | |
e3805f60 P |
104 | } |
105 | ||
96e1f81d CP |
106 | mdp=findorcreatemaildomain(cargv[0]); |
107 | ||
108 | aup->helloattempts++; | |
109 | ||
1dd6d55d | 110 | rup=getreguser(); |
111 | rup->status=0; | |
112 | rup->ID=++lastuserID; | |
113 | strncpy(rup->username,sender->nick,NICKLEN); rup->username[NICKLEN]='\0'; | |
114 | rup->created=time(NULL); | |
cf50e022 | 115 | rup->lastauth=0; |
1dd6d55d | 116 | rup->lastemailchange=time(NULL); |
117 | rup->flags=QUFLAG_NOTICE; | |
118 | rup->languageid=0; | |
119 | rup->suspendby=0; | |
120 | rup->suspendexp=0; | |
121 | rup->password[0]='\0'; | |
1dd6d55d | 122 | rup->email=getsstring(cargv[0],EMAILLEN); |
96e1f81d CP |
123 | |
124 | rup->localpart=getsstring(dupemail,EMAILLEN); | |
125 | free(dupemail); | |
126 | ||
e3805f60 P |
127 | rup->domain=mdp; |
128 | addregusertomaildomain(rup, rup->domain); | |
1dd6d55d | 129 | rup->info=NULL; |
130 | sprintf(userhost,"%s@%s",sender->ident,sender->host->name->content); | |
131 | rup->lastuserhost=getsstring(userhost,USERLEN+HOSTLEN+1); | |
132 | rup->suspendreason=NULL; | |
133 | rup->comment=NULL; | |
134 | rup->knownon=NULL; | |
135 | rup->checkshd=NULL; | |
136 | rup->stealcount=0; | |
137 | rup->fakeuser=NULL; | |
1dd6d55d | 138 | addregusertohash(rup); |
139 | csa_createrandompw(rup->password, PASSLEN); | |
1dd6d55d | 140 | chanservstdmessage(sender, QM_NEWACCOUNT, rup->username,rup->email->content); |
141 | cs_log(sender,"HELLO OK created auth %s (%s)",rup->username,rup->email->content); | |
142 | csdb_createuser(rup); | |
143 | csdb_createmail(rup, QMAIL_NEWACCOUNT); | |
144 | ||
145 | return CMD_OK; | |
146 | } |