diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2017-04-19 18:22:50 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2017-04-19 18:24:38 +0100 |
commit | 4e5552a4239587e8bcc6a7fae5c6b276b6b8e873 (patch) | |
tree | 7a48959078c4ce709c79d06786ea777133a1e7f3 | |
parent | 0d8db3665339c2dac87a8c301db065c96e43edee (diff) | |
download | userv-utils-4e5552a4239587e8bcc6a7fae5c6b276b6b8e873.tar.gz |
ipif: service-wrap: Scan directories
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rwxr-xr-x | ipif/service-wrap | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ipif/service-wrap b/ipif/service-wrap index 7f6dad4..412c2dc 100755 --- a/ipif/service-wrap +++ b/ipif/service-wrap @@ -15,7 +15,8 @@ # # .../ipif1 <v1config> <real-service-program> -- <service-args>... # -# Config file is a series of lines. +# Config file is a series of lines, or a directory. If a directory, +# all files with names matching ^[-A-Za-z0-9_]+$ are processed. # # permit <keyword>.... # @@ -47,7 +48,7 @@ # if a permit has no ifname at all, it is as if # `ifname userv%d' was specified # -# include <other-config-file> +# include <other-config-file-or-directory> # # v0config <v0configfile> # @@ -176,8 +177,21 @@ sub maybe_allow_addrs ($$) { } } +sub readconfig ($); sub readconfig ($) { local ($cfgpath) = @_; + + my $dirfh; + if (opendir $dirfh, $cfgpath) { + while ($!=0, my $ent = readdir $dirfh) { + next if $ent =~ m/[^-A-Za-z0-9_]/; + readconfig "$cfgpath/$ent"; + } + die "$0: $cfgpath: $!\n" if $!; + return; + } + die "$0: $cfgpath: $!\n" unless $!==ENOENT || $!==ENOTDIR; + my $cfgfh = new IO::File $cfgpath, "<"; if (!$cfgfh) { die "$0: $cfgpath: $!\n" unless $!==ENOENT; |