chiark / gitweb /
test: Use stunt pipes and ipif shell script for netlink
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 10 Oct 2019 23:30:22 +0000 (00:30 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 12 Oct 2019 22:29:26 +0000 (23:29 +0100)
The overall effect is that now secnet crashes as soon as invoke
completes (ie, immediately) because there's no writer for the netlink
pipe.  This is good.  Also we no longer need "really".

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
.gitignore
test/invoke

index b124db078e2d6988528edcba35ecf731caa141f7..d597aa5e42cc3e74e1874654e9db63938e857694 100644 (file)
@@ -37,3 +37,4 @@ test-example/bogus-setup-request
 build-stamp
 
 test/*.conf
+test/*.fake-userv
index ef66106fc79841b9b6a4989398a6e6d08e295d72..69aa0da67b63cf999dcf60db6cb00db5c459e59f 100755 (executable)
@@ -26,9 +26,29 @@ proc mkconf {which} {
     global netlink
     global ports
     global extra
+    global netlinkfh
+    set pipefp test/$which.netlink
+    foreach tr {t r} {
+       file delete $pipefp.$tr
+       exec mkfifo -m600 $pipefp.$tr
+       set netlinkfh($which.$tr) [set fh [open $pipefp.$tr r+]]
+       fconfigure $fh -blocking 0 -buffering none -translation binary
+    }
+    fileevent $netlinkfh($which.t) readable [list netlink-readable $which]
+    set fakeuf test/$which.fake-userv
+    set fakeuh [open $fakeuf w 0755]
+    puts $fakeuh "#!/bin/sh
+set -e
+cat >$pipefp.t &
+exec 3<>$pipefp.r
+exec <$pipefp.r
+exec 3<&-
+exec cat
+"
     set cfg "
-       netlink tun {
-           name \"netlink-tun\";
+       netlink userv-ipif {
+           name \"netlink\";
+            userv-path \"$fakeuf\";
        $netlink($which)
            mtu 1400;
            buffer sysbuffer(2048);
@@ -57,7 +77,6 @@ proc mkconf {which} {
            class "info","notice","warning","error","security","fatal";
        };
        system {
-           userid "secnet";
        };
        resolver adns {
        };
@@ -76,10 +95,10 @@ proc spawn-secnet {which} {
     set ch [open $cf w]
     puts $ch [mkconf $which]
     close $ch
-    set argl [list ./secnet -dvnc $cf]
+    set argl [list -dvnc $cf]
     set pid [fork]
     if {!$pid} {
-       execl really $argl
+       execl ./secnet $argl
     }
 }