Add option to generate command key on start

With generatecommandkey directive, if no command key is found in the key
file on start, one will be generated automatically from /dev/urandom.
This commit is contained in:
Miroslav Lichvar
2013-05-21 13:58:52 +02:00
parent ea3672df4e
commit 1c901b82dc
6 changed files with 105 additions and 5 deletions

21
conf.c
View File

@@ -73,6 +73,7 @@ static void parse_driftfile(char *);
static void parse_dumpdir(char *);
static void parse_dumponexit(char *);
static void parse_fallbackdrift(char *);
static void parse_generatecommandkey(char *);
static void parse_include(char *);
static void parse_initstepslew(char *);
static void parse_keyfile(char *);
@@ -111,6 +112,7 @@ static void parse_user(char *);
/* Configuration variables */
static int restarted = 0;
static int generate_command_key = 0;
static char *rtc_device = "/dev/rtc";
static int acquisition_port = 0; /* 0 means let kernel choose port */
static int ntp_port = 123;
@@ -386,6 +388,8 @@ CNF_ReadFile(const char *filename)
parse_dumponexit(p);
} else if (!strcasecmp(command, "fallbackdrift")) {
parse_fallbackdrift(p);
} else if (!strcasecmp(command, "generatecommandkey")) {
parse_generatecommandkey(p);
} else if (!strcasecmp(command, "include")) {
parse_include(p);
} else if (!strcasecmp(command, "initstepslew")) {
@@ -999,6 +1003,15 @@ parse_fallbackdrift(char *line)
/* ================================================== */
static void
parse_generatecommandkey(char *line)
{
check_number_of_args(line, 0);
generate_command_key = 1;
}
/* ================================================== */
static void
parse_makestep(char *line)
{
@@ -1563,6 +1576,14 @@ CNF_GetCommandKey(void)
/* ================================================== */
int
CNF_GetGenerateCommandKey(void)
{
return generate_command_key;
}
/* ================================================== */
int
CNF_GetDumpOnExit(void)
{