summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0001-do-not-disable-buffer-in-writing-files.patch
blob: 39a975319b276f3dfef78d82a9732af1b5113389 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
From f92fd7e77ed5aab2dda01a20e6891c37f09415d3 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Fri, 1 Mar 2019 15:22:15 +0800
Subject: [PATCH] do not disable buffer in writing files

Do not disable buffer in writing files, otherwise we get
failure at boot for musl like below.

  [!!!!!!] Failed to allocate manager object.

And there will be other failures, critical or not critical.
This is specific to musl.

Upstream-Status: Inappropriate [musl]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
[Rebased for v242]
Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
[rebased for systemd 243]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>

---
 src/basic/cgroup-util.c                 | 10 +++++-----
 src/basic/procfs-util.c                 |  4 ++--
 src/basic/smack-util.c                  |  2 +-
 src/basic/util.c                        |  2 +-
 src/binfmt/binfmt.c                     |  6 +++---
 src/core/main.c                         |  4 ++--
 src/core/smack-setup.c                  |  8 ++++----
 src/hibernate-resume/hibernate-resume.c |  2 +-
 src/libsystemd/sd-device/sd-device.c    |  2 +-
 src/login/logind-dbus.c                 |  2 +-
 src/nspawn/nspawn-cgroup.c              |  2 +-
 src/nspawn/nspawn.c                     |  6 +++---
 src/shared/cgroup-setup.c               |  4 ++--
 src/shared/sysctl-util.c                |  2 +-
 src/sleep/sleep.c                       |  8 ++++----
 src/udev/udevadm-trigger.c              |  2 +-
 src/udev/udevd.c                        |  2 +-
 src/vconsole/vconsole-setup.c           |  2 +-
 18 files changed, 35 insertions(+), 35 deletions(-)

Index: systemd-stable/src/basic/cgroup-util.c
===================================================================
--- systemd-stable.orig/src/basic/cgroup-util.c
+++ systemd-stable/src/basic/cgroup-util.c
@@ -769,7 +769,7 @@ int cg_install_release_agent(const char
 
         sc = strstrip(contents);
         if (isempty(sc)) {
-                r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER);
+                r = write_string_file(fs, agent, 0);
                 if (r < 0)
                         return r;
         } else if (!path_equal(sc, agent))
@@ -787,7 +787,7 @@ int cg_install_release_agent(const char
 
         sc = strstrip(contents);
         if (streq(sc, "0")) {
-                r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER);
+                r = write_string_file(fs, "1", 0);
                 if (r < 0)
                         return r;
 
@@ -814,7 +814,7 @@ int cg_uninstall_release_agent(const cha
         if (r < 0)
                 return r;
 
-        r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file(fs, "0", 0);
         if (r < 0)
                 return r;
 
@@ -824,7 +824,7 @@ int cg_uninstall_release_agent(const cha
         if (r < 0)
                 return r;
 
-        r = write_string_file(fs, "", WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file(fs, "", 0);
         if (r < 0)
                 return r;
 
@@ -1656,7 +1656,7 @@ int cg_set_attribute(const char *control
         if (r < 0)
                 return r;
 
-        return write_string_file(p, value, WRITE_STRING_FILE_DISABLE_BUFFER);
+        return write_string_file(p, value, 0);
 }
 
 int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) {
Index: systemd-stable/src/basic/procfs-util.c
===================================================================
--- systemd-stable.orig/src/basic/procfs-util.c
+++ systemd-stable/src/basic/procfs-util.c
@@ -86,13 +86,13 @@ int procfs_tasks_set_limit(uint64_t limi
          * decrease it, as threads-max is the much more relevant sysctl. */
         if (limit > pid_max-1) {
                 sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */
-                r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER);
+                r = write_string_file("/proc/sys/kernel/pid_max", buffer, 0);
                 if (r < 0)
                         return r;
         }
 
         sprintf(buffer, "%" PRIu64, limit);
-        r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/proc/sys/kernel/threads-max", buffer, 0);
         if (r < 0) {
                 uint64_t threads_max;
 
Index: systemd-stable/src/basic/smack-util.c
===================================================================
--- systemd-stable.orig/src/basic/smack-util.c
+++ systemd-stable/src/basic/smack-util.c
@@ -114,7 +114,7 @@ int mac_smack_apply_pid(pid_t pid, const
                 return 0;
 
         p = procfs_file_alloca(pid, "attr/current");
-        r = write_string_file(p, label, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file(p, label, 0);
         if (r < 0)
                 return r;
 
Index: systemd-stable/src/basic/util.c
===================================================================
--- systemd-stable.orig/src/basic/util.c
+++ systemd-stable/src/basic/util.c
@@ -267,7 +267,7 @@ void disable_coredumps(void) {
         if (detect_container() > 0)
                 return;
 
-        r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0);
         if (r < 0)
                 log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m");
 }
Index: systemd-stable/src/binfmt/binfmt.c
===================================================================
--- systemd-stable.orig/src/binfmt/binfmt.c
+++ systemd-stable/src/binfmt/binfmt.c
@@ -48,7 +48,7 @@ static int delete_rule(const char *rule)
         if (!fn)
                 return log_oom();
 
-        return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER);
+        return write_string_file(fn, "-1", 0);
 }
 
 static int apply_rule(const char *rule) {
@@ -56,7 +56,7 @@ static int apply_rule(const char *rule)
 
         (void) delete_rule(rule);
 
-        r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0);
         if (r < 0)
                 return log_error_errno(r, "Failed to add binary format: %m");
 
@@ -223,7 +223,7 @@ static int run(int argc, char *argv[]) {
                 }
 
                 /* Flush out all rules */
-                (void) write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER);
+                (void) write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0);
 
                 STRV_FOREACH(f, files) {
                         k = apply_file(*f, true);
Index: systemd-stable/src/core/main.c
===================================================================
--- systemd-stable.orig/src/core/main.c
+++ systemd-stable/src/core/main.c
@@ -1382,7 +1382,7 @@ static int bump_unix_max_dgram_qlen(void
         if (v >= DEFAULT_UNIX_MAX_DGRAM_QLEN)
                 return 0;
 
-        r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", WRITE_STRING_FILE_DISABLE_BUFFER, "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN);
+        r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", 0, "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN);
         if (r < 0)
                 return log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
                                       "Failed to bump AF_UNIX datagram queue length, ignoring: %m");
@@ -1668,7 +1668,7 @@ static void initialize_core_pattern(bool
         if (getpid_cached() != 1)
                 return;
 
-        r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, 0);
         if (r < 0)
                 log_warning_errno(r, "Failed to write '%s' to /proc/sys/kernel/core_pattern, ignoring: %m", arg_early_core_pattern);
 }
Index: systemd-stable/src/core/smack-setup.c
===================================================================
--- systemd-stable.orig/src/core/smack-setup.c
+++ systemd-stable/src/core/smack-setup.c
@@ -325,17 +325,17 @@ int mac_smack_setup(bool *loaded_policy)
         }
 
 #ifdef SMACK_RUN_LABEL
-        r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0);
         if (r < 0)
                 log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m");
-        r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, 0);
         if (r < 0)
                 log_warning_errno(r, "Failed to set SMACK ambient label \"" SMACK_RUN_LABEL "\": %m");
         r = write_string_file("/sys/fs/smackfs/netlabel",
-                              "0.0.0.0/0 " SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER);
+                              "0.0.0.0/0 " SMACK_RUN_LABEL, 0);
         if (r < 0)
                 log_warning_errno(r, "Failed to set SMACK netlabel rule \"0.0.0.0/0 " SMACK_RUN_LABEL "\": %m");
-        r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", 0);
         if (r < 0)
                 log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m");
 #endif
Index: systemd-stable/src/hibernate-resume/hibernate-resume.c
===================================================================
--- systemd-stable.orig/src/hibernate-resume/hibernate-resume.c
+++ systemd-stable/src/hibernate-resume/hibernate-resume.c
@@ -45,7 +45,7 @@ int main(int argc, char *argv[]) {
                 return EXIT_FAILURE;
         }
 
-        r = write_string_file("/sys/power/resume", major_minor, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/sys/power/resume", major_minor, 0);
         if (r < 0) {
                 log_error_errno(r, "Failed to write '%s' to /sys/power/resume: %m", major_minor);
                 return EXIT_FAILURE;
Index: systemd-stable/src/libsystemd/sd-device/sd-device.c
===================================================================
--- systemd-stable.orig/src/libsystemd/sd-device/sd-device.c
+++ systemd-stable/src/libsystemd/sd-device/sd-device.c
@@ -1877,7 +1877,7 @@ _public_ int sd_device_set_sysattr_value
         if (!value)
                 return -ENOMEM;
 
-        r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW);
+        r = write_string_file(path, value, 0 | WRITE_STRING_FILE_NOFOLLOW);
         if (r < 0) {
                 if (r == -ELOOP)
                         return -EINVAL;
Index: systemd-stable/src/login/logind-dbus.c
===================================================================
--- systemd-stable.orig/src/login/logind-dbus.c
+++ systemd-stable/src/login/logind-dbus.c
@@ -1341,7 +1341,7 @@ static int trigger_device(Manager *m, sd
                 if (!t)
                         return -ENOMEM;
 
-                (void) write_string_file(t, "change", WRITE_STRING_FILE_DISABLE_BUFFER);
+                (void) write_string_file(t, "change", 0);
         }
 
         return 0;
Index: systemd-stable/src/nspawn/nspawn-cgroup.c
===================================================================
--- systemd-stable.orig/src/nspawn/nspawn-cgroup.c
+++ systemd-stable/src/nspawn/nspawn-cgroup.c
@@ -124,7 +124,7 @@ int sync_cgroup(pid_t pid, CGroupUnified
         fn = strjoina(tree, cgroup, "/cgroup.procs");
 
         sprintf(pid_string, PID_FMT, pid);
-        r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755);
+        r = write_string_file(fn, pid_string, WRITE_STRING_FILE_MKDIR_0755);
         if (r < 0) {
                 log_error_errno(r, "Failed to move process: %m");
                 goto finish;
Index: systemd-stable/src/nspawn/nspawn.c
===================================================================
--- systemd-stable.orig/src/nspawn/nspawn.c
+++ systemd-stable/src/nspawn/nspawn.c
@@ -2493,7 +2493,7 @@ static int reset_audit_loginuid(void) {
         if (streq(p, "4294967295"))
                 return 0;
 
-        r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/proc/self/loginuid", "4294967295", 0);
         if (r < 0) {
                 log_error_errno(r,
                                 "Failed to reset audit login UID. This probably means that your kernel is too\n"
@@ -3726,13 +3726,13 @@ static int setup_uid_map(pid_t pid) {
 
         xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid);
         xsprintf(line, UID_FMT " " UID_FMT " " UID_FMT "\n", 0, arg_uid_shift, arg_uid_range);
-        r = write_string_file(uid_map, line, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file(uid_map, line, 0);
         if (r < 0)
                 return log_error_errno(r, "Failed to write UID map: %m");
 
         /* We always assign the same UID and GID ranges */
         xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid);
-        r = write_string_file(uid_map, line, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file(uid_map, line, 0);
         if (r < 0)
                 return log_error_errno(r, "Failed to write GID map: %m");
 
Index: systemd-stable/src/shared/cgroup-setup.c
===================================================================
--- systemd-stable.orig/src/shared/cgroup-setup.c
+++ systemd-stable/src/shared/cgroup-setup.c
@@ -267,7 +267,7 @@ int cg_attach(const char *controller, co
 
         xsprintf(c, PID_FMT "\n", pid);
 
-        r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file(fs, c, 0);
         if (r < 0)
                 return r;
 
@@ -817,7 +817,7 @@ int cg_enable_everywhere(
                                         return log_debug_errno(errno, "Failed to open cgroup.subtree_control file of %s: %m", p);
                         }
 
-                        r = write_string_stream(f, s, WRITE_STRING_FILE_DISABLE_BUFFER);
+                        r = write_string_stream(f, s, 0);
                         if (r < 0) {
                                 log_debug_errno(r, "Failed to %s controller %s for %s (%s): %m",
                                                 FLAGS_SET(mask, bit) ? "enable" : "disable", n, p, fs);
Index: systemd-stable/src/shared/sysctl-util.c
===================================================================
--- systemd-stable.orig/src/shared/sysctl-util.c
+++ systemd-stable/src/shared/sysctl-util.c
@@ -93,7 +93,7 @@ int sysctl_write_ip_property(int af, con
 
         log_debug("Setting '%s' to '%s'", p, value);
 
-        return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER);
+        return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | 0);
 }
 
 int sysctl_read(const char *property, char **content) {
Index: systemd-stable/src/sleep/sleep.c
===================================================================
--- systemd-stable.orig/src/sleep/sleep.c
+++ systemd-stable/src/sleep/sleep.c
@@ -48,7 +48,7 @@ static int write_hibernate_location_info
         assert(hibernate_location->swap);
 
         xsprintf(resume_str, "%u:%u", major(hibernate_location->devno), minor(hibernate_location->devno));
-        r = write_string_file("/sys/power/resume", resume_str, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/sys/power/resume", resume_str, 0);
         if (r < 0)
                 return log_debug_errno(r, "Failed to write partition device to /sys/power/resume for '%s': '%s': %m",
                                        hibernate_location->swap->device, resume_str);
@@ -75,7 +75,7 @@ static int write_hibernate_location_info
         }
 
         xsprintf(offset_str, "%" PRIu64, hibernate_location->offset);
-        r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/sys/power/resume_offset", offset_str, 0);
         if (r < 0)
                 return log_debug_errno(r, "Failed to write swap file offset to /sys/power/resume_offset for '%s': '%s': %m",
                                        hibernate_location->swap->device, offset_str);
@@ -92,7 +92,7 @@ static int write_mode(char **modes) {
         STRV_FOREACH(mode, modes) {
                 int k;
 
-                k = write_string_file("/sys/power/disk", *mode, WRITE_STRING_FILE_DISABLE_BUFFER);
+                k = write_string_file("/sys/power/disk", *mode, 0);
                 if (k >= 0)
                         return 0;
 
@@ -114,7 +114,7 @@ static int write_state(FILE **f, char **
         STRV_FOREACH(state, states) {
                 int k;
 
-                k = write_string_stream(*f, *state, WRITE_STRING_FILE_DISABLE_BUFFER);
+                k = write_string_stream(*f, *state, 0);
                 if (k >= 0)
                         return 0;
                 log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m", *state);
Index: systemd-stable/src/udev/udevadm-trigger.c
===================================================================
--- systemd-stable.orig/src/udev/udevadm-trigger.c
+++ systemd-stable/src/udev/udevadm-trigger.c
@@ -43,7 +43,7 @@ static int exec_list(sd_device_enumerato
                 if (!filename)
                         return log_oom();
 
-                r = write_string_file(filename, action, WRITE_STRING_FILE_DISABLE_BUFFER);
+                r = write_string_file(filename, action, 0);
                 if (r < 0) {
                         bool ignore = IN_SET(r, -ENOENT, -EACCES, -ENODEV, -EROFS);
 
Index: systemd-stable/src/udev/udevd.c
===================================================================
--- systemd-stable.orig/src/udev/udevd.c
+++ systemd-stable/src/udev/udevd.c
@@ -1153,7 +1153,7 @@ static int synthesize_change_one(sd_devi
 
         filename = strjoina(syspath, "/uevent");
         log_device_debug(dev, "device is closed, synthesising 'change' on %s", syspath);
-        r = write_string_file(filename, "change", WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file(filename, "change", 0);
         if (r < 0)
                 return log_device_debug_errno(dev, r, "Failed to write 'change' to %s: %m", filename);
         return 0;
Index: systemd-stable/src/vconsole/vconsole-setup.c
===================================================================
--- systemd-stable.orig/src/vconsole/vconsole-setup.c
+++ systemd-stable/src/vconsole/vconsole-setup.c
@@ -116,7 +116,7 @@ static int toggle_utf8_vc(const char *na
 static int toggle_utf8_sysfs(bool utf8) {
         int r;
 
-        r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), 0);
         if (r < 0)
                 return log_warning_errno(r, "Failed to %s sysfs UTF-8 flag: %m", enable_disable(utf8));