diff options
author | Brandon Maier <brandon.maier@rockwellcollins.com> | 2018-09-21 12:54:05 -0500 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-30 13:23:05 +0200 |
commit | 14454b3071c7a5c053fde8eed416ab3b2f8475fb (patch) | |
tree | d24d35fc5b1a12e575202b79ebe1c89abb36d670 | |
parent | abfa3ec0598ff431407224c6b81682f7d0d35495 (diff) | |
download | busybox-w32-14454b3071c7a5c053fde8eed416ab3b2f8475fb.tar.gz busybox-w32-14454b3071c7a5c053fde8eed416ab3b2f8475fb.tar.bz2 busybox-w32-14454b3071c7a5c053fde8eed416ab3b2f8475fb.zip |
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 <brandon.maier@rockwellcollins.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ifupdown.c | 16 |
1 files changed, 16 insertions, 0 deletions
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 | |||
1022 | currently_processing = NONE; | 1022 | currently_processing = NONE; |
1023 | } else if (strcmp(first_word, "source") == 0) { | 1023 | } else if (strcmp(first_word, "source") == 0) { |
1024 | read_interfaces(next_word(&rest_of_line), defn); | 1024 | read_interfaces(next_word(&rest_of_line), defn); |
1025 | } else if (is_prefixed_with(first_word, "source-dir")) { | ||
1026 | const char *dirpath; | ||
1027 | DIR *dir; | ||
1028 | struct dirent *entry; | ||
1029 | |||
1030 | dirpath = next_word(&rest_of_line); | ||
1031 | dir = xopendir(dirpath); | ||
1032 | while ((entry = readdir(dir)) != NULL) { | ||
1033 | char *path; | ||
1034 | if (entry->d_name[0] == '.') | ||
1035 | continue; | ||
1036 | path = concat_path_file(dirpath, entry->d_name); | ||
1037 | read_interfaces(path, defn); | ||
1038 | free(path); | ||
1039 | } | ||
1040 | closedir(dir); | ||
1025 | } else { | 1041 | } else { |
1026 | switch (currently_processing) { | 1042 | switch (currently_processing) { |
1027 | case IFACE: | 1043 | case IFACE: |