summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bachmann <manuel.bachmann@iot.bzh>2016-05-11 08:45:06 +0200
committerManuel Bachmann <manuel.bachmann@iot.bzh>2016-05-11 08:45:06 +0200
commitdef39ec22797c5cd40b7f0bf97df6007c62b3f7d (patch)
tree05eabe22a65f7ce3e3756326e14b55ed23fb2d70
parenta4c89089944e8b101ec39ce19dacf400c16aeabf (diff)
daemon: make --token parameter mandatory
The daemon now quits with an explicit error message instead of crashing if the "--token" parameter was omitted. Signed-off-by: Manuel Bachmann <manuel.bachmann@iot.bzh>
-rw-r--r--src/session.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/session.c b/src/session.c
index d08ca759..46db9cea 100644
--- a/src/session.c
+++ b/src/session.c
@@ -83,11 +83,16 @@ static void ctxUuidFreeCB (struct AFB_clientCtx *client)
// Create a new store in RAM, not that is too small it will be automatically extended
void ctxStoreInit (int max_session_count, int timeout, const char *initok, int context_count)
{
+
// let's create as store as hashtable does not have any
sessions.store = calloc (1 + (unsigned)max_session_count, sizeof(struct AFB_clientCtx));
sessions.max = max_session_count;
sessions.timeout = timeout;
sessions.apicount = context_count;
+ if (!initok) {
+ ERROR("\"--token=\" parameter is mandatory");
+ exit(1);
+ }
if (strlen(initok) >= sizeof(sessions.store[0]->token)) {
ERROR("initial token '%s' too long (max length 36)", initok);
exit(1);