]>
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; |
97390b65 | 34 | maillock *mlp; |
1dd6d55d | 35 | |
36 | if (getreguserfromnick(sender)) | |
37 | return CMD_ERROR; | |
38 | ||
39 | if (cargc<2) { | |
40 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "hello"); | |
41 | return CMD_ERROR; | |
42 | } | |
43 | ||
44 | if (findreguserbynick(sender->nick)) { | |
45 | chanservstdmessage(sender, QM_AUTHNAMEINUSE, sender->nick); | |
46 | return CMD_ERROR; | |
47 | } | |
48 | ||
bd87ef68 CP |
49 | if (!(aup = getactiveuserfromnick(sender))) |
50 | return CMD_ERROR; | |
51 | ||
52 | if (aup->helloattempts > MAXHELLOS) { | |
53 | chanservstdmessage(sender, QM_MAXHELLOLIMIT); | |
54 | return CMD_ERROR; | |
55 | } | |
56 | ||
1dd6d55d | 57 | if (strcmp(cargv[0],cargv[1])) { |
58 | chanservstdmessage(sender, QM_EMAILDONTMATCH); | |
59 | cs_log(sender,"HELLO FAIL username %s email don't match (%s vs %s)",sender->nick,cargv[0],cargv[1]); | |
60 | return CMD_ERROR; | |
61 | } | |
62 | ||
63 | if (csa_checkeboy(sender, cargv[0])) | |
64 | return CMD_ERROR; | |
65 | ||
dc9548f4 CP |
66 | if (csa_checkaccountname(sender, sender->nick)) |
67 | return CMD_ERROR; | |
68 | ||
97390b65 CP |
69 | for(mlp=maillocks;mlp;mlp=mlp->next) { |
70 | if(!match(mlp->pattern->content, cargv[0])) { | |
71 | chanservstdmessage(sender, QM_MAILLOCKED); | |
72 | return CMD_ERROR; | |
73 | } | |
74 | } | |
75 | ||
bbc9e3a6 P |
76 | dupemail = strdup(cargv[0]); |
77 | local=strchr(dupemail, '@'); | |
a0ec3e1a CP |
78 | if(!local) { |
79 | free(dupemail); | |
96e1f81d | 80 | return CMD_ERROR; |
a0ec3e1a | 81 | } |
e3805f60 | 82 | *(local++)='\0'; |
96e1f81d CP |
83 | |
84 | mdp=findnearestmaildomain(local); | |
85 | if(mdp) { | |
86 | for(smdp=mdp; smdp; smdp=smdp->parent) { | |
87 | if(MDIsBanned(smdp)) { | |
88 | free(dupemail); | |
e81781a3 | 89 | chanservstdmessage(sender, QM_MAILLOCKED); |
96e1f81d | 90 | return CMD_ERROR; |
e3805f60 | 91 | } |
96e1f81d CP |
92 | if((smdp->count >= smdp->limit) && (smdp->limit > 0)) { |
93 | free(dupemail); | |
94 | chanservstdmessage(sender, QM_DOMAINLIMIT); | |
95 | return CMD_ERROR; | |
96 | } | |
97 | } | |
e3805f60 P |
98 | } |
99 | ||
96e1f81d CP |
100 | mdp=findmaildomainbydomain(local); |
101 | if(mdp) { | |
102 | for (ruh=mdp->users; ruh; ruh=ruh->nextbydomain) { | |
103 | if (ruh->localpart) | |
104 | if (!strcasecmp(dupemail, ruh->localpart->content)) { | |
105 | found++; | |
106 | } | |
107 | } | |
108 | ||
109 | if((found >= mdp->actlimit) && (mdp->actlimit > 0)) { | |
110 | free(dupemail); | |
111 | chanservstdmessage(sender, QM_ADDRESSLIMIT); | |
112 | return CMD_ERROR; | |
113 | } | |
e3805f60 P |
114 | } |
115 | ||
6ff65e48 | 116 | free(dupemail); |
96e1f81d CP |
117 | |
118 | aup->helloattempts++; | |
a0ec3e1a | 119 | |
6ff65e48 CP |
120 | rup=csa_createaccount(sender->nick,"", cargv[0]); |
121 | csa_createrandompw(rup->password, PASSLEN); | |
122 | sprintf(userhost,"%s@%s",sender->ident,sender->host->name->content); | |
123 | rup->lastuserhost=getsstring(userhost,USERLEN+HOSTLEN+1); | |
124 | ||
125 | chanservstdmessage(sender, QM_NEWACCOUNT, rup->username,rup->email->content); | |
126 | cs_log(sender,"HELLO OK created auth %s (%s)",rup->username,rup->email->content); | |
127 | csdb_createuser(rup); | |
128 | csdb_createmail(rup, QMAIL_NEWACCOUNT); | |
129 | ||
130 | return CMD_OK; | |
131 | } |