tests: Make /etc/alternatives work in VM

In recent Debian versions, ebtables is an alias managed by
the alternatives(8) mechanism. This means /usr/sbin/ebtables
is a symlink to /etc/alternatives/ebtables, which in turn
links to the real binary.

As we mount a tmpfs over /etc, we cannot access this.

Fix this by bind-mounting the real /etc to /tmp/etc and
adding a symlink from /etc/alternatives to this.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2019-02-02 23:38:35 +01:00 committed by Jouni Malinen
parent 4b1cc13914
commit e5a410f472

View file

@ -1,10 +1,13 @@
#!/bin/sh #!/bin/sh
# keep old /etc
mount tmpfs -t tmpfs /tmp
mkdir /tmp/etc
mount --bind /etc /tmp/etc
# mount all kinds of things # mount all kinds of things
mount tmpfs -t tmpfs /etc mount tmpfs -t tmpfs /etc
# we need our own /dev/rfkill, and don't want device access # we need our own /dev/rfkill, and don't want device access
mount tmpfs -t tmpfs /dev mount tmpfs -t tmpfs /dev
mount tmpfs -t tmpfs /tmp
# some sockets go into /var/run, and / is read-only # some sockets go into /var/run, and / is read-only
mount tmpfs -t tmpfs /var/run mount tmpfs -t tmpfs /var/run
mount proc -t proc /proc mount proc -t proc /proc
@ -79,6 +82,9 @@ udp 17 UDP
ipv6-icmp 58 IPv6-ICMP ipv6-icmp 58 IPv6-ICMP
EOF EOF
# we may need /etc/alternatives, at least on Debian-based systems
ln -s /tmp/etc/alternatives /etc/
# local network is needed for some tests # local network is needed for some tests
ip link set lo up ip link set lo up