diff --git a/TODO.txt b/TODO.txt index ef1959f..3cfe040 100644 --- a/TODO.txt +++ b/TODO.txt @@ -40,10 +40,13 @@ Milestone: v0.4.0 [ ] How to set default value of true on boolean? - defaults probably need to be set at parser level, not enough to set it after. + - Or booleans should default to -1 if not specified, let the + higher level logic set the default from there. + [ ] Write man page. [ ] Refactor MatrixErrorCreate() to take a custom message or NULL to use the default. This will make debugging a lot easier. -[ ] Make sure admin registration token is printed to log, not stdout. +[x] Make sure admin registration token is printed to log, not stdout. Unless they are the same, of course. [ ] Refactor Config to use j2s. diff --git a/src/Main.c b/src/Main.c index 73c69ac..a2533b2 100644 --- a/src/Main.c +++ b/src/Main.c @@ -121,6 +121,8 @@ Main(Array * args) char startDir[PATH_MAX]; + char *token; + start: /* Global variables */ httpServers = NULL; @@ -140,6 +142,8 @@ start: groupInfo = NULL; cron = NULL; + token = NULL; + memset(&matrixArgs, 0, sizeof(matrixArgs)); if (!LogConfigGlobal()) @@ -226,7 +230,6 @@ start: if (!ConfigExists(matrixArgs.db)) { - char *token; RegTokenInfo *info; Log(LOG_NOTICE, "No configuration exists in the opened database."); @@ -253,11 +256,11 @@ start: goto finish; } - Log(LOG_NOTICE, "Admin Registration token: %s", token); - - Free(token); RegTokenClose(info); RegTokenFree(info); + + /* Don't free token, because we need to print it when logging is + * set up. */ } Log(LOG_NOTICE, "Loading configuration..."); @@ -336,6 +339,13 @@ start: goto finish; } + /* If a token was created with a default config, print it to the log */ + if (token) + { + Log(LOG_NOTICE, "Admin Registration token: %s", token); + Free(token); + } + Log(LOG_DEBUG, "Configuration:"); LogConfigIndent(LogConfigGlobal()); Log(LOG_DEBUG, "Server Name: %s", tConfig->serverName);