From 14454b3071c7a5c053fde8eed416ab3b2f8475fb Mon Sep 17 00:00:00 2001 From: Brandon Maier Date: Fri, 21 Sep 2018 12:54:05 -0500 Subject: ifupdown: support "source-directory" stanza Support the "source-directory" stanza from ifupdown[1]. source-directory will include all files in the named directory. Similar to the Busybox version of the "source" stanza, this version of source-directory does not currently support shell wildcards. We only check that the stanza starts with "source-dir" as ifupdown does[2]. [1] https://manpages.debian.org/stretch/ifupdown/interfaces.5.en.html#INCLUDING_OTHER_FILES [2] https://salsa.debian.org/debian/ifupdown/blob/0.8.33/config.c#L498 function old new delta read_interfaces 1150 1241 +91 Signed-off-by: Brandon Maier Signed-off-by: Denys Vlasenko --- networking/ifupdown.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'networking') diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 5481134e5..80fce87a6 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c @@ -1022,6 +1022,22 @@ static struct interfaces_file_t *read_interfaces(const char *filename, struct in currently_processing = NONE; } else if (strcmp(first_word, "source") == 0) { read_interfaces(next_word(&rest_of_line), defn); + } else if (is_prefixed_with(first_word, "source-dir")) { + const char *dirpath; + DIR *dir; + struct dirent *entry; + + dirpath = next_word(&rest_of_line); + dir = xopendir(dirpath); + while ((entry = readdir(dir)) != NULL) { + char *path; + if (entry->d_name[0] == '.') + continue; + path = concat_path_file(dirpath, entry->d_name); + read_interfaces(path, defn); + free(path); + } + closedir(dir); } else { switch (currently_processing) { case IFACE: -- cgit v1.2.3