mirror of
https://git.yoctoproject.org/poky
synced 2026-04-21 03:32:12 +02:00
systemd: Simplify mount error patch
As mentioned during review, this patch can be less invasive and hence easier to maintain. Improve as such. (From OE-Core rev: 3a1bd768e62a493aa73e82f5c443ca28b108af51) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -36,10 +36,10 @@ systemd 247 and above plus kernel v5.7 or older will need this.
|
||||
Upstream-Status: Denied [https://github.com/systemd/systemd/issues/16896]
|
||||
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
|
||||
|
||||
diff --git a/src/core/namespace.c b/src/core/namespace.c
|
||||
index cdf427a6ea93..f8fc33a89fc2 100644
|
||||
--- a/src/core/namespace.c
|
||||
+++ b/src/core/namespace.c
|
||||
Index: git/src/core/namespace.c
|
||||
===================================================================
|
||||
--- git.orig/src/core/namespace.c
|
||||
+++ git/src/core/namespace.c
|
||||
@@ -4,7 +4,9 @@
|
||||
#include <linux/loop.h>
|
||||
#include <sched.h>
|
||||
@@ -50,11 +50,9 @@ index cdf427a6ea93..f8fc33a89fc2 100644
|
||||
#include <unistd.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
@@ -859,14 +861,34 @@ static int mount_sysfs(const MountEntry *m) {
|
||||
}
|
||||
@@ -860,13 +862,32 @@ static int mount_sysfs(const MountEntry
|
||||
|
||||
static int mount_procfs(const MountEntry *m, const NamespaceInfo *ns_info) {
|
||||
+ _cleanup_free_ char *opts = NULL;
|
||||
const char *entry_path;
|
||||
- int r;
|
||||
+ int r, major, minor;
|
||||
@@ -86,41 +84,14 @@ index cdf427a6ea93..f8fc33a89fc2 100644
|
||||
/* Mount a new instance, so that we get the one that matches our user namespace, if we are running in
|
||||
* one. i.e we don't reuse existing mounts here under any condition, we want a new instance owned by
|
||||
* our user namespace and with our hidepid= settings applied. Hence, let's get rid of everything
|
||||
@@ -875,9 +897,8 @@ static int mount_procfs(const MountEntry *m, const NamespaceInfo *ns_info) {
|
||||
@@ -875,8 +896,8 @@ static int mount_procfs(const MountEntry
|
||||
(void) mkdir_p_label(entry_path, 0755);
|
||||
(void) umount_recursive(entry_path, 0);
|
||||
|
||||
- if (ns_info->protect_proc != PROTECT_PROC_DEFAULT ||
|
||||
- ns_info->proc_subset != PROC_SUBSET_ALL) {
|
||||
- _cleanup_free_ char *opts = NULL;
|
||||
+ if (!old && (ns_info->protect_proc != PROTECT_PROC_DEFAULT ||
|
||||
+ ns_info->proc_subset != PROC_SUBSET_ALL)) {
|
||||
_cleanup_free_ char *opts = NULL;
|
||||
|
||||
/* Starting with kernel 5.8 procfs' hidepid= logic is truly per-instance (previously it
|
||||
* pretended to be per-instance but actually was per-namespace), hence let's make use of it
|
||||
@@ -891,21 +912,9 @@ static int mount_procfs(const MountEntry *m, const NamespaceInfo *ns_info) {
|
||||
ns_info->proc_subset == PROC_SUBSET_PID ? ",subset=pid" : "");
|
||||
if (!opts)
|
||||
return -ENOMEM;
|
||||
-
|
||||
- r = mount_nofollow_verbose(LOG_DEBUG, "proc", entry_path, "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, opts);
|
||||
- if (r < 0) {
|
||||
- if (r != -EINVAL)
|
||||
- return r;
|
||||
-
|
||||
- /* If this failed with EINVAL then this likely means the textual hidepid= stuff is
|
||||
- * not supported by the kernel, and thus the per-instance hidepid= neither, which
|
||||
- * means we really don't want to use it, since it would affect our host's /proc
|
||||
- * mount. Hence let's gracefully fallback to a classic, unrestricted version. */
|
||||
- } else
|
||||
- return 1;
|
||||
}
|
||||
|
||||
- r = mount_nofollow_verbose(LOG_DEBUG, "proc", entry_path, "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
|
||||
+ r = mount_nofollow_verbose(LOG_DEBUG, "proc", entry_path, "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, opts);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user