diff options
Diffstat (limited to 'fw/test')
| -rwxr-xr-x | fw/test/fwtest.rc | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/fw/test/fwtest.rc b/fw/test/fwtest.rc index 0b923e9..a7ba4d2 100755 --- a/fw/test/fwtest.rc +++ b/fw/test/fwtest.rc @@ -104,6 +104,19 @@ fn have { echo no } +# Is it gone from the served tree? +# +# A stat, not a read. Reading /net/log, or an interface's data or snoop +# file, blocks until traffic arrives, so a check that read them would +# hang rather than fail on exactly the build that still serves them - +# and a test that hangs on a regression is worse than no test. +fn gone { + if(test -e $1) + echo there + if not + echo gone +} + # Stop the firewalls a packet check started. # # Take the interfaces away and fw follows: the relay's read fails and @@ -139,7 +152,8 @@ cat > $tmp/empty.ndb <<'!' ! echo '== namespace mode: what is refused is there to refuse' -for(p in /net/udp/clone /net/gre/clone /net/ndb /net/log /net/ipifc/0/data){ +for(p in /net/udp/clone /net/gre/clone /net/ndb /net/log /net/ipifc/0/data \ + /net/ipifc/0/snoop /net/tcp/trans /net/ether0/clone /net/ipmux/clone){ r=`{have $p} check 'the real /net has '^$p yes $"r } @@ -164,13 +178,55 @@ echo '== namespace mode' r=`{wr /net/ndb 'x'} check '/net/ndb is not writable' refused $"r - r=`{wr /net/log 'tcp'} - check '/net/log is not writable' refused $"r - - r=`{rd /net/ipifc/0/data} - check 'an interface data file is not readable' refused $"r + # trans installs a kernel address translation and devip gates it + # with iseve() -- which is fw's identity through here, not the + # caller's, so on a machine where fw runs as eve there was no gate + # at all. Opening it with truncation also flushed the table. + r=`{gone /net/tcp/trans} + check 'a protocol trans file is not served' gone $"r + r=`{wr /net/tcp/trans '10.9.9.9 80 10.9.9.8 1234 10.9.9.7 5678'} + check 'and cannot be written' refused $"r + + # reading log is the leak, not writing it: turn it on elsewhere and + # it traces every connection on the machine + r=`{gone /net/log} + check '/net/log is not served at all' gone $"r + + r=`{gone /net/ipifc/0/data} + check 'an interface data file is a wire, and is not served' gone $"r + r=`{gone /net/ipifc/0/snoop} + check 'nor is its snoop file, which is the same wire' gone $"r r=`{rd /net/ipifc/0/status} check 'but its status still is' ok $"r + + r=`{gone /net/ether0/clone} + check 'a card is not served, clone file or no' gone $"r + r=`{gone /net/ipmux/clone} + check 'nor is ipmux' gone $"r + + # The mount driver splits a path before it sends it, so this only + # asks that the obvious way out is shut; a compound name arriving + # as one walk element needs a client speaking 9P straight to the + # server, and splitpath is what refuses that. + r=`{gone '/net/tcp/../../adm/keys'} + check 'nothing outside /net resolves through it' gone $"r + + # what a program still needs + r=`{wr /net/cs 'tcp!10.9.9.9!80'} + check 'cs still translates' ok $"r + r=`{rd /net/arp} + check 'arp is still readable' ok $"r + r=`{rd /net/ndb} + check 'ndb is still readable' ok $"r + r=`{rd /net/iproute} + check 'iproute is still readable' ok $"r + + r=`{ls -p /net | grep -c '^(log|ipmux|ether0|ether1)$'} + check 'none of them are even listed' 0 $"r + r=`{ls -p /net/tcp | grep -c '^trans$'} + check 'and trans is not listed either' 0 $"r + r=`{ls -p /net/tcp | grep -c '^clone$'} + check 'while clone still is' 1 $"r } @{ |
