From 03e3cd7d0224293624a17af7de6638cdd8659917 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 21 Apr 2017 21:04:03 +0100 Subject: [PATCH] ipif: "include" looks for the file in the directory where "include" appears Signed-off-by: Ian Jackson --- ipif/service-wrap | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ipif/service-wrap b/ipif/service-wrap index 678a867..8dca1c3 100755 --- a/ipif/service-wrap +++ b/ipif/service-wrap @@ -62,6 +62,7 @@ use strict; use POSIX; use Carp; use NetAddr::IP::Lite qw(:nofqdn :lower); +use File::Basename; our $default_ifname = 'userv%d'; @@ -265,7 +266,9 @@ sub readconfig ($) { foreach @wrong; } } elsif (m{^include\s+(\S+)$}) { - readconfig $1; + my $include = $1; + $include =~ s{^(?!/)}{ dirname($cfgpath)."/" }e; + readconfig $include; } else { badcfg "unknown config directive or bad syntax"; } @@ -274,10 +277,21 @@ sub readconfig ($) { close $cfgfh; } -readconfig $v1config; - -if ($v0config && $v0config =~ m{^[^#]} && $v0config ne '/dev/null') { +sub try_v0config() { + return unless $v0config; + return unless $v0config =~ m{^[^#]}; + return if $v0config eq '/dev/null'; + if ($v0config =~ m{^/}) { + if (!stat $v0config) { + die "v0 config $v0config: $!\n" unless $!==ENOENT; + return; + } + } print "trying v0 config $v0config...\n" if $protocol eq 'debug'; execreal $v0config; } + +readconfig $v1config; +try_v0config(); + die "permission denied\n"; -- 2.30.2