diff options
author | Chen Qi <Qi.Chen@windriver.com> | 2023-11-07 00:05:57 -0800 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-11-11 08:23:01 -1000 |
commit | 8134b3dd7b5c835d33712fd15255384397cc975c (patch) | |
tree | f732965c6550becb7597cc7cd8900896388f2907 | |
parent | 155c80d7edc71ff22bdb9ba6f74184f25f60b2fa (diff) | |
download | poky-8134b3dd7b5c835d33712fd15255384397cc975c.tar.gz |
systemd: backport patch to fix warning in systemd-vconsole-setup
The backported patch fixes the following warning:
systemd-vconsole-setup[221]: Failed to import credentials, ignoring: No such file or directory
(From OE-Core rev: 07c31cd6190476d9d9a4de750a30fe0fb3a93b21)
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r-- | meta/recipes-core/systemd/systemd/0001-shared-creds-util-return-0-for-missing-creds-in-read.patch | 139 | ||||
-rw-r--r-- | meta/recipes-core/systemd/systemd_253.1.bb | 1 |
2 files changed, 140 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-shared-creds-util-return-0-for-missing-creds-in-read.patch b/meta/recipes-core/systemd/systemd/0001-shared-creds-util-return-0-for-missing-creds-in-read.patch new file mode 100644 index 0000000000..953afd20b4 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0001-shared-creds-util-return-0-for-missing-creds-in-read.patch | |||
@@ -0,0 +1,139 @@ | |||
1 | From 78fc42be73d81ff625f6479784ce1950bd4741b3 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl> | ||
3 | Date: Tue, 25 Apr 2023 17:58:34 +0200 | ||
4 | Subject: [PATCH] shared/creds-util: return 0 for missing creds in | ||
5 | read_credential_strings_many | ||
6 | |||
7 | Realistically, the only thing that the caller can do is ignore failures related | ||
8 | to missing credentials. If the caller requires some credentials to be present, | ||
9 | they should just check which output variables are not NULL. One of the callers | ||
10 | was already doing that, and the other wanted to, but missed -ENOENT. By | ||
11 | suppressing -ENOENT and -ENXIO, both callers are simplified. | ||
12 | |||
13 | Fixes a warning at boot: | ||
14 | systemd-vconsole-setup[221]: Failed to import credentials, ignoring: No such file or directory | ||
15 | |||
16 | (cherry picked from commit 55ace8e5c58441d1a2c64b297a38b232ef0c0e28) | ||
17 | |||
18 | Upstream-Status: Backport [1575f1d9e78ab44beedd4eae4af3a14d45312d76] | ||
19 | |||
20 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
21 | --- | ||
22 | src/resolve/resolved-conf.c | 7 +++---- | ||
23 | src/shared/creds-util.c | 18 +++++++++++------- | ||
24 | src/test/test-creds.c | 8 ++++---- | ||
25 | src/vconsole/vconsole-setup.c | 2 +- | ||
26 | 4 files changed, 19 insertions(+), 16 deletions(-) | ||
27 | |||
28 | diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c | ||
29 | index d6929984e9..52e65caffa 100644 | ||
30 | --- a/src/resolve/resolved-conf.c | ||
31 | +++ b/src/resolve/resolved-conf.c | ||
32 | @@ -476,10 +476,9 @@ static void read_credentials(Manager *m) { | ||
33 | if (!m->read_resolv_conf) | ||
34 | return; | ||
35 | |||
36 | - r = read_credential_strings_many( | ||
37 | - "network.dns", &dns, | ||
38 | - "network.search_domains", &domains); | ||
39 | - if (r < 0 && !IN_SET(r, -ENXIO, -ENOENT)) | ||
40 | + r = read_credential_strings_many("network.dns", &dns, | ||
41 | + "network.search_domains", &domains); | ||
42 | + if (r < 0) | ||
43 | log_warning_errno(r, "Failed to read credentials, ignoring: %m"); | ||
44 | |||
45 | if (dns) { | ||
46 | diff --git a/src/shared/creds-util.c b/src/shared/creds-util.c | ||
47 | index 750ee2571e..617bae4205 100644 | ||
48 | --- a/src/shared/creds-util.c | ||
49 | +++ b/src/shared/creds-util.c | ||
50 | @@ -96,17 +96,21 @@ int read_credential_strings_many_internal( | ||
51 | |||
52 | /* Reads a bunch of credentials into the specified buffers. If the specified buffers are already | ||
53 | * non-NULL frees them if a credential is found. Only supports string-based credentials | ||
54 | - * (i.e. refuses embedded NUL bytes) */ | ||
55 | + * (i.e. refuses embedded NUL bytes). | ||
56 | + * | ||
57 | + * 0 is returned when some or all credentials are missing. | ||
58 | + */ | ||
59 | |||
60 | if (!first_name) | ||
61 | return 0; | ||
62 | |||
63 | r = read_credential(first_name, &b, NULL); | ||
64 | - if (r == -ENXIO) /* no creds passed at all? propagate this */ | ||
65 | - return r; | ||
66 | - if (r < 0) | ||
67 | - ret = r; | ||
68 | - else | ||
69 | + if (r == -ENXIO) /* No creds passed at all? Bail immediately. */ | ||
70 | + return 0; | ||
71 | + if (r < 0) { | ||
72 | + if (r != -ENOENT) | ||
73 | + ret = r; | ||
74 | + } else | ||
75 | free_and_replace(*first_value, b); | ||
76 | |||
77 | va_list ap; | ||
78 | @@ -127,7 +131,7 @@ int read_credential_strings_many_internal( | ||
79 | |||
80 | r = read_credential(name, &bb, NULL); | ||
81 | if (r < 0) { | ||
82 | - if (ret >= 0) | ||
83 | + if (ret >= 0 && r != -ENOENT) | ||
84 | ret = r; | ||
85 | } else | ||
86 | free_and_replace(*value, bb); | ||
87 | diff --git a/src/test/test-creds.c b/src/test/test-creds.c | ||
88 | index 44022e7324..25b0c34a59 100644 | ||
89 | --- a/src/test/test-creds.c | ||
90 | +++ b/src/test/test-creds.c | ||
91 | @@ -16,7 +16,7 @@ TEST(read_credential_strings) { | ||
92 | if (e) | ||
93 | assert_se(saved = strdup(e)); | ||
94 | |||
95 | - assert_se(read_credential_strings_many("foo", &x, "bar", &y) == -ENXIO); | ||
96 | + assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0); | ||
97 | assert_se(x == NULL); | ||
98 | assert_se(y == NULL); | ||
99 | |||
100 | @@ -24,20 +24,20 @@ TEST(read_credential_strings) { | ||
101 | |||
102 | assert_se(setenv("CREDENTIALS_DIRECTORY", tmp, /* override= */ true) >= 0); | ||
103 | |||
104 | - assert_se(read_credential_strings_many("foo", &x, "bar", &y) == -ENOENT); | ||
105 | + assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0); | ||
106 | assert_se(x == NULL); | ||
107 | assert_se(y == NULL); | ||
108 | |||
109 | assert_se(p = path_join(tmp, "bar")); | ||
110 | assert_se(write_string_file(p, "piff", WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_AVOID_NEWLINE) >= 0); | ||
111 | |||
112 | - assert_se(read_credential_strings_many("foo", &x, "bar", &y) == -ENOENT); | ||
113 | + assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0); | ||
114 | assert_se(x == NULL); | ||
115 | assert_se(streq(y, "piff")); | ||
116 | |||
117 | assert_se(write_string_file(p, "paff", WRITE_STRING_FILE_TRUNCATE|WRITE_STRING_FILE_AVOID_NEWLINE) >= 0); | ||
118 | |||
119 | - assert_se(read_credential_strings_many("foo", &x, "bar", &y) == -ENOENT); | ||
120 | + assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0); | ||
121 | assert_se(x == NULL); | ||
122 | assert_se(streq(y, "piff")); | ||
123 | |||
124 | diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c | ||
125 | index 7d3e9db73f..b2676eb487 100644 | ||
126 | --- a/src/vconsole/vconsole-setup.c | ||
127 | +++ b/src/vconsole/vconsole-setup.c | ||
128 | @@ -442,7 +442,7 @@ int main(int argc, char **argv) { | ||
129 | "vconsole.font", &vc_font, | ||
130 | "vconsole.font_map", &vc_font_map, | ||
131 | "vconsole.font_unimap", &vc_font_unimap); | ||
132 | - if (r < 0 && r != -ENXIO) | ||
133 | + if (r < 0) | ||
134 | log_warning_errno(r, "Failed to import credentials, ignoring: %m"); | ||
135 | |||
136 | /* Load data from configuration file (middle priority) */ | ||
137 | -- | ||
138 | 2.42.0 | ||
139 | |||
diff --git a/meta/recipes-core/systemd/systemd_253.1.bb b/meta/recipes-core/systemd/systemd_253.1.bb index f306765168..3d8e2b4816 100644 --- a/meta/recipes-core/systemd/systemd_253.1.bb +++ b/meta/recipes-core/systemd/systemd_253.1.bb | |||
@@ -25,6 +25,7 @@ SRC_URI += " \ | |||
25 | file://0002-binfmt-Don-t-install-dependency-links-at-install-tim.patch \ | 25 | file://0002-binfmt-Don-t-install-dependency-links-at-install-tim.patch \ |
26 | file://0008-implment-systemd-sysv-install-for-OE.patch \ | 26 | file://0008-implment-systemd-sysv-install-for-OE.patch \ |
27 | file://0004-Move-sysusers.d-sysctl.d-binfmt.d-modules-load.d-to-.patch \ | 27 | file://0004-Move-sysusers.d-sysctl.d-binfmt.d-modules-load.d-to-.patch \ |
28 | file://0001-shared-creds-util-return-0-for-missing-creds-in-read.patch \ | ||
28 | " | 29 | " |
29 | 30 | ||
30 | # patches needed by musl | 31 | # patches needed by musl |