summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-core/systemd/systemd/0001-basic-do-not-warn-in-mkdir_p-when-parent-directory-e.patch78
-rw-r--r--meta/recipes-core/systemd/systemd_250.14.bb1
2 files changed, 79 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-basic-do-not-warn-in-mkdir_p-when-parent-directory-e.patch b/meta/recipes-core/systemd/systemd/0001-basic-do-not-warn-in-mkdir_p-when-parent-directory-e.patch
new file mode 100644
index 0000000000..723b8ca4f7
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0001-basic-do-not-warn-in-mkdir_p-when-parent-directory-e.patch
@@ -0,0 +1,78 @@
1From e01e68e70ae1db9fe61adec3e7bdcced7adc1930 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
3Date: Thu, 10 Feb 2022 08:30:08 +0100
4Subject: [PATCH] basic: do not warn in mkdir_p() when parent directory exists
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9This effectively disables warnings about type/mode/ownership of existing
10directories when recursively creating parent directories. (Or files. If there's
11a file in a place we expect a directory, the code will later try to create
12a file and fail. This follows the general pattern where we do (void)mkdir()
13if the mkdir() is immediately followed by opening of a file.)
14
15I was recently debugging an issue with the fstab-generator [1], and it says:
16'Directory "/tmp" already exists, but has mode 0777 that is too permissive (0644 was requested), refusing.'
17which is very specific but totally wrong in this context.
18This output was added in 37c1d5e97dbc869edd8fc178427714e2d9428d2b, and I still
19think it is worth to do it, because if you actually *do* want the directory, if
20there's something wrong, the precise error message will make it much easier to
21diagnose. And we can't easily pass the information what failed up the call chain
22because there are multiple things we check (ownership, permission mask, type)…
23So passing a param whether to warn or not down into the library code seems like
24the best solution, despite not being very elegant.
25
26[1] https://bugzilla.redhat.com/show_bug.cgi?id=2051285
27
28Upstream-Status: Backport [https://github.com/systemd/systemd/commit/e01e68e70ae1db9fe61adec3e7bdcced7adc1930]
29
30Signed-off-by: Haitao Liu <haitao.liu@windriver.com>
31Signed-off-by: Kai Kang <kai.kang@windriver.com>
32---
33 src/basic/mkdir.c | 5 ++++-
34 src/basic/mkdir.h | 5 +++--
35 2 files changed, 7 insertions(+), 3 deletions(-)
36
37diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c
38index 27144dd45a..cf7cf4a357 100644
39--- a/src/basic/mkdir.c
40+++ b/src/basic/mkdir.c
41@@ -55,6 +55,9 @@ int mkdir_safe_internal(
42 return -errno;
43 }
44
45+ if (flags & MKDIR_IGNORE_EXISTING)
46+ return 0;
47+
48 if (!S_ISDIR(st.st_mode))
49 return log_full_errno(flags & MKDIR_WARN_MODE ? LOG_WARNING : LOG_DEBUG, SYNTHETIC_ERRNO(ENOTDIR),
50 "Path \"%s\" already exists and is not a directory, refusing.", path);
51@@ -142,7 +145,7 @@ int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, ui
52 s[n] = '\0';
53
54 if (!prefix || !path_startswith_full(prefix, path, /* accept_dot_dot= */ false)) {
55- r = mkdir_safe_internal(path, mode, uid, gid, flags, _mkdirat);
56+ r = mkdir_safe_internal(path, mode, uid, gid, flags | MKDIR_IGNORE_EXISTING, _mkdirat);
57 if (r < 0 && r != -EEXIST)
58 return r;
59 }
60diff --git a/src/basic/mkdir.h b/src/basic/mkdir.h
61index 34a5227577..c0c0ea6c4f 100644
62--- a/src/basic/mkdir.h
63+++ b/src/basic/mkdir.h
64@@ -4,8 +4,9 @@
65 #include <sys/types.h>
66
67 typedef enum MkdirFlags {
68- MKDIR_FOLLOW_SYMLINK = 1 << 0,
69- MKDIR_WARN_MODE = 1 << 1,
70+ MKDIR_FOLLOW_SYMLINK = 1 << 0,
71+ MKDIR_IGNORE_EXISTING = 1 << 1, /* Quietly accept a preexisting directory (or file) */
72+ MKDIR_WARN_MODE = 1 << 2, /* Log at LOG_WARNING when mode doesn't match */
73 } MkdirFlags;
74
75 int mkdirat_errno_wrapper(int dirfd, const char *pathname, mode_t mode);
76--
772.25.1
78
diff --git a/meta/recipes-core/systemd/systemd_250.14.bb b/meta/recipes-core/systemd/systemd_250.14.bb
index b79284d79c..b3e31e1f23 100644
--- a/meta/recipes-core/systemd/systemd_250.14.bb
+++ b/meta/recipes-core/systemd/systemd_250.14.bb
@@ -30,6 +30,7 @@ SRC_URI += "file://touchscreen.rules \
30 file://fix-vlan-qos-mapping.patch \ 30 file://fix-vlan-qos-mapping.patch \
31 file://0001-core-fix-build-when-seccomp-is-off.patch \ 31 file://0001-core-fix-build-when-seccomp-is-off.patch \
32 file://0001-journal-Make-sd_journal_previous-next-return-0-at-HE.patch \ 32 file://0001-journal-Make-sd_journal_previous-next-return-0-at-HE.patch \
33 file://0001-basic-do-not-warn-in-mkdir_p-when-parent-directory-e.patch \
33 " 34 "
34 35
35# patches needed by musl 36# patches needed by musl