#include "../core/hooks.h"
#include "../irc/irc.h"
-#define WARN_CHANNEL "#fishcowcow"
+#define CS_NODB
+#include "../chanserv/chanserv.h"
+
+#define WARN_CHANNEL "#twilightzone"
MODULE_VERSION("");
int ta_ticketauth(void *source, int cargc, char **cargv) {
nick *np = (nick *)source;
- char buffer[1024], *uhmac, *acc, *junk;
+ char buffer[1024], *uhmac, *acc, *junk, *flags;
unsigned char digest[32];
int expiry, acclen, id;
hmacsha256 hmac;
return CMD_ERROR;
}
- if(cargc != 3)
+ if(cargc != 6) {
+ controlreply(np, "%d\n", cargc);
return CMD_USAGE;
+ }
acc = cargv[0];
- expiry = atoi(cargv[1]) + 30;
+ expiry = atoi(cargv[1]);
id = atoi(cargv[2]);
acclen = strlen(acc);
- junk = cargv[3];
- uhmac = cargv[4];
+ flags = cargv[3];
+ junk = cargv[4];
+ uhmac = cargv[5];
if((acclen <= 1) || (acclen > ACCOUNTLEN)) {
controlreply(np, "Bad account.");
return CMD_ERROR;
}
- if(time(NULL) > expiry) {
+ if(time(NULL) > expiry + 30) {
controlwall(NO_OPER, NL_MISC, "%s!%s@%s attempted to TICKETAUTH as %s (expired)", np->nick, np->ident, np->host->name->content, acc);
controlreply(np, "Ticket time is bad or has expired.");
return CMD_ERROR;
}
hmacsha256_init(&hmac, (unsigned char *)sharedsecret->content, sharedsecret->length);
- snprintf(buffer, sizeof(buffer), "%s %d %d %s", acc, id, expiry, junk);
+ snprintf(buffer, sizeof(buffer), "%s %d %d %s %s", acc, expiry, id, flags, junk);
hmacsha256_update(&hmac, (unsigned char *)buffer, strlen(buffer));
hmacsha256_final(&hmac, digest);
controlreply(np, "Ticket valid, authing. . .");
- localusersetaccountwithuserid(np, acc, id);
+ localusersetaccount(np, acc, id, cs_accountflagmap_str(flags), 0);
controlreply(np, "Done.");
return CMD_OK;
return;
}
- registercontrolhelpcmd("ticketauth", NO_OPERED, 3, ta_ticketauth, "Usage: ticketauth <ticket>");
+ registercontrolhelpcmd("ticketauth", NO_OPERED, 6, ta_ticketauth, "Usage: ticketauth <ticket>");
}
void _fini() {