]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/authcmds/login.c
efe24cd9bf5b9074f258eaafc38cdcd3cd2e5ed7
1 /* Automatically generated by refactor.pl.
5 * CMDLEVEL: QCMD_SECURE | QCMD_NOTAUTHED | QCMD_ALIAS
7 * CMDDESC: Authenticates you on the bot.
9 * CMDPROTO: int csa_doauth(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: LOGIN <username> <password>
11 * CMDHELP: Authenticates you on the bot, where:
12 * CMDHELP: username - your username
13 * CMDHELP: password - your password
14 * CMDHELP: If you do not have a username and password, see HELLO.
15 * CMDHELP: Note: due to the sensitive nature of this command, you must send the message
16 * CMDHELP: to Q@CServe.quakenet.org when using it.
17 * CMDHELP: Note: the preferred way to authenticate is to use the /AUTH command.
20 #include "../chanserv.h"
21 #include "../authlib.h"
22 #include "../../lib/irc_string.h"
26 int csa_auth(void *source
, int cargc
, char **cargv
, CRAlgorithm alg
) {
29 nick
*sender
=source
, *onp
;
30 char userhost
[USERLEN
+HOSTLEN
+2];
32 char *authtype
= "AUTH";
39 authtype
= "CHALLENGEAUTH";
41 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "auth");
45 if (!(aup
= getactiveuserfromnick(sender
)))
49 if (aup
->authattempts
> MAXAUTHATTEMPT
) {
50 if ((aup
->authattempts
% 100) == 0)
51 chanservwallmessage("Warning: User %s!%s@%s attempted to auth %d times. Last attempt: %s %s %s",
52 sender
->nick
, sender
->ident
, sender
->host
->name
->content
, aup
->authattempts
, authtype
, cargv
[0], cargv
[1]);
53 chanservstdmessage(sender
, QM_AUTHFAIL
);
54 cs_log(sender
,"%s FAIL too many auth attempts (last attempt: %s %s %s)", authtype
, authtype
, cargv
[0], cargv
[1]);
58 if (!(rup
=findreguserbynick(cargv
[0]))) {
59 chanservstdmessage(sender
, QM_AUTHFAIL
);
60 cs_log(sender
,"%s FAIL bad username %s",authtype
,cargv
[0]);
65 if (!checkpassword(rup
, cargv
[1])) {
66 chanservstdmessage(sender
, QM_AUTHFAIL
);
67 cs_log(sender
,"%s FAIL username %s bad password %s",authtype
,rup
->username
,cargv
[1]);
71 if (!checkresponse(rup
, aup
->entropy
, cargv
[1], alg
)) {
72 chanservstdmessage(sender
, QM_AUTHFAIL
);
73 cs_log(sender
,"%s FAIL username %s bad response",authtype
,rup
->username
);
78 /* This should never fail but do something other than crashing if it does. */
79 if (!(anp
=findauthname(rup
->ID
))) {
80 chanservstdmessage(sender
, QM_AUTHFAIL
);
84 /* Check for too many auths. Don't return immediately, since we will still warn
85 * other users on the acct in this case. */
86 if (!UHasHelperPriv(rup
) && !UIsNoAuthLimit(rup
)) {
87 if (anp
->usercount
>= MAXAUTHCOUNT
) {
88 chanservstdmessage(sender
, QM_TOOMANYAUTHS
);
93 for (onp
=anp
->nicks
;onp
;onp
=onp
->nextbyauthname
) {
95 chanservstdmessage(onp
, QM_OTHERUSERAUTHEDLIMIT
, sender
->nick
, sender
->ident
, sender
->host
->name
->content
, MAXAUTHCOUNT
);
97 chanservstdmessage(onp
, QM_OTHERUSERAUTHED
, sender
->nick
, sender
->ident
, sender
->host
->name
->content
);
106 if (UHasSuspension(rup
) && rup
->suspendexp
&& (now
>= rup
->suspendexp
)) {
107 /* suspension has expired, remove it */
108 rup
->flags
&=(~(QUFLAG_SUSPENDED
|QUFLAG_GLINE
|QUFLAG_DELAYEDGLINE
));
111 freesstring(rup
->suspendreason
);
112 rup
->suspendreason
=0;
113 csdb_updateuser(rup
);
116 if (UIsSuspended(rup
)) {
118 chanservstdmessage(sender
, QM_AUTHSUSPENDED
);
119 if(rup
->suspendreason
)
120 chanservstdmessage(sender
, QM_REASON
, rup
->suspendreason
->content
);
122 chanservstdmessage(sender
, QM_EXPIRES
, rup
->suspendexp
);
126 /* Guarantee a unique auth timestamp for each account */
127 if (rup
->lastauth
< now
)
132 sprintf(userhost
,"%s@%s",sender
->ident
,sender
->host
->name
->content
);
133 if (rup
->lastuserhost
)
134 freesstring(rup
->lastuserhost
);
135 rup
->lastuserhost
=getsstring(userhost
,USERLEN
+HOSTLEN
+1);
137 csdb_updateuser(rup
);
139 cs_log(sender
,"%s OK username %s", authtype
,rup
->username
);
141 localusersetaccount(sender
, rup
->username
, rup
->ID
, cs_accountflagmap(rup
), rup
->lastauth
);
143 chanservstdmessage(sender
, QM_AUTHOK
, rup
->username
);
148 int csa_doauth(void *source
, int cargc
, char **cargv
) {
149 return csa_auth(source
, cargc
, cargv
, NULL
);