Compare commits

..

4 Commits

Author SHA1 Message Date
Lennart Poettering 1016f67a60 test-namespace: tweak log message a bit 2024-11-22 23:02:59 +01:00
Lennart Poettering 35dd1b27bd virt: make use of ns inode check in running_in_userns() and running_in_cgroupns() too 2024-11-22 23:02:59 +01:00
Luca Boccassi d2b23cdc1a detect-virt: check the inode number of the pid namespace
The indoe number of root pid namespace is hardcoded in the kernel to
0xEFFFFFFC since 3.8, so check the inode number of our pid namespace
if all else fails. If it's not 0xEFFFFFFC then we are in a pid
namespace, hence a container environment.

Fixes https://github.com/systemd/systemd/issues/35249

[Reworked by Lennart, to make use of namespace_is_init()]
2024-11-22 23:02:59 +01:00
Lennart Poettering 213051b29e namespace-util: add generic namespace_is_init() call 2024-11-22 23:02:59 +01:00
1 changed files with 1 additions and 1 deletions

View File

@ -221,7 +221,7 @@ TEST(namespace_is_init) {
if (r == -EBADR)
log_info_errno(r, "In root namespace of type '%s': don't know", namespace_info[t].proc_name);
else {
ASSERT_OK(r);
assert_se(r >= 0);
log_info("In root namespace of type '%s': %s", namespace_info[t].proc_name, yes_no(r));
}
}