Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
#
# .../ipif1 <v1config> <real-service-program> -- <service-args>...
#
#
# .../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>....
#
#
# permit <keyword>....
#
# if a permit has no ifname at all, it is as if
# `ifname userv%d' was specified
#
# 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>
#
#
# v0config <v0configfile>
#
sub readconfig ($) {
local ($cfgpath) = @_;
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;
my $cfgfh = new IO::File $cfgpath, "<";
if (!$cfgfh) {
die "$0: $cfgpath: $!\n" unless $!==ENOENT;