handle nonexistent managed-keys-directory
3378. [bug] Handle missing 'managed-keys-directory' better. [RT #30625]
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
3378. [bug] Handle missing 'managed-keys-directory' better.
|
||||
[RT #30625]
|
||||
|
||||
3377. [bug] Removed spurious newline from NSEC3 multiline
|
||||
output. [RT #31044]
|
||||
|
||||
|
||||
+11
-1
@@ -808,7 +808,17 @@ configure_view_dnsseckeys(dns_view_t *view, const cfg_obj_t *vconfig,
|
||||
*/
|
||||
obj = NULL;
|
||||
(void)ns_config_get(maps, "managed-keys-directory", &obj);
|
||||
directory = obj != NULL ? cfg_obj_asstring(obj) : NULL;
|
||||
directory = (obj != NULL ? cfg_obj_asstring(obj) : NULL);
|
||||
if (directory != NULL)
|
||||
result = isc_file_isdirectory(directory);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(ns_g_lctx, DNS_LOGCATEGORY_SECURITY,
|
||||
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
||||
"invalid managed-keys-directory %s: %s",
|
||||
directory, isc_result_totext(result));
|
||||
goto cleanup;
|
||||
|
||||
}
|
||||
CHECK(add_keydata_zone(view, directory, ns_g_mctx));
|
||||
|
||||
cleanup:
|
||||
|
||||
+13
-4
@@ -3553,6 +3553,13 @@ sync_keyzone(dns_zone_t *zone, dns_db_t *db) {
|
||||
}
|
||||
|
||||
failure:
|
||||
if (result != ISC_R_SUCCESS &&
|
||||
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) {
|
||||
dns_zone_log(zone, ISC_LOG_ERROR,
|
||||
"unable to synchronize managed keys: %s",
|
||||
dns_result_totext(result));
|
||||
isc_time_settoepoch(&zone->refreshkeytime);
|
||||
}
|
||||
if (keynode != NULL)
|
||||
dns_keytable_detachkeynode(sr, &keynode);
|
||||
if (sr != NULL)
|
||||
@@ -8551,10 +8558,12 @@ zone_maintenance(dns_zone_t *zone) {
|
||||
*/
|
||||
switch (zone->type) {
|
||||
case dns_zone_key:
|
||||
if (isc_time_compare(&now, &zone->refreshkeytime) >= 0 &&
|
||||
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED) &&
|
||||
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_REFRESHING))
|
||||
zone_refreshkeys(zone);
|
||||
if (isc_time_compare(&now, &zone->refreshkeytime) >= 0) {
|
||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED) &&
|
||||
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_REFRESHING)) {
|
||||
zone_refreshkeys(zone);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case dns_zone_master:
|
||||
if (!isc_time_isepoch(&zone->refreshkeytime) &&
|
||||
|
||||
@@ -217,6 +217,22 @@ isc_file_isplainfile(const char *name);
|
||||
* These occur when stat returns -1 and an errno.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_isdirectory(const char *name);
|
||||
/*!<
|
||||
* \brief Check that 'name' exists and is a directory.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
* Success, file is a directory.
|
||||
*\li #ISC_R_INVALIDFILE
|
||||
* File is not a directory.
|
||||
*\li #ISC_R_FILENOTFOUND
|
||||
* File does not exist.
|
||||
*\li #other ISC_R_* errors translated from errno
|
||||
* These occur when stat returns -1 and an errno.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_file_iscurrentdir(const char *filename);
|
||||
/*!<
|
||||
|
||||
@@ -396,6 +396,24 @@ isc_file_isplainfile(const char *filename) {
|
||||
return(ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_isdirectory(const char *filename) {
|
||||
/*
|
||||
* This function returns success if filename exists and is a
|
||||
* directory.
|
||||
*/
|
||||
struct stat filestat;
|
||||
memset(&filestat,0,sizeof(struct stat));
|
||||
|
||||
if ((stat(filename, &filestat)) == -1)
|
||||
return(isc__errno2result(errno));
|
||||
|
||||
if(! S_ISDIR(filestat.st_mode))
|
||||
return(ISC_R_INVALIDFILE);
|
||||
|
||||
return(ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
isc_file_isabsolute(const char *filename) {
|
||||
REQUIRE(filename != NULL);
|
||||
|
||||
@@ -440,6 +440,23 @@ isc_file_isplainfile(const char *filename) {
|
||||
return(ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_isdirectory(const char *filename) {
|
||||
/*
|
||||
* This function returns success if filename is a directory.
|
||||
*/
|
||||
struct stat filestat;
|
||||
memset(&filestat,0,sizeof(struct stat));
|
||||
|
||||
if ((stat(filename, &filestat)) == -1)
|
||||
return(isc__errno2result(errno));
|
||||
|
||||
if(! S_ISDIR(filestat.st_mode))
|
||||
return(ISC_R_INVALIDFILE);
|
||||
|
||||
return(ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
isc_file_isabsolute(const char *filename) {
|
||||
REQUIRE(filename != NULL);
|
||||
|
||||
@@ -228,6 +228,7 @@ isc_file_getmodtime
|
||||
isc_file_isabsolute
|
||||
isc_file_ischdiridempotent
|
||||
isc_file_iscurrentdir
|
||||
isc_file_isdirectory
|
||||
isc_file_isplainfile
|
||||
isc_file_mktemplate
|
||||
isc_file_mode
|
||||
|
||||
Reference in New Issue
Block a user