]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/config: Make /run path configurable
authorKarel Zak <kzak@redhat.com>
Thu, 9 Oct 2025 18:35:26 +0000 (20:35 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 14 Oct 2025 11:22:05 +0000 (13:22 +0200)
Avoid hardcoded paths when writing regression tests.

Signed-off-by: Karel Zak <kzak@redhat.com>
include/configs.h
lib/configs.c
term-utils/agetty.c

index ea72afacc9aad3df4b0b022297f279a05167cc90..95b9bb46c6b9960d0cb93a9efb84a832bf513c7a 100644 (file)
@@ -44,6 +44,7 @@
 int ul_configs_file_list(struct list_head *file_list,
                         const char *project,
                         const char *etc_subdir,
+                        const char *run_subdir,
                         const char *usr_subdir,
                         const char *config_name,
                         const char *config_suffix);
index 09bfffb667d23bc3b81f096f94a3d149033d0403..105d97f37a905abf51f2414abf8c9efc63b43f68 100644 (file)
@@ -191,6 +191,7 @@ static void free_list_entry(struct file_element *element)
 int ul_configs_file_list(struct list_head *file_list,
                         const char *project,
                         const char *etc_subdir,
+                        const char *run_subdir,
                         const char *usr_subdir,
                         const char *config_name,
                         const char *config_suffix)
@@ -215,7 +216,8 @@ int ul_configs_file_list(struct list_head *file_list,
        /* Default is /etc */
        if (!etc_subdir)
                etc_subdir = _PATH_SYSCONFDIR;
-
+       if (!run_subdir)
+               run_subdir = "";
        if (!usr_subdir)
                usr_subdir = "";
 
@@ -226,7 +228,7 @@ int ul_configs_file_list(struct list_head *file_list,
        /* in the following order : /etc /run /usr             */
        filename = main_configs(etc_subdir, project, config_name, config_suffix);
        if (filename == NULL)
-               filename = main_configs(_PATH_RUNSTATEDIR, project, config_name, config_suffix);
+               filename = main_configs(run_subdir, project, config_name, config_suffix);
        if (filename == NULL)
                filename = main_configs(usr_subdir, project, config_name, config_suffix);
        if (filename != NULL) {
@@ -252,7 +254,7 @@ int ul_configs_file_list(struct list_head *file_list,
                           config_suffix);
        ret_run = read_dir(&run_file_list,
                           project,
-                          _PATH_RUNSTATEDIR,
+                          run_subdir,
                           config_name,
                           config_suffix);
        ret_usr = read_dir(&usr_file_list,
index 08d009261e1f922b14b24e8c5f49c73127702506..7a97167cd8c749bf188c946d463a2d35e2edc127 100644 (file)
@@ -1952,6 +1952,7 @@ skip:
        ul_configs_file_list(&file_list,
                             NULL,
                             _PATH_SYSCONFDIR,
+                            _PATH_SYSCONFDIR,
                             _PATH_SYSCONFSTATICDIR,
                             "issue",
                             ISSUEDIR_EXT);