From 3d2e40794ce465a082ae024746b275713d544d46 Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 23 Apr 2020 01:03:48 +1000 Subject: Linky-hashish is now a Base64, it saves a tiny bit of space in emails. --- src/sledjchisl/sledjchisl.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 15f8d06..c4126b3 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -3289,13 +3289,14 @@ t("Write shs %s", tnm4); { // TODO - Later use libcurl. - char *uuid = Rd->shs.UUID, *first = getStrH(Rd->stuff, "firstName"), *last = getStrH(Rd->stuff, "lastName"); + char *uuid = Rd->shs.UUID, *first = getStrH(Rd->stuff, "firstName"), *last = getStrH(Rd->stuff, "lastName"); // TODO - should be from Rd.shs->linky-hashish - char *t0 = Rd->lnk->hashish, *content, *command; + char *t0 = xstrdup(Rd->lnk->hashish), *content, *command; if ('\0' != t0[0]) { - char *t1 = qurl_encode(t0, strlen(t0)); + size_t sz = qhex_decode(t0); + char *t1 = qB64_encode(t0, sz); content = xmprintf( "From: grid_no_reply@%s\n" @@ -3343,6 +3344,7 @@ t("Write shs %s", tnm4); free(file); free(content); free(t1); + free(t0); } } } @@ -3555,11 +3557,11 @@ T("new sesh %s %s %s", linky ? "linky" : "session", ret->UUID, ret->name); hashish = myHMACkey(ret->salt, toke_n_munchie, FALSE); free(toke_n_munchie); qstrcpy(ret->hashish, sizeof(ret->hashish), hashish); -d("hashish %s", ret->hashish); +//d("hashish %s", ret->hashish); t0 = myHMACkey(getStrH(Rd->configs, "pepper"), hashish, TRUE); free(hashish); qstrcpy(ret->leaf, sizeof(ret->leaf), t0); -d("leaf %s", ret->leaf); +//d("leaf %s", ret->leaf); free(t0); ret->isLinky = linky; setToken_n_munchie(Rd, linky); @@ -3651,16 +3653,23 @@ static int sessionValidate(reqData *Rd, inputForm *iF, inputValue *iV) char *toke_n_munchie = "", *munchie = "", *hashish = "", *leaf = "", *timeStamp = "", *seshion = "", *seshID = "", *t0, *t1; // In this case the session stuff has to come from specific places. - hashish = getStrH(Rd->queries, "hashish"); + hashish = Rd->queries->getstr(Rd->queries, "hashish", true); //d("O hashish %s", hashish); - if ('\0' != hashish[0]) + if (NULL != hashish) + { + char *t = xstrdup(hashish); + size_t sz = qB64_decode(t); + + free(hashish); + hashish = qhex_encode(t, sz); linky = TRUE; + } else { toke_n_munchie = getStrH(Rd->cookies, "toke_n_munchie"); // munchie = getStrH(Rd->body, "munchie"); - hashish = getStrH(Rd->cookies, "hashish"); - if (('\0' == toke_n_munchie[0]) || (('\0' == hashish[0]))) + hashish = Rd->cookies->getstr(Rd->cookies, "hashish", true); + if (('\0' == toke_n_munchie[0]) || ((NULL == hashish))) { if (strcmp("logout", Rd->doit) == 0) { @@ -3842,6 +3851,7 @@ t("SessionValidate() Lua read %s = %s", n, (char *) obj.data); } free(leaf); tnm->free(tnm); + free(hashish); } return ret; @@ -5675,6 +5685,7 @@ static void cleanup(void) if (configs) configs->free(configs); } + void sledjchisl_main(void) { char *cmd = *toys.optargs; -- cgit v1.1