]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/virt.h
detect-virt: add --private-users switch to check if a userns is active
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 21 Oct 2016 03:41:21 +0000 (23:41 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Oct 2016 00:12:51 +0000 (20:12 -0400)
commit299a34c11a4241f8c5832ccd5a7bc13263f8488b
treef67f997d142debec99297a095f4687f65bf7c00e
parent24597ee0e626b61f134e09b4e871449ef86b1343
detect-virt: add --private-users switch to check if a userns is active

Various things don't work when we're running in a user namespace, but it's
pretty hard to reliably detect if that is true.

A function is added which looks at /proc/self/uid_map and returns false
if the default "0 0 UINT32_MAX" is found, and true if it finds anything else.
This misses the case where an 1:1 mapping with the full range was used, but
I don't know how to distinguish this case.

'systemd-detect-virt --private-users' is very similar to
'systemd-detect-virt --chroot', but we check for a user namespace instead.
man/systemd-detect-virt.xml
man/systemd.unit.xml
src/basic/virt.c
src/basic/virt.h
src/detect-virt/detect-virt.c