From 3832070e927acb88ac67185742f30ec79923b093 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Tue, 20 Aug 2024 11:30:13 +0000 Subject: [PATCH] Print the full path of the working directory in startup log messages named now prints its initial working directory during startup and the changed working directory when loading or reloading its configuration file if it has a valid 'directory' option defined. (cherry picked from commit fd8e1d161fc3e2d40497fec3a30df5973dc180fe) --- bin/named/server.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bin/named/server.c b/bin/named/server.c index 40b808a817..04361ec690 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -7088,6 +7088,13 @@ directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg) { return (result); } + char cwd[PATH_MAX]; + if (getcwd(cwd, sizeof(cwd)) == cwd) { + isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, + NAMED_LOGMODULE_SERVER, ISC_LOG_INFO, + "the working directory is now '%s'", cwd); + } + return (ISC_R_SUCCESS); } @@ -8559,6 +8566,19 @@ load_configuration(const char *filename, named_server_t *server, &named_g_defaults) == ISC_R_SUCCESS); } + /* + * Log the current working directory. + */ + if (first_time) { + char cwd[PATH_MAX]; + if (getcwd(cwd, sizeof(cwd)) == cwd) { + isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, + NAMED_LOGMODULE_SERVER, ISC_LOG_INFO, + "the initial working directory is '%s'", + cwd); + } + } + /* * Parse the configuration file using the new config code. */