int csa_doresendemail(void *source, int cargc, char **cargv);
int csa_doactivateuser(void *source, int cargc, char **cargv);
int csa_doaddchan(void *source, int argc, char **argv);
+int csa_doremoteauth(void *source, int argc, char **argv);
+
static int decrypt_password(unsigned char *secret, int keybits, char *buf, int bufsize, char *encrypted);
static int hex_to_int(char *input, unsigned char *buf, int buflen);
registercontrolhelpcmd("resendemail", NO_RELAY, 1, csa_doresendemail, "Usage: resendemail <userid>");
registercontrolhelpcmd("activateuser", NO_RELAY, 1, csa_doactivateuser, "Usage: activateuser <userid>");
registercontrolhelpcmd("addchan", NO_RELAY, 3, csa_doaddchan, "Usage: addchan <channel> <userid> <channel type>");
+ registercontrolhelpcmd("remoteauth", NO_RELAY, 6, csa_doremoteauth, "Usage: remoteauth <username> <digest> <junk> <nick> <ident> <host>");
s=getcopyconfigitem("chanserv","createaccountsecret","",128);
if(!s || !s->content || !s->content[0]) {
return CMD_OK;
}
+static void controlremotereply(nick *target, char *message) {
+ controlreply(target, "REMOTEAUTH FAILTEXT %s", message);
+}
+
+static void remote_reply(nick *sender, int message_id, ...) {
+ va_list va;
+ va_start(va, message_id);
+ chanservstdvmessage(sender, NULL, message_id, -1 * (int)(strlen("REMOTEAUTH FAILTEXT ")), controlremotereply, va);
+ va_end(va);
+}
+
+int csa_doremoteauth(void *source, int cargc, char **cargv) {
+ nick *sender=(nick *)source;
+ reguser *rup;
+
+ if(cargc<6) {
+ controlreply(sender, "REMOTEAUTH FAILREASON args");
+ return CMD_ERROR;
+ }
+
+ char *account = cargv[0];
+ char *digest = cargv[1];
+ char *junk = cargv[2];
+ char *nick = cargv[3];
+ char *ident = cargv[4];
+ char *hostname = cargv[5];
+
+ if (!(rup=findreguserbynick(account))) {
+ controlreply(sender, "REMOTEAUTH FAILREASON user");
+ return CMD_ERROR;
+ }
+
+ if(!checkhashpass(rup, junk, digest)) {
+ controlreply(sender, "REMOTEAUTH FAILREASON digest");
+ return CMD_ERROR;
+ }
+
+ if (!csa_completeauth2(rup, nick, ident, hostname, "REMOTEAUTH", remote_reply, sender)) {
+ controlreply(sender, "REMOTEAUTH END");
+ return CMD_ERROR;
+ }
+
+ /* username:ts:authid */
+ controlreply(sender, "REMOTEAUTH OK %s %ld %ld", rup->username, rup->lastauth ? rup->lastauth : getnettime(), rup->ID);
+
+ /* note: NO HOOK_CHANSERV_AUTH */
+
+ return CMD_OK;
+}
+
static char *email_to_error(char *email) {
maildomain *mdp, *smdp;
char *local;
error_password = "passwordlong";
} else if(r == QM_PWTOWEAK) {
error_password = "passwordweak";
+ } else if(r == QM_PWINVALID) {
+ error_password = "passwordinvalid";
} else if(r != -1) {
error_password = "passwordunknown";
}
cs_log(sender,"SETEMAIL OK username %s email %s",rup->username, rup->email->content);
csdb_updateuser(rup);
- sendemail(rup);
controlreply(sender, "SETEMAIL TRUE");