Commit 7dac8d23 authored by Andreas Gustafsson's avatar Andreas Gustafsson

the server would catch an assertion failure if the key statement in rndc.key

was missing the algorithm or secret clause
parent f4effb70
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: controlconf.c,v 1.18 2001/08/03 05:56:19 marka Exp $ */
/* $Id: controlconf.c,v 1.19 2001/08/03 17:24:08 gson Exp $ */
#include <config.h>
......@@ -36,6 +36,7 @@
#include <isc/util.h>
#include <isccfg/cfg.h>
#include <isccfg/check.h>
#include <isccc/alist.h>
#include <isccc/cc.h>
......@@ -750,6 +751,8 @@ get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids) {
if (keyid->keyname == NULL)
CHECK(ISC_R_NOMEMORY);
CHECK(cfg_check_key(key, ns_g_lctx));
(void)cfg_map_get(key, "algorithm", &algobj);
(void)cfg_map_get(key, "secret", &secretobj);
INSIST(algobj != NULL && secretobj != NULL);
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: check.c,v 1.13 2001/07/19 16:29:14 bwelling Exp $ */
/* $Id: check.c,v 1.14 2001/08/03 17:24:10 gson Exp $ */
#include <config.h>
......@@ -294,6 +294,24 @@ check_zoneconf(cfg_obj_t *zconfig, isc_symtab_t *symtab, isc_log_t *logctx) {
return (result);
}
isc_result_t
cfg_check_key(cfg_obj_t *key, isc_log_t *logctx) {
cfg_obj_t *algobj = NULL;
cfg_obj_t *secretobj = NULL;
const char *keyname = cfg_obj_asstring(cfg_map_getname(key));
cfg_map_get(key, "algorithm", &algobj);
cfg_map_get(key, "secret", &secretobj);
if (secretobj == NULL || algobj == NULL) {
cfg_obj_log(key, logctx, ISC_LOG_ERROR,
"key '%s' must have both 'secret' and "
"'algorithm' defined",
keyname);
return ISC_R_FAILURE;
}
return ISC_R_SUCCESS;
}
static isc_result_t
check_viewconf(cfg_obj_t *vconfig, const char *vname, isc_log_t *logctx,
isc_mem_t *mctx)
......@@ -341,10 +359,8 @@ check_viewconf(cfg_obj_t *vconfig, const char *vname, isc_log_t *logctx,
{
cfg_obj_t *key = cfg_listelt_value(element);
const char *keyname = cfg_obj_asstring(cfg_map_getname(key));
cfg_obj_t *algobj = NULL;
cfg_obj_t *secretobj = NULL;
isc_symvalue_t symvalue;
symvalue.as_pointer = NULL;
tresult = isc_symtab_define(symtab, keyname, 1,
symvalue, isc_symexists_reject);
......@@ -356,14 +372,11 @@ check_viewconf(cfg_obj_t *vconfig, const char *vname, isc_log_t *logctx,
isc_symtab_destroy(&symtab);
return (tresult);
}
cfg_map_get(key, "algorithm", &algobj);
cfg_map_get(key, "secret", &secretobj);
if (secretobj == NULL || algobj == NULL) {
cfg_obj_log(key, logctx, ISC_LOG_ERROR,
"key '%s' must have both 'secret' and "
"algorithm defined",
keyname);
result = ISC_R_FAILURE;
tresult = cfg_check_key(key, logctx);
if (result != ISC_R_SUCCESS) {
isc_symtab_destroy(&symtab);
return (tresult);
}
}
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: check.h,v 1.3 2001/03/08 00:55:50 bwelling Exp $ */
/* $Id: check.h,v 1.4 2001/08/03 17:24:11 gson Exp $ */
#ifndef ISCCFG_CHECK_H
#define ISCCFG_CHECK_H 1
......@@ -43,6 +43,12 @@ cfg_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx);
* ISC_R_FAILURE
*/
isc_result_t
cfg_check_key(cfg_obj_t *config, isc_log_t *logctx);
/*
* As above, but for a single 'key' statement.
*/
ISC_LANG_ENDDECLS
#endif /* ISCCFG_CHECK_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment