chiark / gitweb /
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)
committerSven Eden <yamakuzure@gmx.net>
Wed, 5 Jul 2017 06:50:55 +0000 (08:50 +0200)
commit70cec624a0e54f3c35aff781645b07452fc32596
treea088cea6dbdd3125fcc1070f1bc4c478534f69d5
parentfb3aeda07e139f87c787fab2e2d0bd8bf97aa3a5
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.

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