Print admin registration token to configured log, not default stdout.

If Telodendria is started as a daemon and is logging to the syslog, we
want the token to show up in the syslog.
This commit is contained in:
Jordan Bancino 2023-08-05 14:12:02 +00:00
parent 6ec87b8d76
commit 78302d6320
2 changed files with 18 additions and 5 deletions

View file

@ -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.

View file

@ -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);