1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| | # SPDX-License-Identifier: GPL-2.0-or-later
#
# PASST - Plug A Simple Socket Transport
# for qemu/UNIX domain socket mode
#
# PASTA - Pack A Subtle Tap Abstraction
# for network namespace/tap device mode
#
# test/pasta_options/dns_host_follow - Check that we follow host's resolv.conf
htools unshare mount grep
test Host nameserver follows changes to resolv.conf
set DIR __STATEDIR__/resolv
set LOG_FILE __STATEDIR__/resolv.log
set DONE __STATEDIR__/resolv.done
passt unshare -rUm
passt mkdir -p __DIR__/upper __DIR__/work
passt mount -t overlay -o lowerdir=/etc,upperdir=__DIR__/upper,workdir=__DIR__/work none /etc
passt echo "nameserver 192.0.2.1" > /etc/r && mv /etc/r /etc/resolv.conf
passt ./pasta -d -l __LOG_FILE__ --dns-forward 192.0.2.53 -- sh -c 'while [ ! -e __DONE__ ]; do sleep 0.1; done' 2>/dev/null &
sleep 1
passt echo "nameserver 192.0.2.2" > /etc/r && mv /etc/r /etc/resolv.conf
sleep 1
check grep -q "new host nameserver 192.0.2.2" __LOG_FILE__
test Host nameserver removed from resolv.conf is forgotten
passt echo "nameserver 2001:db8::1" > /etc/r && mv /etc/r /etc/resolv.conf
sleep 1
passt touch __DONE__ && wait
check grep -q "removed nameserver 192.0.2.2" __LOG_FILE__
test Host nameserver follows changes to resolv.conf in passt mode
set PASST_LOG __STATEDIR__/resolv_passt.log
set PIDFILE __STATEDIR__/resolv_passt.pid
passt echo "nameserver 192.0.2.1" > /etc/r && mv /etc/r /etc/resolv.conf
passt ./passt -d -l __PASST_LOG__ -P __PIDFILE__ -s __STATEDIR__/resolv.sock --dns-forward 192.0.2.53
passt echo "nameserver 192.0.2.2" > /etc/r && mv /etc/r /etc/resolv.conf
sleep 1
passt echo "nameserver 2001:db8::1" > /etc/r && mv /etc/r /etc/resolv.conf
sleep 1
passt kill $(cat __PIDFILE__)
passt umount /etc
passt exit
check grep -q "new host nameserver 192.0.2.2" __PASST_LOG__
check grep -q "removed nameserver 192.0.2.2" __PASST_LOG__
|