Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 1 | From aa6e5588e6d01c12e2f101d140cc710ab199df16 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 2 | From: Chen Qi <Qi.Chen@windriver.com> |
| 3 | Date: Fri, 1 Mar 2019 15:22:15 +0800 |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 4 | Subject: [PATCH] do not disable buffer in writing files |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5 | |
| 6 | Do not disable buffer in writing files, otherwise we get |
| 7 | failure at boot for musl like below. |
| 8 | |
| 9 | [!!!!!!] Failed to allocate manager object. |
| 10 | |
| 11 | And there will be other failures, critical or not critical. |
| 12 | This is specific to musl. |
| 13 | |
| 14 | Upstream-Status: Inappropriate [musl] |
| 15 | |
| 16 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 17 | [Rebased for v242] |
| 18 | Signed-off-by: Andrej Valek <andrej.valek@siemens.com> |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 19 | [rebased for systemd 243] |
| 20 | Signed-off-by: Scott Murray <scott.murray@konsulko.com> |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 21 | [rebased for systemd 254] |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 22 | --- |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 23 | src/basic/cgroup-util.c | 12 ++++++------ |
| 24 | src/basic/namespace-util.c | 4 ++-- |
| 25 | src/basic/procfs-util.c | 4 ++-- |
| 26 | src/basic/sysctl-util.c | 2 +- |
| 27 | src/binfmt/binfmt.c | 6 +++--- |
| 28 | src/core/cgroup.c | 2 +- |
| 29 | src/core/main.c | 2 +- |
| 30 | src/core/smack-setup.c | 8 ++++---- |
| 31 | src/home/homework.c | 2 +- |
| 32 | src/libsystemd/sd-device/sd-device.c | 2 +- |
| 33 | src/nspawn/nspawn-cgroup.c | 2 +- |
| 34 | src/nspawn/nspawn.c | 6 +++--- |
| 35 | src/shared/binfmt-util.c | 2 +- |
| 36 | src/shared/cgroup-setup.c | 4 ++-- |
| 37 | src/shared/coredump-util.c | 2 +- |
| 38 | src/shared/sleep-util.c | 4 ++-- |
| 39 | src/shared/smack-util.c | 2 +- |
| 40 | src/sleep/sleep.c | 4 ++-- |
| 41 | src/udev/udev-rules.c | 1 - |
| 42 | src/vconsole/vconsole-setup.c | 2 +- |
| 43 | 20 files changed, 36 insertions(+), 37 deletions(-) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 44 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 45 | --- a/src/basic/cgroup-util.c |
| 46 | +++ b/src/basic/cgroup-util.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 47 | @@ -400,7 +400,7 @@ int cg_kill_kernel_sigkill(const char *c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 48 | if (r < 0) |
| 49 | return r; |
| 50 | |
| 51 | - r = write_string_file(killfile, "1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 52 | + r = write_string_file(killfile, "1", 0); |
| 53 | if (r < 0) |
| 54 | return r; |
| 55 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 56 | @@ -806,7 +806,7 @@ int cg_install_release_agent(const char |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 57 | |
| 58 | sc = strstrip(contents); |
| 59 | if (isempty(sc)) { |
| 60 | - r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 61 | + r = write_string_file(fs, agent, 0); |
| 62 | if (r < 0) |
| 63 | return r; |
| 64 | } else if (!path_equal(sc, agent)) |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 65 | @@ -824,7 +824,7 @@ int cg_install_release_agent(const char |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 66 | |
| 67 | sc = strstrip(contents); |
| 68 | if (streq(sc, "0")) { |
| 69 | - r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 70 | + r = write_string_file(fs, "1", 0); |
| 71 | if (r < 0) |
| 72 | return r; |
| 73 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 74 | @@ -851,7 +851,7 @@ int cg_uninstall_release_agent(const cha |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 75 | if (r < 0) |
| 76 | return r; |
| 77 | |
| 78 | - r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 79 | + r = write_string_file(fs, "0", 0); |
| 80 | if (r < 0) |
| 81 | return r; |
| 82 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 83 | @@ -861,7 +861,7 @@ int cg_uninstall_release_agent(const cha |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 84 | if (r < 0) |
| 85 | return r; |
| 86 | |
| 87 | - r = write_string_file(fs, "", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 88 | + r = write_string_file(fs, "", 0); |
| 89 | if (r < 0) |
| 90 | return r; |
| 91 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 92 | @@ -1764,7 +1764,7 @@ int cg_set_attribute(const char *control |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 93 | if (r < 0) |
| 94 | return r; |
| 95 | |
| 96 | - return write_string_file(p, value, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 97 | + return write_string_file(p, value, 0); |
| 98 | } |
| 99 | |
| 100 | int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) { |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 101 | --- a/src/basic/namespace-util.c |
| 102 | +++ b/src/basic/namespace-util.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 103 | @@ -227,12 +227,12 @@ int userns_acquire(const char *uid_map, |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 104 | freeze(); |
| 105 | |
| 106 | xsprintf(path, "/proc/" PID_FMT "/uid_map", pid); |
| 107 | - r = write_string_file(path, uid_map, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 108 | + r = write_string_file(path, uid_map, 0); |
| 109 | if (r < 0) |
| 110 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 111 | |
| 112 | xsprintf(path, "/proc/" PID_FMT "/gid_map", pid); |
| 113 | - r = write_string_file(path, gid_map, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 114 | + r = write_string_file(path, gid_map, 0); |
| 115 | if (r < 0) |
| 116 | return log_error_errno(r, "Failed to write GID map: %m"); |
| 117 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 118 | --- a/src/basic/procfs-util.c |
| 119 | +++ b/src/basic/procfs-util.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 120 | @@ -64,13 +64,13 @@ int procfs_tasks_set_limit(uint64_t limi |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 121 | * decrease it, as threads-max is the much more relevant sysctl. */ |
| 122 | if (limit > pid_max-1) { |
| 123 | sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */ |
| 124 | - r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 125 | + r = write_string_file("/proc/sys/kernel/pid_max", buffer, 0); |
| 126 | if (r < 0) |
| 127 | return r; |
| 128 | } |
| 129 | |
| 130 | sprintf(buffer, "%" PRIu64, limit); |
| 131 | - r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 132 | + r = write_string_file("/proc/sys/kernel/threads-max", buffer, 0); |
| 133 | if (r < 0) { |
| 134 | uint64_t threads_max; |
| 135 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 136 | --- a/src/basic/sysctl-util.c |
| 137 | +++ b/src/basic/sysctl-util.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 138 | @@ -58,7 +58,7 @@ int sysctl_write(const char *property, c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 139 | |
| 140 | log_debug("Setting '%s' to '%s'", p, value); |
| 141 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 142 | - return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL); |
| 143 | + return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL); |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 146 | int sysctl_writef(const char *property, const char *format, ...) { |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 147 | --- a/src/binfmt/binfmt.c |
| 148 | +++ b/src/binfmt/binfmt.c |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 149 | @@ -30,7 +30,7 @@ static bool arg_unregister = false; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 150 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 151 | static int delete_rule(const char *rulename) { |
| 152 | const char *fn = strjoina("/proc/sys/fs/binfmt_misc/", rulename); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 153 | - return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 154 | + return write_string_file(fn, "-1", 0); |
| 155 | } |
| 156 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 157 | static int apply_rule(const char *filename, unsigned line, const char *rule) { |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 158 | @@ -58,7 +58,7 @@ static int apply_rule(const char *filena |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 159 | if (r >= 0) |
| 160 | log_debug("%s:%u: Rule '%s' deleted.", filename, line, rulename); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 161 | |
| 162 | - r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 163 | + r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0); |
| 164 | if (r < 0) |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 165 | return log_error_errno(r, "%s:%u: Failed to add binary format '%s': %m", |
| 166 | filename, line, rulename); |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 167 | @@ -244,7 +244,7 @@ static int run(int argc, char *argv[]) { |
| 168 | return r; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 169 | |
| 170 | /* Flush out all rules */ |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 171 | - r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 172 | + r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); |
| 173 | if (r < 0) |
| 174 | log_warning_errno(r, "Failed to flush binfmt_misc rules, ignoring: %m"); |
| 175 | else |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 176 | --- a/src/core/cgroup.c |
| 177 | +++ b/src/core/cgroup.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 178 | @@ -4349,7 +4349,7 @@ int unit_cgroup_freezer_action(Unit *u, |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 179 | u->freezer_state = FREEZER_THAWING; |
| 180 | } |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 181 | |
| 182 | - r = write_string_file(path, one_zero(action == FREEZER_FREEZE), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 183 | + r = write_string_file(path, one_zero(action == FREEZER_FREEZE), 0); |
| 184 | if (r < 0) |
| 185 | return r; |
| 186 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 187 | --- a/src/core/main.c |
| 188 | +++ b/src/core/main.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 189 | @@ -1737,7 +1737,7 @@ static void initialize_core_pattern(bool |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 190 | if (getpid_cached() != 1) |
| 191 | return; |
| 192 | |
| 193 | - r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 194 | + r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, 0); |
| 195 | if (r < 0) |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 196 | log_warning_errno(r, "Failed to write '%s' to /proc/sys/kernel/core_pattern, ignoring: %m", |
| 197 | arg_early_core_pattern); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 198 | --- a/src/core/smack-setup.c |
| 199 | +++ b/src/core/smack-setup.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 200 | @@ -319,17 +319,17 @@ int mac_smack_setup(bool *loaded_policy) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 201 | } |
| 202 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 203 | #if HAVE_SMACK_RUN_LABEL |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 204 | - r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 205 | + r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0); |
| 206 | if (r < 0) |
| 207 | log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m"); |
| 208 | - r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 209 | + r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, 0); |
| 210 | if (r < 0) |
| 211 | log_warning_errno(r, "Failed to set SMACK ambient label \"" SMACK_RUN_LABEL "\": %m"); |
| 212 | r = write_string_file("/sys/fs/smackfs/netlabel", |
| 213 | - "0.0.0.0/0 " SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 214 | + "0.0.0.0/0 " SMACK_RUN_LABEL, 0); |
| 215 | if (r < 0) |
| 216 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"0.0.0.0/0 " SMACK_RUN_LABEL "\": %m"); |
| 217 | - r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 218 | + r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", 0); |
| 219 | if (r < 0) |
| 220 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m"); |
| 221 | #endif |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 222 | --- a/src/home/homework.c |
| 223 | +++ b/src/home/homework.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 224 | @@ -278,7 +278,7 @@ static void drop_caches_now(void) { |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 225 | * for details. We write "2" into /proc/sys/vm/drop_caches to ensure dentries/inodes are flushed, but |
| 226 | * not more. */ |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 227 | |
| 228 | - r = write_string_file("/proc/sys/vm/drop_caches", "2\n", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 229 | + r = write_string_file("/proc/sys/vm/drop_caches", "2\n", 0); |
| 230 | if (r < 0) |
| 231 | log_warning_errno(r, "Failed to drop caches, ignoring: %m"); |
| 232 | else |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 233 | --- a/src/libsystemd/sd-device/sd-device.c |
| 234 | +++ b/src/libsystemd/sd-device/sd-device.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 235 | @@ -2515,7 +2515,7 @@ _public_ int sd_device_set_sysattr_value |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 236 | if (!value) |
| 237 | return -ENOMEM; |
| 238 | |
| 239 | - r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW); |
| 240 | + r = write_string_file(path, value, 0 | WRITE_STRING_FILE_NOFOLLOW); |
| 241 | if (r < 0) { |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 242 | /* On failure, clear cache entry, as we do not know how it fails. */ |
| 243 | device_remove_cached_sysattr_value(device, sysattr); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 244 | --- a/src/nspawn/nspawn-cgroup.c |
| 245 | +++ b/src/nspawn/nspawn-cgroup.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 246 | @@ -122,7 +122,7 @@ int sync_cgroup(pid_t pid, CGroupUnified |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 247 | fn = strjoina(tree, cgroup, "/cgroup.procs"); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 248 | |
| 249 | sprintf(pid_string, PID_FMT, pid); |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 250 | - r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755); |
| 251 | + r = write_string_file(fn, pid_string, WRITE_STRING_FILE_MKDIR_0755); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 252 | if (r < 0) { |
| 253 | log_error_errno(r, "Failed to move process: %m"); |
| 254 | goto finish; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 255 | --- a/src/nspawn/nspawn.c |
| 256 | +++ b/src/nspawn/nspawn.c |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 257 | @@ -2774,7 +2774,7 @@ static int reset_audit_loginuid(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 258 | if (streq(p, "4294967295")) |
| 259 | return 0; |
| 260 | |
| 261 | - r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 262 | + r = write_string_file("/proc/self/loginuid", "4294967295", 0); |
| 263 | if (r < 0) { |
| 264 | log_error_errno(r, |
| 265 | "Failed to reset audit login UID. This probably means that your kernel is too\n" |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 266 | @@ -4214,7 +4214,7 @@ static int setup_uid_map( |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 267 | return log_oom(); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 268 | |
| 269 | xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 270 | - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 271 | + r = write_string_file(uid_map, s, 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 272 | if (r < 0) |
| 273 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 274 | |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 275 | @@ -4224,7 +4224,7 @@ static int setup_uid_map( |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 276 | return log_oom(); |
| 277 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 278 | xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 279 | - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 280 | + r = write_string_file(uid_map, s, 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 281 | if (r < 0) |
| 282 | return log_error_errno(r, "Failed to write GID map: %m"); |
| 283 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 284 | --- a/src/shared/binfmt-util.c |
| 285 | +++ b/src/shared/binfmt-util.c |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 286 | @@ -46,7 +46,7 @@ int disable_binfmt(void) { |
| 287 | return 0; |
| 288 | } |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 289 | |
| 290 | - r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 291 | + r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); |
| 292 | if (r < 0) |
| 293 | return log_warning_errno(r, "Failed to unregister binfmt_misc entries: %m"); |
| 294 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 295 | --- a/src/shared/cgroup-setup.c |
| 296 | +++ b/src/shared/cgroup-setup.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 297 | @@ -351,7 +351,7 @@ int cg_attach(const char *controller, co |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 298 | |
| 299 | xsprintf(c, PID_FMT "\n", pid); |
| 300 | |
| 301 | - r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 302 | + r = write_string_file(fs, c, 0); |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 303 | if (r == -EOPNOTSUPP && cg_is_threaded(controller, path) > 0) |
| 304 | /* When the threaded mode is used, we cannot read/write the file. Let's return recognizable error. */ |
| 305 | return -EUCLEAN; |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 306 | @@ -964,7 +964,7 @@ int cg_enable_everywhere( |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 307 | return log_debug_errno(errno, "Failed to open cgroup.subtree_control file of %s: %m", p); |
| 308 | } |
| 309 | |
| 310 | - r = write_string_stream(f, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 311 | + r = write_string_stream(f, s, 0); |
| 312 | if (r < 0) { |
| 313 | log_debug_errno(r, "Failed to %s controller %s for %s (%s): %m", |
| 314 | FLAGS_SET(mask, bit) ? "enable" : "disable", n, p, fs); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 315 | --- a/src/shared/coredump-util.c |
| 316 | +++ b/src/shared/coredump-util.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 317 | @@ -163,7 +163,7 @@ int set_coredump_filter(uint64_t value) |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 318 | xsprintf(t, "0x%"PRIx64, value); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 319 | |
| 320 | return write_string_file("/proc/self/coredump_filter", t, |
| 321 | - WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER); |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 322 | + 0); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 323 | } |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 324 | |
| 325 | /* Turn off core dumps but only if we're running outside of a container. */ |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 326 | --- a/src/shared/sleep-util.c |
| 327 | +++ b/src/shared/sleep-util.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 328 | @@ -1044,7 +1044,7 @@ int write_resume_config(dev_t devno, uin |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 329 | |
| 330 | /* We write the offset first since it's safer. Note that this file is only available in 4.17+, so |
| 331 | * fail gracefully if it doesn't exist and we're only overwriting it with 0. */ |
| 332 | - r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 333 | + r = write_string_file("/sys/power/resume_offset", offset_str, 0); |
| 334 | if (r == -ENOENT) { |
| 335 | if (offset != 0) |
| 336 | return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 337 | @@ -1060,7 +1060,7 @@ int write_resume_config(dev_t devno, uin |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 338 | log_debug("Wrote resume_offset=%s for device '%s' to /sys/power/resume_offset.", |
| 339 | offset_str, device); |
| 340 | |
| 341 | - r = write_string_file("/sys/power/resume", devno_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 342 | + r = write_string_file("/sys/power/resume", devno_str, 0); |
| 343 | if (r < 0) |
| 344 | return log_error_errno(r, |
| 345 | "Failed to write device '%s' (%s) to /sys/power/resume: %m", |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 346 | --- a/src/shared/smack-util.c |
| 347 | +++ b/src/shared/smack-util.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 348 | @@ -113,7 +113,7 @@ int mac_smack_apply_pid(pid_t pid, const |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 349 | return 0; |
| 350 | |
| 351 | p = procfs_file_alloca(pid, "attr/current"); |
| 352 | - r = write_string_file(p, label, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 353 | + r = write_string_file(p, label, 0); |
| 354 | if (r < 0) |
| 355 | return r; |
| 356 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 357 | --- a/src/sleep/sleep.c |
| 358 | +++ b/src/sleep/sleep.c |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 359 | @@ -139,7 +139,7 @@ static int write_mode(char **modes) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 360 | STRV_FOREACH(mode, modes) { |
| 361 | int k; |
| 362 | |
| 363 | - k = write_string_file("/sys/power/disk", *mode, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 364 | + k = write_string_file("/sys/power/disk", *mode, 0); |
| 365 | if (k >= 0) |
| 366 | return 0; |
| 367 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 368 | @@ -160,7 +160,7 @@ static int write_state(FILE **f, char ** |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 369 | STRV_FOREACH(state, states) { |
| 370 | int k; |
| 371 | |
| 372 | - k = write_string_stream(*f, *state, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 373 | + k = write_string_stream(*f, *state, 0); |
| 374 | if (k >= 0) |
| 375 | return 0; |
| 376 | log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m", *state); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 377 | --- a/src/udev/udev-rules.c |
| 378 | +++ b/src/udev/udev-rules.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 379 | @@ -2634,7 +2634,6 @@ static int udev_rule_apply_token_to_even |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 380 | log_event_debug(dev, token, "ATTR '%s' writing '%s'", buf, value); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 381 | r = write_string_file(buf, value, |
| 382 | WRITE_STRING_FILE_VERIFY_ON_FAILURE | |
| 383 | - WRITE_STRING_FILE_DISABLE_BUFFER | |
| 384 | WRITE_STRING_FILE_AVOID_NEWLINE | |
| 385 | WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE); |
| 386 | if (r < 0) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 387 | --- a/src/vconsole/vconsole-setup.c |
| 388 | +++ b/src/vconsole/vconsole-setup.c |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 389 | @@ -260,7 +260,7 @@ static int toggle_utf8_vc(const char *na |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 390 | static int toggle_utf8_sysfs(bool utf8) { |
| 391 | int r; |
| 392 | |
| 393 | - r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 394 | + r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), 0); |
| 395 | if (r < 0) |
| 396 | return log_warning_errno(r, "Failed to %s sysfs UTF-8 flag: %m", enable_disable(utf8)); |
| 397 | |