]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Print the full path of the working directory in startup log messages
authorAram Sargsyan <aram@isc.org>
Tue, 20 Aug 2024 11:30:13 +0000 (11:30 +0000)
committerAram Sargsyan <aram@isc.org>
Tue, 20 Aug 2024 16:28:53 +0000 (16:28 +0000)
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.

bin/named/server.c

index 2a61a8cc45f936b65735a433f4d4796d55ead506..a57f5f5597a0f1a1807d85944402c66bdf6e951d 100644 (file)
@@ -7033,6 +7033,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_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
+                             ISC_LOG_INFO, "the working directory is now '%s'",
+                             cwd);
+       }
+
        return (ISC_R_SUCCESS);
 }
 
@@ -8261,6 +8268,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_LOGCATEGORY_GENERAL,
+                                     NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
+                                     "the initial working directory is '%s'",
+                                     cwd);
+               }
+       }
+
        /*
         * Parse the configuration file using the new config code.
         */