cmdmon: save NTS cookies and server keys on dump command
Extend the dump command to save also the server NTS keys and client NTS cookies. Remove the warning for unset dumpdir.
This commit is contained in:
parent
0b2e77ae64
commit
d690faeb19
14 changed files with 82 additions and 3 deletions
2
client.c
2
client.c
|
@ -1267,7 +1267,7 @@ give_help(void)
|
|||
"\0\0"
|
||||
"Other daemon commands:\0\0"
|
||||
"cyclelogs\0Close and re-open log files\0"
|
||||
"dump\0Dump all measurements to save files\0"
|
||||
"dump\0Dump measurements and NTS keys/cookies\0"
|
||||
"rekey\0Re-read keys from key file\0"
|
||||
"reset\0Drop all measurements\0"
|
||||
"shutdown\0Stop daemon\0"
|
||||
|
|
3
cmdmon.c
3
cmdmon.c
|
@ -44,6 +44,7 @@
|
|||
#include "reference.h"
|
||||
#include "manual.h"
|
||||
#include "memory.h"
|
||||
#include "nts_ke_server.h"
|
||||
#include "local.h"
|
||||
#include "addrfilt.h"
|
||||
#include "conf.h"
|
||||
|
@ -309,6 +310,8 @@ static void
|
|||
handle_dump(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
{
|
||||
SRC_DumpSources();
|
||||
NSR_DumpAuthData();
|
||||
NKS_DumpKeys();
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
|
14
ntp_auth.c
14
ntp_auth.c
|
@ -484,3 +484,17 @@ NAU_ChangeAddress(NAU_Instance instance, IPAddr *address)
|
|||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
NAU_DumpData(NAU_Instance instance)
|
||||
{
|
||||
switch (instance->mode) {
|
||||
case NTP_AUTH_NTS:
|
||||
NNC_DumpData(instance->nts);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,4 +86,7 @@ extern int NAU_CheckResponseAuth(NAU_Instance instance, NTP_Packet *response,
|
|||
/* Change an authentication-specific address (e.g. after replacing a source) */
|
||||
extern void NAU_ChangeAddress(NAU_Instance instance, IPAddr *address);
|
||||
|
||||
/* Save authentication-specific data to speed up the next start */
|
||||
extern void NAU_DumpData(NAU_Instance instance);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2562,6 +2562,14 @@ int NCR_IsSyncPeer(NCR_Instance inst)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
NCR_DumpAuthData(NCR_Instance inst)
|
||||
{
|
||||
NAU_DumpData(inst->auth);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
broadcast_timeout(void *arg)
|
||||
{
|
||||
|
|
|
@ -136,6 +136,8 @@ extern uint32_t NCR_GetLocalRefid(NCR_Instance inst);
|
|||
|
||||
extern int NCR_IsSyncPeer(NCR_Instance instance);
|
||||
|
||||
extern void NCR_DumpAuthData(NCR_Instance inst);
|
||||
|
||||
extern void NCR_AddBroadcastDestination(IPAddr *addr, unsigned short port, int interval);
|
||||
|
||||
#endif /* GOT_NTP_CORE_H */
|
||||
|
|
|
@ -1297,6 +1297,18 @@ NSR_GetActivityReport(RPT_ActivityReport *report)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
NSR_DumpAuthData(void)
|
||||
{
|
||||
SourceRecord *record;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARR_GetSize(records); i++) {
|
||||
record = get_record(i);
|
||||
if (!record->remote_addr)
|
||||
continue;
|
||||
NCR_DumpAuthData(record->data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,4 +140,6 @@ extern int NSR_GetNTPReport(RPT_NTPReport *report);
|
|||
|
||||
extern void NSR_GetActivityReport(RPT_ActivityReport *report);
|
||||
|
||||
extern void NSR_DumpAuthData(void);
|
||||
|
||||
#endif /* GOT_NTP_SOURCES_H */
|
||||
|
|
|
@ -707,6 +707,14 @@ NKS_Finalise(void)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
NKS_DumpKeys(void)
|
||||
{
|
||||
save_keys();
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
/* A server cookie consists of key ID, nonce, and encrypted C2S+S2C keys */
|
||||
|
||||
int
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
extern void NKS_Initialise(int scfilter_level);
|
||||
extern void NKS_Finalise(void);
|
||||
|
||||
/* Save the current server keys */
|
||||
extern void NKS_DumpKeys(void);
|
||||
|
||||
/* Generate an NTS cookie with a given context */
|
||||
extern int NKS_GenerateCookie(NKE_Context *context, NKE_Cookie *cookie);
|
||||
|
||||
|
|
|
@ -619,3 +619,11 @@ error:
|
|||
memset(&inst->context, 0, sizeof (inst->context));
|
||||
inst->num_cookies = 0;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
NNC_DumpData(NNC_Instance inst)
|
||||
{
|
||||
save_cookies(inst);
|
||||
}
|
||||
|
|
|
@ -43,4 +43,6 @@ extern int NNC_CheckResponseAuth(NNC_Instance inst, NTP_Packet *packet,
|
|||
|
||||
extern void NNC_ChangeAddress(NNC_Instance inst, IPAddr *address);
|
||||
|
||||
extern void NNC_DumpData(NNC_Instance inst);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1197,7 +1197,6 @@ FILE *open_dumpfile(SRC_Instance inst, char mode)
|
|||
|
||||
dumpdir = CNF_GetDumpDir();
|
||||
if (dumpdir[0] == '\0') {
|
||||
LOG(LOGS_WARN, "dumpdir not specified");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
15
stubs.c
15
stubs.c
|
@ -331,6 +331,11 @@ NSR_GetActivityReport(RPT_ActivityReport *report)
|
|||
memset(report, 0, sizeof (*report));
|
||||
}
|
||||
|
||||
void
|
||||
NSR_DumpAuthData(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef FEAT_CMDMON
|
||||
|
||||
void
|
||||
|
@ -515,6 +520,11 @@ NNC_ChangeAddress(NNC_Instance inst, IPAddr *address)
|
|||
{
|
||||
}
|
||||
|
||||
void
|
||||
NNC_DumpData(NNC_Instance inst)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
NKC_Initialise(void)
|
||||
{
|
||||
|
@ -535,4 +545,9 @@ NKS_Finalise(void)
|
|||
{
|
||||
}
|
||||
|
||||
void
|
||||
NKS_DumpKeys(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* !FEAT_NTS */
|
||||
|
|
Loading…
Reference in a new issue