X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/82c01b317cd1892f4376c68be88a74f971493428..ad9bae0b85165ad96e35c202c96e4adb67786a90:/server/dcgi.c diff --git a/server/dcgi.c b/server/dcgi.c index 29bac5d..b7a8508 100644 --- a/server/dcgi.c +++ b/server/dcgi.c @@ -57,6 +57,7 @@ #include "url.h" #include "mime.h" #include "sendmail.h" +#include "base64.h" char *login_cookie; @@ -73,15 +74,23 @@ struct entry { const char *display; }; +static const char nonce_base64_table[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/*"; + static const char *nonce(void) { - static unsigned long count; - char *s; + static uint32_t count; + + struct ndata { + uint16_t count; + uint16_t pid; + uint32_t when; + } nd; - byte_xasprintf(&s, "%lx%lx%lx", - (unsigned long)time(0), - (unsigned long)getpid(), - count++); - return s; + nd.count = count++; + nd.pid = (uint32_t)getpid(); + nd.when = (uint32_t)time(0); + return generic_to_base64((void *)&nd, sizeof nd, + nonce_base64_table); } static int compare_entry(const void *a, const void *b) { @@ -645,6 +654,23 @@ static void act_edituser(cgi_sink *output, expand_template(ds, output, "login"); } +static void act_reminder(cgi_sink *output, + dcgi_state *ds) { + const char *const username = cgi_get("username"); + + if(!username || !*username) { + cgi_set_option("error", "nousername"); + expand_template(ds, output, "login"); + return; + } + if(disorder_reminder(ds->g->client, username)) { + cgi_set_option("error", "reminderfailed"); + expand_template(ds, output, "login"); + return; + } + cgi_set_option("status", "reminded"); + expand_template(ds, output, "login"); +} static const struct action { const char *name; @@ -664,6 +690,7 @@ static const struct action { { "random-disable", act_random_disable }, { "random-enable", act_random_enable }, { "register", act_register }, + { "reminder", act_reminder }, { "remove", act_remove }, { "resume", act_resume }, { "scratch", act_scratch },