source: mod_gnutls/test/netns_py.bash @ 0f52d48

Last change on this file since 0f52d48 was 5d5a7c8, checked in by Fiona Klute <fiona.klute@…>, 16 months ago

netns_py.bash: Fix Python command line without namespaces

The previous version concatenated all arguments into one, breaking the
Python call.

  • Property mode set to 100755
File size: 1.1 KB
3# If USE_TEST_NAMESPACE is set and MGS_NETNS_ACTIVE is not, exec into
4# the Python interpreter with the given parameters inside a new
5# namespace with active loopback interface and MGS_NETNS_ACTIVE
6# defined.
8# This script can be used to isolate each testcase inside its own
9# network namespace. If USE_TEST_NAMESPACE is empty or unset this
10# script just execs into Python, so tests do not need to distinguish
11# whether to use namespaces (unless they have a separate reason to).
13# Note that once the network is up, the exec call is wrapped in
14# another user namespace to get rid of pseudo "root" access. The
15# reason for this is that Apache tries to switch permissions to a
16# non-root user when apparently started as root, and fails because no
17# such user exists inside the namespace. Changing to a non-root user
18# beforehand avoids the issue.
20if [ -n "${USE_TEST_NAMESPACE}" ] && [ -z "${MGS_NETNS_ACTIVE}" ]; then
21    exec "${UNSHARE}" --net --ipc -r /bin/bash -c \
22         "export MGS_NETNS_ACTIVE=1; ip link set up lo; exec ${UNSHARE} --user ${PYTHON} ${*}"
24    exec ${PYTHON} "${@}"
Note: See TracBrowser for help on using the repository browser.