testutils: newNS() works in a rootless user namespace

When running in a user namespace created by an unprivileged user the
owner of /var/run will be reported as the unknown user (as defined in
/proc/sys/kernel/overflowuid) so any access to the directory will
fail.

If the XDG_RUNTIME_DIR environment variable is set, check whether the
current user is also the owner of /var/run.  If the owner is different
than the current user, use the $XDG_RUNTIME_DIR/netns directory.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2019-10-17 13:20:32 +02:00
parent 411d060b81
commit 85083ea434
3 changed files with 26 additions and 3 deletions

View File

@ -1,6 +1,6 @@
language: go
sudo: required
dist: trusty
dist: xenial
go:
- 1.11.x