2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

Merge branch 'aram/fix-lock-file-option-and--X-argument-issues' into 'main'

Fix assertion failure when using -X none and lock-file in configuration

See merge request isc-projects/bind9!8432
This commit is contained in:
Arаm Sаrgsyаn
2023-10-26 13:11:30 +00:00

View File

@@ -8151,8 +8151,8 @@ check_lockfile(named_server_t *server, const cfg_obj_t *config,
(void)named_config_get(maps, "lock-file", &obj); (void)named_config_get(maps, "lock-file", &obj);
if (!first_time) { if (!first_time) {
if (obj != NULL && !cfg_obj_isstring(obj) && if (obj != NULL && cfg_obj_isstring(obj) &&
server->lockfile != NULL && server->lockfile != NULL && !named_g_forcelock &&
strcmp(cfg_obj_asstring(obj), server->lockfile) != 0) strcmp(cfg_obj_asstring(obj), server->lockfile) != 0)
{ {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
@@ -8166,27 +8166,24 @@ check_lockfile(named_server_t *server, const cfg_obj_t *config,
} }
if (obj != NULL) { if (obj != NULL) {
if (cfg_obj_isvoid(obj)) { if (named_g_forcelock) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_DEBUG(1),
"skipping lock-file check ");
return (ISC_R_SUCCESS);
} else if (named_g_forcelock) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING, NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
"'lock-file' has no effect " "'lock-file' has no effect "
"because the server was run with -X"); "because the server was run with -X");
server->lockfile = isc_mem_strdup( if (named_g_defaultlockfile != NULL) {
server->mctx, named_g_defaultlockfile); server->lockfile = isc_mem_strdup(
} else { server->mctx, named_g_defaultlockfile);
}
} else if (cfg_obj_isvoid(obj)) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_DEBUG(1),
"skipping lock-file check");
} else if (cfg_obj_isstring(obj)) {
filename = cfg_obj_asstring(obj); filename = cfg_obj_asstring(obj);
server->lockfile = isc_mem_strdup(server->mctx, server->lockfile = isc_mem_strdup(server->mctx,
filename); filename);
} }
if (server->lockfile == NULL) {
return (ISC_R_NOMEMORY);
}
} else if (named_g_forcelock && named_g_defaultlockfile != NULL) { } else if (named_g_forcelock && named_g_defaultlockfile != NULL) {
server->lockfile = isc_mem_strdup(server->mctx, server->lockfile = isc_mem_strdup(server->mctx,
named_g_defaultlockfile); named_g_defaultlockfile);