]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
Fix reading of configuration files in symlinked directories
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 6 Jan 2014 14:41:04 +0000 (15:41 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 6 Jan 2014 14:41:04 +0000 (15:41 +0100)
We want novaboot to follow logical directory structure based on symlinks
and not to follow directories simply using ".." directory entry.

novaboot
tests/novaboot.wv

index 05996a12b4e1358e1ceb6954db801dfbfc71e3aa..6632e876fd7138c23a097ad20f3a7c6ab6e309ee 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -32,7 +32,7 @@ use Expect;
 # always flush
 $| = 1;
 
-my $invocation_dir = getcwd();
+my $invocation_dir = $ENV{PWD} || getcwd();
 
 ## Configuration file handling
 
@@ -83,9 +83,10 @@ my @cfgs;
     # when a script is run as "novaboot <options> <script>" then $ARGV[0]
     # contains the first option. Hence the -f check.
     my $dir = File::Spec->rel2abs($ARGV[0] && -f $ARGV[0] ? dirname($ARGV[0]) : '', $invocation_dir);
-    while (-d $dir && $dir ne "/") {
+    while ((-d $dir || -l $dir ) && $dir ne "/") {
        push @cfgs, "$dir/.novaboot" if -r "$dir/.novaboot";
-       $dir = abs_path($dir."/..");
+       my @dirs = File::Spec->splitdir($dir);
+       $dir = File::Spec->catdir(@dirs[0..$#dirs-1]);
     }
 }
 my $cfg = $ENV{'NOVABOOT_CONFIG'};
index 0220f256534e20dac8f373889047ce7872acc730..4d8f2b1910732c3c7139f9c4752d9a7c88ad7780 100755 (executable)
@@ -53,6 +53,15 @@ echo '1;' > .novaboot
 WVPASS sh -c "./script --gen-only 2> log"
 WVPASS grep "novaboot: Read $PWD/.novaboot" log
 
+WVSTART Configuration files in symlinked directories
+mkdir config
+echo '1;' > config/.novaboot
+mkdir script
+( cd script; create_dummy )
+ln -s ../script config
+WVPASS sh -c "./config/script/script --gen-only 2> log"
+WVPASS grep "novaboot: Read $PWD/config/.novaboot" log
+
 WVSTART Builddir configuration variable
 WVPASS mkdir -p build
 cat > .novaboot <<'EOF'
@@ -80,7 +89,6 @@ echo '$hypervisor="HYP";' > .novaboot
 WVPASS ./script --gen-only --pulsar
 WVPASS grep "exec HYP" config-novaboot
 
-
 exit
 
 # Broken