aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/sledjchisl/sledjchisl.c156
1 files changed, 80 insertions, 76 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c
index 8b9d567..393376e 100644
--- a/src/sledjchisl/sledjchisl.c
+++ b/src/sledjchisl/sledjchisl.c
@@ -476,6 +476,8 @@ char *logTypes[] =
476 "36", "TIMEOUT", // cyan 476 "36", "TIMEOUT", // cyan
477 "97;40", "INFO", // white 477 "97;40", "INFO", // white
478 "90", "DEBUG", // grey 478 "90", "DEBUG", // grey
479 "35", "debug", // magenta
480 "34", "timeout", // blue
479}; 481};
480 482
481#define DATE_TIME_LEN 42 483#define DATE_TIME_LEN 42
@@ -513,6 +515,8 @@ void logMe(int v, char *format, ...)
513#define T(...) logMe(3, __VA_ARGS__) 515#define T(...) logMe(3, __VA_ARGS__)
514#define I(...) logMe(4, __VA_ARGS__) 516#define I(...) logMe(4, __VA_ARGS__)
515#define D(...) logMe(5, __VA_ARGS__) 517#define D(...) logMe(5, __VA_ARGS__)
518#define d(...) logMe(6, __VA_ARGS__)
519#define t(...) logMe(7, __VA_ARGS__)
516 520
517 521
518static void addStrL(qlist_t *list, char *s) 522static void addStrL(qlist_t *list, char *s)
@@ -643,7 +647,7 @@ float waitLoadAverage(float la, float extra, int timeout)
643 l = info.loads[0]/65536.0; 647 l = info.loads[0]/65536.0;
644 clock_gettime(CLOCK_MONOTONIC, &timeOut); 648 clock_gettime(CLOCK_MONOTONIC, &timeOut);
645 timeout -= 5; 649 timeout -= 5;
646 T("Tick, load average is %.02f, countdown %d seconds.", l, timeout); 650 t("Tick, load average is %.02f, countdown %d seconds.", l, timeout);
647 } while (((la + extra) < l) && (timeOut.tv_sec < to)); 651 } while (((la + extra) < l) && (timeOut.tv_sec < to));
648 652
649 return l; 653 return l;
@@ -788,7 +792,7 @@ int checkSimIsRunning(char *sim)
788 { 792 {
789 free(path); 793 free(path);
790 path = xmprintf("rm -f %s/caches/%s.pid", scRoot, sim); 794 path = xmprintf("rm -f %s/caches/%s.pid", scRoot, sim);
791 D("%s", path); 795 d("%s", path);
792 i = system(path); 796 i = system(path);
793 } 797 }
794 } 798 }
@@ -818,7 +822,7 @@ static void PrintEnv(qgrow_t *reply, char *label, char **envp)
818static void printEnv(char **envp) 822static void printEnv(char **envp)
819{ 823{
820 for ( ; *envp != NULL; envp++) 824 for ( ; *envp != NULL; envp++)
821 D("%s", *envp); 825 d("%s", *envp);
822} 826}
823 827
824 828
@@ -836,7 +840,7 @@ static void dumpHash(qhashtbl_t *tbl)
836 memset((void*)&obj, 0, sizeof(obj)); 840 memset((void*)&obj, 0, sizeof(obj));
837 tbl->lock(tbl); 841 tbl->lock(tbl);
838 while(tbl->getnext(tbl, &obj, true) == true) 842 while(tbl->getnext(tbl, &obj, true) == true)
839 D("%s = %s", obj.name, (char *) obj.data); 843 d("%s = %s", obj.name, (char *) obj.data);
840 tbl->unlock(tbl); 844 tbl->unlock(tbl);
841} 845}
842 846
@@ -846,7 +850,7 @@ static void dumpArray(int d, char **ar)
846 850
847 while (ar[i] != NULL) 851 while (ar[i] != NULL)
848 { 852 {
849 D("%d %d %s", d, i, ar[i]); 853 d("%d %d %s", d, i, ar[i]);
850 i++; 854 i++;
851 } 855 }
852} 856}
@@ -902,7 +906,7 @@ qlisttbl_t *dbGetFields(MYSQL *db, char *table)
902 // Chicken, meet egg, sorry you had to cross the road for this. 906 // Chicken, meet egg, sorry you had to cross the road for this.
903 char *sql = xmprintf("SELECT * FROM %s LIMIT 0", table); 907 char *sql = xmprintf("SELECT * FROM %s LIMIT 0", table);
904 908
905D("Getting field metadata for %s", table); 909d("Getting field metadata for %s", table);
906 if (mysql_query(db, sql)) 910 if (mysql_query(db, sql))
907 E("Query failed: %s\n%s", mysql_error(db), sql); 911 E("Query failed: %s\n%s", mysql_error(db), sql);
908 else 912 else
@@ -1026,7 +1030,7 @@ void dbDoSomething(dbRequest *req, boolean count, ...)
1026 req->sql = t; 1030 req->sql = t;
1027 } 1031 }
1028 1032
1029D("New SQL statement - %s", req->sql); 1033d("New SQL statement - %s", req->sql);
1030 // prepare statement with the other fields 1034 // prepare statement with the other fields
1031 req->prep = mysql_stmt_init(req->db); 1035 req->prep = mysql_stmt_init(req->db);
1032 if (NULL == req->prep) 1036 if (NULL == req->prep)
@@ -1214,53 +1218,53 @@ I("count!!!!!!!!!!!!!!!!");
1214 { 1218 {
1215 case MYSQL_TYPE_TINY: 1219 case MYSQL_TYPE_TINY:
1216 { 1220 {
1217//D("TINY %d %s %d", i, fld->name, req->outBind[i].buffer_length); 1221//d("TINY %d %s %d", i, fld->name, req->outBind[i].buffer_length);
1218 break; 1222 break;
1219 } 1223 }
1220 1224
1221 case MYSQL_TYPE_SHORT: 1225 case MYSQL_TYPE_SHORT:
1222 { 1226 {
1223//D("SHORT %s %d", fld->name, req->outBind[i].buffer_length); 1227//d("SHORT %s %d", fld->name, req->outBind[i].buffer_length);
1224 req->outBind[i].is_unsigned = FALSE; 1228 req->outBind[i].is_unsigned = FALSE;
1225 break; 1229 break;
1226 } 1230 }
1227 1231
1228 case MYSQL_TYPE_INT24: 1232 case MYSQL_TYPE_INT24:
1229 { 1233 {
1230//D("INT24 %s %d", fld->name, req->outBind[i].buffer_length); 1234//d("INT24 %s %d", fld->name, req->outBind[i].buffer_length);
1231 req->outBind[i].is_unsigned = FALSE; 1235 req->outBind[i].is_unsigned = FALSE;
1232 break; 1236 break;
1233 } 1237 }
1234 1238
1235 case MYSQL_TYPE_LONG: 1239 case MYSQL_TYPE_LONG:
1236 { 1240 {
1237//D("LONG %d %s %d", i, fld->name, req->outBind[i].buffer_length); 1241//d("LONG %d %s %d", i, fld->name, req->outBind[i].buffer_length);
1238 req->outBind[i].is_unsigned = FALSE; 1242 req->outBind[i].is_unsigned = FALSE;
1239 break; 1243 break;
1240 } 1244 }
1241 1245
1242 case MYSQL_TYPE_LONGLONG: 1246 case MYSQL_TYPE_LONGLONG:
1243 { 1247 {
1244//D("LONG LONG %s %d", fld->name, req->outBind[i].buffer_length); 1248//d("LONG LONG %s %d", fld->name, req->outBind[i].buffer_length);
1245 req->outBind[i].is_unsigned = FALSE; 1249 req->outBind[i].is_unsigned = FALSE;
1246 break; 1250 break;
1247 } 1251 }
1248 1252
1249 case MYSQL_TYPE_FLOAT: 1253 case MYSQL_TYPE_FLOAT:
1250 { 1254 {
1251//D("FLOAT %s %d", fld->name, req->outBind[i].buffer_length); 1255//d("FLOAT %s %d", fld->name, req->outBind[i].buffer_length);
1252 break; 1256 break;
1253 } 1257 }
1254 1258
1255 case MYSQL_TYPE_DOUBLE: 1259 case MYSQL_TYPE_DOUBLE:
1256 { 1260 {
1257//D("DOUBLE %s %d", fld->name, req->outBind[i].buffer_length); 1261//d("DOUBLE %s %d", fld->name, req->outBind[i].buffer_length);
1258 break; 1262 break;
1259 } 1263 }
1260 1264
1261 case MYSQL_TYPE_NEWDECIMAL: 1265 case MYSQL_TYPE_NEWDECIMAL:
1262 { 1266 {
1263//D("NEWDECIMAL %s %d", fld->name, req->outBind[i].buffer_length); 1267//d("NEWDECIMAL %s %d", fld->name, req->outBind[i].buffer_length);
1264 break; 1268 break;
1265 } 1269 }
1266 1270
@@ -1269,14 +1273,14 @@ I("count!!!!!!!!!!!!!!!!");
1269 case MYSQL_TYPE_DATETIME: 1273 case MYSQL_TYPE_DATETIME:
1270 case MYSQL_TYPE_TIMESTAMP: 1274 case MYSQL_TYPE_TIMESTAMP:
1271 { 1275 {
1272//D("DATETIME %s %d", fld->name, req->outBind[i].buffer_length); 1276//d("DATETIME %s %d", fld->name, req->outBind[i].buffer_length);
1273 break; 1277 break;
1274 } 1278 }
1275 1279
1276 case MYSQL_TYPE_STRING: 1280 case MYSQL_TYPE_STRING:
1277 case MYSQL_TYPE_VAR_STRING: 1281 case MYSQL_TYPE_VAR_STRING:
1278 { 1282 {
1279//D("STRING %s %d", fld->name, req->outBind[i].buffer_length); 1283//d("STRING %s %d", fld->name, req->outBind[i].buffer_length);
1280 req->outBind[i].length = xzalloc(sizeof(unsigned long)); 1284 req->outBind[i].length = xzalloc(sizeof(unsigned long));
1281 break; 1285 break;
1282 } 1286 }
@@ -1286,19 +1290,19 @@ I("count!!!!!!!!!!!!!!!!");
1286 case MYSQL_TYPE_MEDIUM_BLOB: 1290 case MYSQL_TYPE_MEDIUM_BLOB:
1287 case MYSQL_TYPE_LONG_BLOB: 1291 case MYSQL_TYPE_LONG_BLOB:
1288 { 1292 {
1289//D("BLOB %s %d", fld->name, req->outBind[i].buffer_length); 1293//d("BLOB %s %d", fld->name, req->outBind[i].buffer_length);
1290 break; 1294 break;
1291 } 1295 }
1292 1296
1293 case MYSQL_TYPE_BIT: 1297 case MYSQL_TYPE_BIT:
1294 { 1298 {
1295//D("BIT %s %d", fld->name, req->outBind[i].buffer_length); 1299//d("BIT %s %d", fld->name, req->outBind[i].buffer_length);
1296 break; 1300 break;
1297 } 1301 }
1298 1302
1299 case MYSQL_TYPE_NULL: 1303 case MYSQL_TYPE_NULL:
1300 { 1304 {
1301//D("NULL %s %d", fld->name, req->outBind[i].buffer_length); 1305//d("NULL %s %d", fld->name, req->outBind[i].buffer_length);
1302 break; 1306 break;
1303 } 1307 }
1304 } 1308 }
@@ -1313,7 +1317,7 @@ I("count!!!!!!!!!!!!!!!!");
1313 } 1317 }
1314 1318
1315 1319
1316//D("input bind for %s", req->sql); 1320//d("input bind for %s", req->sql);
1317 for (i = 0; i < req->inCount; i++) 1321 for (i = 0; i < req->inCount; i++)
1318 { 1322 {
1319 dbField *fld = req->flds->get(req->flds, req->inParams[i], NULL, false); 1323 dbField *fld = req->flds->get(req->flds, req->inParams[i], NULL, false);
@@ -1443,7 +1447,7 @@ I("count!!!!!!!!!!!!!!!!");
1443 } 1447 }
1444 1448
1445 1449
1446D("Execute %s", req->sql); 1450d("Execute %s", req->sql);
1447 1451
1448 // do the prepared statement req->prep. 1452 // do the prepared statement req->prep.
1449 if (mysql_stmt_execute(req->prep)) 1453 if (mysql_stmt_execute(req->prep))
@@ -1481,7 +1485,7 @@ D("Execute %s", req->sql);
1481 req->rows->fieldNames[i] = fld->name; 1485 req->rows->fieldNames[i] = fld->name;
1482 if (!*(req->outBind[i].is_null)) 1486 if (!*(req->outBind[i].is_null))
1483 { 1487 {
1484//D("2.8 %s", req->rows->fieldNames[i]); 1488//d("2.8 %s", req->rows->fieldNames[i]);
1485 flds->put(flds, req->rows->fieldNames[i], req->outBind[i].buffer, req->outBind[i].buffer_length); 1489 flds->put(flds, req->rows->fieldNames[i], req->outBind[i].buffer, req->outBind[i].buffer_length);
1486 1490
1487 switch(fld->type) 1491 switch(fld->type)
@@ -1513,7 +1517,7 @@ D("Execute %s", req->sql);
1513 goto freeIt; 1517 goto freeIt;
1514 } 1518 }
1515 char *t = xmprintf("%d", (int) *((int *) (req->outBind[i].buffer))); 1519 char *t = xmprintf("%d", (int) *((int *) (req->outBind[i].buffer)));
1516//D("Setting %i %s %s", i, fld->name, t); 1520//d("Setting %i %s %s", i, fld->name, t);
1517 flds->putstr(flds, req->rows->fieldNames[i], t); 1521 flds->putstr(flds, req->rows->fieldNames[i], t);
1518 break; 1522 break;
1519 } 1523 }
@@ -1952,14 +1956,14 @@ qhashtbl_t *toknize(char *text, char *delims)
1952 else if (delims[1] == dlm) 1956 else if (delims[1] == dlm)
1953 { 1957 {
1954 ret->putstr(ret, qstrtrim_head(key), token); 1958 ret->putstr(ret, qstrtrim_head(key), token);
1955D(" %s = %s", qstrtrim_head(key), val); 1959d(" %s = %s", qstrtrim_head(key), val);
1956 val = NULL; 1960 val = NULL;
1957 } 1961 }
1958 } 1962 }
1959 if (NULL != val) 1963 if (NULL != val)
1960{ 1964{
1961 ret->putstr(ret, qstrtrim_head(key), val); 1965 ret->putstr(ret, qstrtrim_head(key), val);
1962D(" %s = %s", qstrtrim_head(key), val); 1966d(" %s = %s", qstrtrim_head(key), val);
1963} 1967}
1964 free(txt); 1968 free(txt);
1965 return ret; 1969 return ret;
@@ -2951,14 +2955,14 @@ W("New sesh");
2951 else 2955 else
2952 { 2956 {
2953 qstrcpy(ret->salt, sizeof(ret->salt), qhex_encode(buf, sizeof(buf))); 2957 qstrcpy(ret->salt, sizeof(ret->salt), qhex_encode(buf, sizeof(buf)));
2954//D("salt %s", ret->salt); 2958//d("salt %s", ret->salt);
2955 numBytes = getrandom((void *)buf, sizeof(buf), GRND_NONBLOCK); 2959 numBytes = getrandom((void *)buf, sizeof(buf), GRND_NONBLOCK);
2956 if (-1 == numBytes) 2960 if (-1 == numBytes)
2957 perror_msg("Unable to generate a suitable random number."); 2961 perror_msg("Unable to generate a suitable random number.");
2958 else 2962 else
2959 { 2963 {
2960 qstrcpy(ret->seshID, sizeof(ret->seshID), qhex_encode(buf, sizeof(buf))); 2964 qstrcpy(ret->seshID, sizeof(ret->seshID), qhex_encode(buf, sizeof(buf)));
2961//D("seshID %s", ret->seshID); 2965//d("seshID %s", ret->seshID);
2962 2966
2963 ret->timeStamp[0].tv_nsec = UTIME_OMIT; 2967 ret->timeStamp[0].tv_nsec = UTIME_OMIT;
2964 ret->timeStamp[0].tv_sec = UTIME_OMIT; 2968 ret->timeStamp[0].tv_sec = UTIME_OMIT;
@@ -2969,24 +2973,24 @@ W("New sesh");
2969 // tv_sec is a time_t, tv_nsec is a long, but the actual type of time_t isn't well defined, it's some sort of integer. 2973 // tv_sec is a time_t, tv_nsec is a long, but the actual type of time_t isn't well defined, it's some sort of integer.
2970 t0 = xmprintf("%s%ld.%ld", ret->seshID, (long) ret->timeStamp[1].tv_sec, ret->timeStamp[1].tv_nsec); 2974 t0 = xmprintf("%s%ld.%ld", ret->seshID, (long) ret->timeStamp[1].tv_sec, ret->timeStamp[1].tv_nsec);
2971 qstrcpy(ret->sesh, sizeof(ret->sesh), t0); 2975 qstrcpy(ret->sesh, sizeof(ret->sesh), t0);
2972//D("sesh %s", ret->sesh); 2976//d("sesh %s", ret->sesh);
2973 t1 = myHMAC(t0, FALSE); 2977 t1 = myHMAC(t0, FALSE);
2974 free(t0); 2978 free(t0);
2975 munchie = xmprintf("%s%ld.%ld", t1, (long) ret->timeStamp[1].tv_sec, ret->timeStamp[1].tv_nsec); 2979 munchie = xmprintf("%s%ld.%ld", t1, (long) ret->timeStamp[1].tv_sec, ret->timeStamp[1].tv_nsec);
2976 free(t1); 2980 free(t1);
2977 qstrcpy(ret->munchie, sizeof(ret->munchie), munchie); 2981 qstrcpy(ret->munchie, sizeof(ret->munchie), munchie);
2978//D("munchie %s", ret->munchie); 2982//d("munchie %s", ret->munchie);
2979 t0 = xmprintf("%s%s", getStrH(Rd->stuff, "UUID"), munchie); 2983 t0 = xmprintf("%s%s", getStrH(Rd->stuff, "UUID"), munchie);
2980 toke_n_munchie = myHMAC(t0, FALSE); 2984 toke_n_munchie = myHMAC(t0, FALSE);
2981 free(t0); 2985 free(t0);
2982 qstrcpy(ret->toke_n_munchie, sizeof(ret->toke_n_munchie), toke_n_munchie); 2986 qstrcpy(ret->toke_n_munchie, sizeof(ret->toke_n_munchie), toke_n_munchie);
2983//D("toke_n_munchie %s", ret->toke_n_munchie); 2987//d("toke_n_munchie %s", ret->toke_n_munchie);
2984 hashish = myHMACkey(ret->salt, toke_n_munchie, FALSE); 2988 hashish = myHMACkey(ret->salt, toke_n_munchie, FALSE);
2985 qstrcpy(ret->hashish, sizeof(ret->hashish), hashish); 2989 qstrcpy(ret->hashish, sizeof(ret->hashish), hashish);
2986//D("hashish %s", ret->hashish); 2990//d("hashish %s", ret->hashish);
2987 t0 = myHMACkey(getStrH(Rd->configs, "pepper"), hashish, TRUE); 2991 t0 = myHMACkey(getStrH(Rd->configs, "pepper"), hashish, TRUE);
2988 qstrcpy(ret->leaf, sizeof(ret->leaf), t0); 2992 qstrcpy(ret->leaf, sizeof(ret->leaf), t0);
2989//D("leaf %s", ret->leaf); 2993//d("leaf %s", ret->leaf);
2990 free(t0); 2994 free(t0);
2991 ret->isLinky = linky; 2995 ret->isLinky = linky;
2992 setToken_n_munchie(Rd, linky); 2996 setToken_n_munchie(Rd, linky);
@@ -3105,7 +3109,7 @@ int LuaToHash(reqData *Rd, char *file, char *var, qhashtbl_t *tnm, int ret, stru
3105 if (lua_isstring(Rd->L, -1)) 3109 if (lua_isstring(Rd->L, -1))
3106 { 3110 {
3107 tnm->putstr(tnm, n, (char *) lua_tostring(Rd->L, -1)); 3111 tnm->putstr(tnm, n, (char *) lua_tostring(Rd->L, -1));
3108//D("Reading %s %s", n, getStrH(tnm, n)); 3112//d("Reading %s %s", n, getStrH(tnm, n));
3109 } 3113 }
3110 else 3114 else
3111 { 3115 {
@@ -3146,7 +3150,7 @@ static int validateSesh(reqData *Rd, qhashtbl_t *data)
3146 3150
3147 // In this case the session stuff has to come from specific places. 3151 // In this case the session stuff has to come from specific places.
3148 hashish = getStrH(Rd->queries, "hashish"); 3152 hashish = getStrH(Rd->queries, "hashish");
3149//D("O hashish %s", hashish); 3153//d("O hashish %s", hashish);
3150 if ('\0' != hashish[0]) 3154 if ('\0' != hashish[0])
3151 linky = TRUE; 3155 linky = TRUE;
3152 else 3156 else
@@ -3161,16 +3165,16 @@ static int validateSesh(reqData *Rd, qhashtbl_t *data)
3161 } 3165 }
3162 } 3166 }
3163 3167
3164//D("O hashish %s", hashish); 3168//d("O hashish %s", hashish);
3165//D("O toke_n_munchie %s", toke_n_munchie); 3169//d("O toke_n_munchie %s", toke_n_munchie);
3166//D("O munchie %s", munchie); 3170//d("O munchie %s", munchie);
3167 if (0 == ret) 3171 if (0 == ret)
3168 { 3172 {
3169 struct stat st; 3173 struct stat st;
3170 struct timespec now; 3174 struct timespec now;
3171 3175
3172 leaf = myHMACkey(getStrH(Rd->configs, "pepper"), hashish, TRUE); 3176 leaf = myHMACkey(getStrH(Rd->configs, "pepper"), hashish, TRUE);
3173//D("leaf %s", leaf); 3177//d("leaf %s", leaf);
3174 if (linky) 3178 if (linky)
3175 t0 = xmprintf("%s/sessions/%s.linky", scCache, leaf); 3179 t0 = xmprintf("%s/sessions/%s.linky", scCache, leaf);
3176 else 3180 else
@@ -3197,12 +3201,12 @@ static int validateSesh(reqData *Rd, qhashtbl_t *data)
3197 else 3201 else
3198 { 3202 {
3199 timeStamp = xmprintf("%ld.%ld", (long) st.st_mtim.tv_sec, st.st_mtim.tv_nsec); 3203 timeStamp = xmprintf("%ld.%ld", (long) st.st_mtim.tv_sec, st.st_mtim.tv_nsec);
3200//D("timeStamp %s", timeStamp); 3204//d("timeStamp %s", timeStamp);
3201 seshion = xmprintf("%s%s", tnm->getstr(tnm, "seshID", false), timeStamp); 3205 seshion = xmprintf("%s%s", tnm->getstr(tnm, "seshID", false), timeStamp);
3202//D("sesh %s", seshion); 3206//d("sesh %s", seshion);
3203 t0 = myHMAC(seshion, FALSE); 3207 t0 = myHMAC(seshion, FALSE);
3204 munchie = xmprintf("%s%s", t0, timeStamp); 3208 munchie = xmprintf("%s%s", t0, timeStamp);
3205//D("munchie %s", munchie); 3209//d("munchie %s", munchie);
3206 free(t0); 3210 free(t0);
3207 t1 = getStrH(Rd->body, "munchie"); 3211 t1 = getStrH(Rd->body, "munchie");
3208 if ('\0' != t1[0]) 3212 if ('\0' != t1[0])
@@ -3218,7 +3222,7 @@ static int validateSesh(reqData *Rd, qhashtbl_t *data)
3218 t1 = myHMAC(t0, FALSE); 3222 t1 = myHMAC(t0, FALSE);
3219 free(t0); 3223 free(t0);
3220 3224
3221//D("toke_n_munchie %s", t1); 3225//d("toke_n_munchie %s", t1);
3222 if (strcmp(t1, toke_n_munchie) != 0) 3226 if (strcmp(t1, toke_n_munchie) != 0)
3223 { 3227 {
3224 bitchSession(Rd, "Wrong toke_n_munchie for session.", "HMAC(UUID + munchie) != toke_n_munchie"); 3228 bitchSession(Rd, "Wrong toke_n_munchie for session.", "HMAC(UUID + munchie) != toke_n_munchie");
@@ -3236,10 +3240,10 @@ static int validateSesh(reqData *Rd, qhashtbl_t *data)
3236 t1 = myHMAC(t0, FALSE); 3240 t1 = myHMAC(t0, FALSE);
3237 free(t0); 3241 free(t0);
3238 toke_n_munchie = t1; 3242 toke_n_munchie = t1;
3239//D("toke_n_munchie %s", t1); 3243//d("toke_n_munchie %s", t1);
3240 } 3244 }
3241 t1 = myHMACkey(getStrH(tnm, "salt"), toke_n_munchie, FALSE); 3245 t1 = myHMACkey(getStrH(tnm, "salt"), toke_n_munchie, FALSE);
3242//D("hashish %s", t1); 3246//d("hashish %s", t1);
3243 if (strcmp(t1, hashish) != 0) 3247 if (strcmp(t1, hashish) != 0)
3244 { 3248 {
3245 bitchSession(Rd, "Wrong hashish for session.", "HMAC(toke_n_munchie + salt) != hashish"); 3249 bitchSession(Rd, "Wrong hashish for session.", "HMAC(toke_n_munchie + salt) != hashish");
@@ -3856,7 +3860,7 @@ static int validateUUID(reqData *Rd, qhashtbl_t *data)
3856 uuid_generate_random(binuuid); 3860 uuid_generate_random(binuuid);
3857 uuid_unparse_lower(binuuid, uuid); 3861 uuid_unparse_lower(binuuid, uuid);
3858 3862
3859 D("Trying new UUID %s.", uuid); 3863 d("Trying new UUID %s.", uuid);
3860// TODO - check the Lua user files as well. 3864// TODO - check the Lua user files as well.
3861 dbDoSomething(uuids, FALSE, uuid); 3865 dbDoSomething(uuids, FALSE, uuid);
3862 rows = uuids->rows; 3866 rows = uuids->rows;
@@ -4270,12 +4274,12 @@ void account_html(char *file, reqData *Rd, HTMLfile *thisFile)
4270 4274
4271 if (Rd->vegOut) 4275 if (Rd->vegOut)
4272 { 4276 {
4273 T("vegOut"); 4277 t("vegOut");
4274 freeSesh(Rd, FALSE, TRUE); 4278 freeSesh(Rd, FALSE, TRUE);
4275 } 4279 }
4276 else if (Rd->chillOut) 4280 else if (Rd->chillOut)
4277 { 4281 {
4278 T("chillOut"); 4282 t("chillOut");
4279 freeSesh(Rd, FALSE, FALSE); 4283 freeSesh(Rd, FALSE, FALSE);
4280 newSesh(Rd, FALSE); 4284 newSesh(Rd, FALSE);
4281 } 4285 }
@@ -4334,14 +4338,14 @@ void sledjchisl_main(void)
4334 } 4338 }
4335 else 4339 else
4336 { 4340 {
4337 if (S_ISREG (statbuf.st_mode)) D("STDIN is a regular file."); 4341 if (S_ISREG (statbuf.st_mode)) d("STDIN is a regular file.");
4338 else if (S_ISDIR (statbuf.st_mode)) D("STDIN is a directory."); 4342 else if (S_ISDIR (statbuf.st_mode)) d("STDIN is a directory.");
4339 else if (S_ISCHR (statbuf.st_mode)) D("STDIN is a character device."); 4343 else if (S_ISCHR (statbuf.st_mode)) d("STDIN is a character device.");
4340 else if (S_ISBLK (statbuf.st_mode)) D("STDIN is a block device."); 4344 else if (S_ISBLK (statbuf.st_mode)) d("STDIN is a block device.");
4341 else if (S_ISFIFO(statbuf.st_mode)) D("STDIN is a FIFO (named pipe)."); 4345 else if (S_ISFIFO(statbuf.st_mode)) d("STDIN is a FIFO (named pipe).");
4342 else if (S_ISLNK (statbuf.st_mode)) D("STDIN is a symbolic link."); 4346 else if (S_ISLNK (statbuf.st_mode)) d("STDIN is a symbolic link.");
4343 else if (S_ISSOCK(statbuf.st_mode)) D("STDIN is a socket."); 4347 else if (S_ISSOCK(statbuf.st_mode)) d("STDIN is a socket.");
4344 else D("STDIN is a unknown file descriptor type."); 4348 else d("STDIN is a unknown file descriptor type.");
4345 if (!S_ISCHR(statbuf.st_mode)) 4349 if (!S_ISCHR(statbuf.st_mode))
4346 isWeb = TRUE; 4350 isWeb = TRUE;
4347 } 4351 }
@@ -4438,19 +4442,19 @@ jit library is loaded or the JIT compiler will not be activated.
4438 } 4442 }
4439 } 4443 }
4440 } 4444 }
4441 if ((vd = configs->get (configs, "loadAverageInc", NULL, false)) != NULL) {loadAverageInc = *((float *) vd); D("Setting loadAverageInc = %f", loadAverageInc);} 4445 if ((vd = configs->get (configs, "loadAverageInc", NULL, false)) != NULL) {loadAverageInc = *((float *) vd); d("Setting loadAverageInc = %f", loadAverageInc);}
4442 if ((vd = configs->get (configs, "simTimeOut", NULL, false)) != NULL) {simTimeOut = (int) *((float *) vd); D("Setting simTimeOut = %d", simTimeOut);} 4446 if ((vd = configs->get (configs, "simTimeOut", NULL, false)) != NULL) {simTimeOut = (int) *((float *) vd); d("Setting simTimeOut = %d", simTimeOut);}
4443 if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; D("Setting scRoot = %s", scRoot);} 4447 if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; d("Setting scRoot = %s", scRoot);}
4444 if ((tmp = configs->getstr(configs, "scUser", false)) != NULL) {scUser = tmp; D("Setting scUser = %s", scUser);} 4448 if ((tmp = configs->getstr(configs, "scUser", false)) != NULL) {scUser = tmp; d("Setting scUser = %s", scUser);}
4445 if ((tmp = configs->getstr(configs, "Tconsole", false)) != NULL) {Tconsole = tmp; D("Setting Tconsole = %s", Tconsole);} 4449 if ((tmp = configs->getstr(configs, "Tconsole", false)) != NULL) {Tconsole = tmp; d("Setting Tconsole = %s", Tconsole);}
4446 if ((tmp = configs->getstr(configs, "Tsocket", false)) != NULL) {Tsocket = tmp; D("Setting Tsocket = %s", Tsocket);} 4450 if ((tmp = configs->getstr(configs, "Tsocket", false)) != NULL) {Tsocket = tmp; d("Setting Tsocket = %s", Tsocket);}
4447 if ((tmp = configs->getstr(configs, "Ttab", false)) != NULL) {Ttab = tmp; D("Setting Ttab = %s", Ttab);} 4451 if ((tmp = configs->getstr(configs, "Ttab", false)) != NULL) {Ttab = tmp; d("Setting Ttab = %s", Ttab);}
4448 if ((tmp = configs->getstr(configs, "webRoot", false)) != NULL) {webRoot = tmp; D("Setting webRoot = %s", webRoot);} 4452 if ((tmp = configs->getstr(configs, "webRoot", false)) != NULL) {webRoot = tmp; d("Setting webRoot = %s", webRoot);}
4449 if ((tmp = configs->getstr(configs, "URL", false)) != NULL) {URL = tmp; D("Setting URL = %s", URL);} 4453 if ((tmp = configs->getstr(configs, "URL", false)) != NULL) {URL = tmp; d("Setting URL = %s", URL);}
4450 if ((vd = configs->get (configs, "seshTimeOut", NULL, false)) != NULL) {seshTimeOut = (int) *((float *) vd); D("Setting seshTimeOut = %d", seshTimeOut);} 4454 if ((vd = configs->get (configs, "seshTimeOut", NULL, false)) != NULL) {seshTimeOut = (int) *((float *) vd); d("Setting seshTimeOut = %d", seshTimeOut);}
4451 if ((vd = configs->get (configs, "idleTimeOut", NULL, false)) != NULL) {idleTimeOut = (int) *((float *) vd); D("Setting idleTimeOut = %d", idleTimeOut);} 4455 if ((vd = configs->get (configs, "idleTimeOut", NULL, false)) != NULL) {idleTimeOut = (int) *((float *) vd); d("Setting idleTimeOut = %d", idleTimeOut);}
4452 if ((vd = configs->get (configs, "newbieTimeOut", NULL, false)) != NULL) {newbieTimeOut = (int) *((float *) vd); D("Setting newbieTimeOut = %d", newbieTimeOut);} 4456 if ((vd = configs->get (configs, "newbieTimeOut", NULL, false)) != NULL) {newbieTimeOut = (int) *((float *) vd); d("Setting newbieTimeOut = %d", newbieTimeOut);}
4453 if ((tmp = configs->getstr(configs, "ToS", false)) != NULL) {ToS = tmp; D("Setting ToS = %s", ToS);} 4457 if ((tmp = configs->getstr(configs, "ToS", false)) != NULL) {ToS = tmp; d("Setting ToS = %s", ToS);}
4454 4458
4455 4459
4456 // Use a FHS compatible setup - 4460 // Use a FHS compatible setup -
@@ -4667,11 +4671,11 @@ jit library is loaded or the JIT compiler will not be activated.
4667 I("Running SledjChisl inside a web server, pid %d.", getpid()); 4671 I("Running SledjChisl inside a web server, pid %d.", getpid());
4668 4672
4669 if (0 == toys.optc) 4673 if (0 == toys.optc)
4670 D("no args"); 4674 d("no args");
4671 else 4675 else
4672 { 4676 {
4673 for (entries = 0, bytes = -1; entries < toys.optc; entries++) 4677 for (entries = 0, bytes = -1; entries < toys.optc; entries++)
4674 D("ARG %s\n", toys.optargs[entries]); 4678 d("ARG %s\n", toys.optargs[entries]);
4675 } 4679 }
4676 printEnv(environ); 4680 printEnv(environ);
4677 4681
@@ -4710,7 +4714,7 @@ jit library is loaded or the JIT compiler will not be activated.
4710 4714
4711 // So far I'm seeing these as all caps, but I don't think they are defined that way. Case insensitive per the spec. 4715 // So far I'm seeing these as all caps, but I don't think they are defined that way. Case insensitive per the spec.
4712 // So convert them now, also "-" -> "_". 4716 // So convert them now, also "-" -> "_".
4713T("HEADERS"); 4717t("HEADERS");
4714 char **envp = environ; 4718 char **envp = environ;
4715 for ( ; *envp != NULL; envp++) 4719 for ( ; *envp != NULL; envp++)
4716 { 4720 {
@@ -4722,7 +4726,7 @@ T("HEADERS");
4722 char *ky = qstrreplace("tr", qstrupper(k), "-", "_"); 4726 char *ky = qstrreplace("tr", qstrupper(k), "-", "_");
4723 Rd->headers->putstr(Rd->headers, ky, v + 1); 4727 Rd->headers->putstr(Rd->headers, ky, v + 1);
4724if ((strcmp("HTTP_COOKIE", ky) == 0) || (strcmp("CONTENT_LENGTH", ky) == 0) || (strcmp("QUERY_STRING", ky) == 0)) 4728if ((strcmp("HTTP_COOKIE", ky) == 0) || (strcmp("CONTENT_LENGTH", ky) == 0) || (strcmp("QUERY_STRING", ky) == 0))
4725 D(" %s = %s", ky, v + 1); 4729 d(" %s = %s", ky, v + 1);
4726 } 4730 }
4727 } 4731 }
4728 4732
@@ -4761,10 +4765,10 @@ if ((strcmp("HTTP_COOKIE", ky) == 0) || (strcmp("CONTENT_LENGTH", ky) == 0) || (
4761 4765
4762 */ 4766 */
4763 4767
4764T("COOKIES"); 4768t("COOKIES");
4765 Rd->cookies = toknize(Rd->headers->getstr(Rd->headers, "HTTP_COOKIE", false), "=;"); 4769 Rd->cookies = toknize(Rd->headers->getstr(Rd->headers, "HTTP_COOKIE", false), "=;");
4766 santize(Rd->cookies, TRUE); 4770 santize(Rd->cookies, TRUE);
4767T("QUERY"); 4771t("QUERY");
4768 Rd->queries = toknize(Rd->headers->getstr(Rd->headers, "QUERY_STRING", false), "=&"); 4772 Rd->queries = toknize(Rd->headers->getstr(Rd->headers, "QUERY_STRING", false), "=&");
4769 santize(Rd->queries, TRUE); 4773 santize(Rd->queries, TRUE);
4770 char *Body = NULL; 4774 char *Body = NULL;
@@ -4779,7 +4783,7 @@ T("QUERY");
4779 } 4783 }
4780 Body[len] = '\0'; 4784 Body[len] = '\0';
4781 } 4785 }
4782T("BODY"); 4786t("BODY");
4783 Rd->body = toknize(Body, "=&"); 4787 Rd->body = toknize(Body, "=&");
4784 santize(Rd->body, TRUE); 4788 santize(Rd->body, TRUE);
4785 4789