Merge branch 'dev_ppw252' into 'mainline-23.05'

lxc: show network config of unprivileged containers (PPW-285)

See merge request prpl-foundation/prplos/feeds/feed_opensource!6
This commit is contained in:
Matthias Franck
2024-12-19 15:45:56 +00:00

View File

@@ -0,0 +1,21 @@
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 5b4610333..748f663b8 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -2251,12 +2251,15 @@ static inline bool enter_net_ns(struct lxc_container *c)
if (pid < 0)
return false;
+ if(!switch_to_ns(pid, "net"))
+ return false;
+
if ((geteuid() != 0 || (c->lxc_conf && !list_empty(&c->lxc_conf->id_map))) &&
(access("/proc/self/ns/user", F_OK) == 0))
if (!switch_to_ns(pid, "user"))
return false;
- return switch_to_ns(pid, "net");
+ return true;
}
/* Used by qsort and bsearch functions for comparing names. */