Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 1 | From 0f9422780a569c79a4b28e44c79c70b4a354bd92 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> |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 21 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 22 | --- |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 23 | src/basic/cgroup-util.c | 10 +++++----- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 24 | src/basic/procfs-util.c | 4 ++-- |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 25 | src/basic/sysctl-util.c | 2 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 26 | src/basic/util.c | 2 +- |
| 27 | src/binfmt/binfmt.c | 6 +++--- |
| 28 | src/core/main.c | 4 ++-- |
| 29 | src/core/smack-setup.c | 8 ++++---- |
| 30 | src/hibernate-resume/hibernate-resume.c | 2 +- |
| 31 | src/libsystemd/sd-device/sd-device.c | 2 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 32 | src/nspawn/nspawn-cgroup.c | 2 +- |
| 33 | src/nspawn/nspawn.c | 6 +++--- |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 34 | src/shared/cgroup-setup.c | 4 ++-- |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 35 | src/shared/mount-util.c | 4 ++-- |
| 36 | src/shared/smack-util.c | 2 +- |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 37 | src/sleep/sleep.c | 8 ++++---- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 38 | src/vconsole/vconsole-setup.c | 2 +- |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 39 | 16 files changed, 34 insertions(+), 34 deletions(-) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 40 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 41 | --- a/src/basic/cgroup-util.c |
| 42 | +++ b/src/basic/cgroup-util.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 43 | @@ -390,7 +390,7 @@ int cg_kill_kernel_sigkill(const char *c |
| 44 | if (r < 0) |
| 45 | return r; |
| 46 | |
| 47 | - r = write_string_file(killfile, "1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 48 | + r = write_string_file(killfile, "1", 0); |
| 49 | if (r < 0) |
| 50 | return r; |
| 51 | |
| 52 | @@ -803,7 +803,7 @@ int cg_install_release_agent(const char |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 53 | |
| 54 | sc = strstrip(contents); |
| 55 | if (isempty(sc)) { |
| 56 | - r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 57 | + r = write_string_file(fs, agent, 0); |
| 58 | if (r < 0) |
| 59 | return r; |
| 60 | } else if (!path_equal(sc, agent)) |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 61 | @@ -821,7 +821,7 @@ int cg_install_release_agent(const char |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 62 | |
| 63 | sc = strstrip(contents); |
| 64 | if (streq(sc, "0")) { |
| 65 | - r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 66 | + r = write_string_file(fs, "1", 0); |
| 67 | if (r < 0) |
| 68 | return r; |
| 69 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 70 | @@ -848,7 +848,7 @@ int cg_uninstall_release_agent(const cha |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 71 | if (r < 0) |
| 72 | return r; |
| 73 | |
| 74 | - r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 75 | + r = write_string_file(fs, "0", 0); |
| 76 | if (r < 0) |
| 77 | return r; |
| 78 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 79 | @@ -858,7 +858,7 @@ int cg_uninstall_release_agent(const cha |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 80 | if (r < 0) |
| 81 | return r; |
| 82 | |
| 83 | - r = write_string_file(fs, "", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 84 | + r = write_string_file(fs, "", 0); |
| 85 | if (r < 0) |
| 86 | return r; |
| 87 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 88 | @@ -1704,7 +1704,7 @@ int cg_set_attribute(const char *control |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 89 | if (r < 0) |
| 90 | return r; |
| 91 | |
| 92 | - return write_string_file(p, value, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 93 | + return write_string_file(p, value, 0); |
| 94 | } |
| 95 | |
| 96 | int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) { |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 97 | --- a/src/basic/procfs-util.c |
| 98 | +++ b/src/basic/procfs-util.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 99 | @@ -64,13 +64,13 @@ int procfs_tasks_set_limit(uint64_t limi |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 100 | * decrease it, as threads-max is the much more relevant sysctl. */ |
| 101 | if (limit > pid_max-1) { |
| 102 | sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */ |
| 103 | - r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 104 | + r = write_string_file("/proc/sys/kernel/pid_max", buffer, 0); |
| 105 | if (r < 0) |
| 106 | return r; |
| 107 | } |
| 108 | |
| 109 | sprintf(buffer, "%" PRIu64, limit); |
| 110 | - r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 111 | + r = write_string_file("/proc/sys/kernel/threads-max", buffer, 0); |
| 112 | if (r < 0) { |
| 113 | uint64_t threads_max; |
| 114 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 115 | --- a/src/basic/sysctl-util.c |
| 116 | +++ b/src/basic/sysctl-util.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 117 | @@ -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] | 118 | |
| 119 | log_debug("Setting '%s' to '%s'", p, value); |
| 120 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 121 | - return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL); |
| 122 | + 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] | 123 | } |
| 124 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 125 | int sysctl_writef(const char *property, const char *format, ...) { |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 126 | --- a/src/basic/util.c |
| 127 | +++ b/src/basic/util.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 128 | @@ -168,7 +168,7 @@ void disable_coredumps(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 129 | if (detect_container() > 0) |
| 130 | return; |
| 131 | |
| 132 | - r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 133 | + r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); |
| 134 | if (r < 0) |
| 135 | log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m"); |
| 136 | } |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 137 | --- a/src/binfmt/binfmt.c |
| 138 | +++ b/src/binfmt/binfmt.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 139 | @@ -29,7 +29,7 @@ static bool arg_unregister = false; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 140 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 141 | static int delete_rule(const char *rulename) { |
| 142 | const char *fn = strjoina("/proc/sys/fs/binfmt_misc/", rulename); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 143 | - return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 144 | + return write_string_file(fn, "-1", 0); |
| 145 | } |
| 146 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 147 | static int apply_rule(const char *filename, unsigned line, const char *rule) { |
| 148 | @@ -59,7 +59,7 @@ static int apply_rule(const char *filena |
| 149 | if (r >= 0) |
| 150 | log_debug("%s:%u: Rule '%s' deleted.", filename, line, rulename); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 151 | |
| 152 | - r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 153 | + r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0); |
| 154 | if (r < 0) |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 155 | return log_error_errno(r, "%s:%u: Failed to add binary format '%s': %m", |
| 156 | filename, line, rulename); |
| 157 | @@ -226,7 +226,7 @@ static int run(int argc, char *argv[]) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | /* Flush out all rules */ |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 161 | - r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 162 | + r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); |
| 163 | if (r < 0) |
| 164 | log_warning_errno(r, "Failed to flush binfmt_misc rules, ignoring: %m"); |
| 165 | else |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 166 | --- a/src/core/main.c |
| 167 | +++ b/src/core/main.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 168 | @@ -1466,7 +1466,7 @@ static int bump_unix_max_dgram_qlen(void |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 169 | if (v >= DEFAULT_UNIX_MAX_DGRAM_QLEN) |
| 170 | return 0; |
| 171 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 172 | - r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", WRITE_STRING_FILE_DISABLE_BUFFER, |
| 173 | + r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", 0, |
| 174 | "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 175 | if (r < 0) |
| 176 | return log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r, |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 177 | @@ -1737,7 +1737,7 @@ static void initialize_core_pattern(bool |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 178 | if (getpid_cached() != 1) |
| 179 | return; |
| 180 | |
| 181 | - r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 182 | + r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, 0); |
| 183 | if (r < 0) |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 184 | log_warning_errno(r, "Failed to write '%s' to /proc/sys/kernel/core_pattern, ignoring: %m", |
| 185 | arg_early_core_pattern); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 186 | --- a/src/core/smack-setup.c |
| 187 | +++ b/src/core/smack-setup.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 188 | @@ -320,17 +320,17 @@ int mac_smack_setup(bool *loaded_policy) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 189 | } |
| 190 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 191 | #if HAVE_SMACK_RUN_LABEL |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 192 | - r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 193 | + r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0); |
| 194 | if (r < 0) |
| 195 | log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m"); |
| 196 | - r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 197 | + r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, 0); |
| 198 | if (r < 0) |
| 199 | log_warning_errno(r, "Failed to set SMACK ambient label \"" SMACK_RUN_LABEL "\": %m"); |
| 200 | r = write_string_file("/sys/fs/smackfs/netlabel", |
| 201 | - "0.0.0.0/0 " SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 202 | + "0.0.0.0/0 " SMACK_RUN_LABEL, 0); |
| 203 | if (r < 0) |
| 204 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"0.0.0.0/0 " SMACK_RUN_LABEL "\": %m"); |
| 205 | - r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 206 | + r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", 0); |
| 207 | if (r < 0) |
| 208 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m"); |
| 209 | #endif |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 210 | --- a/src/hibernate-resume/hibernate-resume.c |
| 211 | +++ b/src/hibernate-resume/hibernate-resume.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 212 | @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) { |
| 213 | return EXIT_FAILURE; |
| 214 | } |
| 215 | |
| 216 | - r = write_string_file("/sys/power/resume", major_minor, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 217 | + r = write_string_file("/sys/power/resume", major_minor, 0); |
| 218 | if (r < 0) { |
| 219 | log_error_errno(r, "Failed to write '%s' to /sys/power/resume: %m", major_minor); |
| 220 | return EXIT_FAILURE; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 221 | --- a/src/libsystemd/sd-device/sd-device.c |
| 222 | +++ b/src/libsystemd/sd-device/sd-device.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 223 | @@ -2108,7 +2108,7 @@ _public_ int sd_device_set_sysattr_value |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 224 | if (!value) |
| 225 | return -ENOMEM; |
| 226 | |
| 227 | - r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW); |
| 228 | + r = write_string_file(path, value, 0 | WRITE_STRING_FILE_NOFOLLOW); |
| 229 | if (r < 0) { |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 230 | /* On failure, clear cache entry, as we do not know how it fails. */ |
| 231 | device_remove_cached_sysattr_value(device, sysattr); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 232 | --- a/src/nspawn/nspawn-cgroup.c |
| 233 | +++ b/src/nspawn/nspawn-cgroup.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 234 | @@ -124,7 +124,7 @@ int sync_cgroup(pid_t pid, CGroupUnified |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 235 | fn = strjoina(tree, cgroup, "/cgroup.procs"); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 236 | |
| 237 | sprintf(pid_string, PID_FMT, pid); |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 238 | - r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755); |
| 239 | + r = write_string_file(fn, pid_string, WRITE_STRING_FILE_MKDIR_0755); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 240 | if (r < 0) { |
| 241 | log_error_errno(r, "Failed to move process: %m"); |
| 242 | goto finish; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 243 | --- a/src/nspawn/nspawn.c |
| 244 | +++ b/src/nspawn/nspawn.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 245 | @@ -2757,7 +2757,7 @@ static int reset_audit_loginuid(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 246 | if (streq(p, "4294967295")) |
| 247 | return 0; |
| 248 | |
| 249 | - r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 250 | + r = write_string_file("/proc/self/loginuid", "4294967295", 0); |
| 251 | if (r < 0) { |
| 252 | log_error_errno(r, |
| 253 | "Failed to reset audit login UID. This probably means that your kernel is too\n" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 254 | @@ -4163,7 +4163,7 @@ static int setup_uid_map( |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 255 | return log_oom(); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 256 | |
| 257 | xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 258 | - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 259 | + r = write_string_file(uid_map, s, 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 260 | if (r < 0) |
| 261 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 262 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 263 | @@ -4173,7 +4173,7 @@ static int setup_uid_map( |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 264 | return log_oom(); |
| 265 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 266 | xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 267 | - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 268 | + r = write_string_file(uid_map, s, 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 269 | if (r < 0) |
| 270 | return log_error_errno(r, "Failed to write GID map: %m"); |
| 271 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 272 | --- a/src/shared/cgroup-setup.c |
| 273 | +++ b/src/shared/cgroup-setup.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 274 | @@ -345,7 +345,7 @@ int cg_attach(const char *controller, co |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 275 | |
| 276 | xsprintf(c, PID_FMT "\n", pid); |
| 277 | |
| 278 | - r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 279 | + r = write_string_file(fs, c, 0); |
| 280 | if (r < 0) |
| 281 | return r; |
| 282 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 283 | @@ -877,7 +877,7 @@ int cg_enable_everywhere( |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 284 | return log_debug_errno(errno, "Failed to open cgroup.subtree_control file of %s: %m", p); |
| 285 | } |
| 286 | |
| 287 | - r = write_string_stream(f, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 288 | + r = write_string_stream(f, s, 0); |
| 289 | if (r < 0) { |
| 290 | log_debug_errno(r, "Failed to %s controller %s for %s (%s): %m", |
| 291 | FLAGS_SET(mask, bit) ? "enable" : "disable", n, p, fs); |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 292 | --- a/src/shared/smack-util.c |
| 293 | +++ b/src/shared/smack-util.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 294 | @@ -114,7 +114,7 @@ int mac_smack_apply_pid(pid_t pid, const |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 295 | return 0; |
| 296 | |
| 297 | p = procfs_file_alloca(pid, "attr/current"); |
| 298 | - r = write_string_file(p, label, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 299 | + r = write_string_file(p, label, 0); |
| 300 | if (r < 0) |
| 301 | return r; |
| 302 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 303 | --- a/src/sleep/sleep.c |
| 304 | +++ b/src/sleep/sleep.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 305 | @@ -46,7 +46,7 @@ static int write_hibernate_location_info |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 306 | assert(hibernate_location->swap); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 307 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 308 | xsprintf(resume_str, "%u:%u", major(hibernate_location->devno), minor(hibernate_location->devno)); |
| 309 | - r = write_string_file("/sys/power/resume", resume_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 310 | + r = write_string_file("/sys/power/resume", resume_str, 0); |
| 311 | if (r < 0) |
| 312 | return log_debug_errno(r, "Failed to write partition device to /sys/power/resume for '%s': '%s': %m", |
| 313 | hibernate_location->swap->device, resume_str); |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 314 | @@ -73,7 +73,7 @@ static int write_hibernate_location_info |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 315 | } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 316 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 317 | xsprintf(offset_str, "%" PRIu64, hibernate_location->offset); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 318 | - r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 319 | + r = write_string_file("/sys/power/resume_offset", offset_str, 0); |
| 320 | if (r < 0) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 321 | return log_debug_errno(r, "Failed to write swap file offset to /sys/power/resume_offset for '%s': '%s': %m", |
| 322 | hibernate_location->swap->device, offset_str); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 323 | @@ -90,7 +90,7 @@ static int write_mode(char **modes) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 324 | STRV_FOREACH(mode, modes) { |
| 325 | int k; |
| 326 | |
| 327 | - k = write_string_file("/sys/power/disk", *mode, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 328 | + k = write_string_file("/sys/power/disk", *mode, 0); |
| 329 | if (k >= 0) |
| 330 | return 0; |
| 331 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 332 | @@ -112,7 +112,7 @@ static int write_state(FILE **f, char ** |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 333 | STRV_FOREACH(state, states) { |
| 334 | int k; |
| 335 | |
| 336 | - k = write_string_stream(*f, *state, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 337 | + k = write_string_stream(*f, *state, 0); |
| 338 | if (k >= 0) |
| 339 | return 0; |
| 340 | log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m", *state); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 341 | --- a/src/vconsole/vconsole-setup.c |
| 342 | +++ b/src/vconsole/vconsole-setup.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 343 | @@ -108,7 +108,7 @@ static int toggle_utf8_vc(const char *na |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 344 | static int toggle_utf8_sysfs(bool utf8) { |
| 345 | int r; |
| 346 | |
| 347 | - r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 348 | + r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), 0); |
| 349 | if (r < 0) |
| 350 | return log_warning_errno(r, "Failed to %s sysfs UTF-8 flag: %m", enable_disable(utf8)); |
| 351 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 352 | --- a/src/basic/namespace-util.c |
| 353 | +++ b/src/basic/namespace-util.c |
| 354 | @@ -202,12 +202,12 @@ int userns_acquire(const char *uid_map, |
| 355 | freeze(); |
| 356 | |
| 357 | xsprintf(path, "/proc/" PID_FMT "/uid_map", pid); |
| 358 | - r = write_string_file(path, uid_map, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 359 | + r = write_string_file(path, uid_map, 0); |
| 360 | if (r < 0) |
| 361 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 362 | |
| 363 | xsprintf(path, "/proc/" PID_FMT "/gid_map", pid); |
| 364 | - r = write_string_file(path, gid_map, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 365 | + r = write_string_file(path, gid_map, 0); |
| 366 | if (r < 0) |
| 367 | return log_error_errno(r, "Failed to write GID map: %m"); |
| 368 | |
| 369 | --- a/src/core/cgroup.c |
| 370 | +++ b/src/core/cgroup.c |
| 371 | @@ -4140,7 +4140,7 @@ int unit_cgroup_freezer_action(Unit *u, |
| 372 | else |
| 373 | u->freezer_state = FREEZER_THAWING; |
| 374 | |
| 375 | - r = write_string_file(path, one_zero(action == FREEZER_FREEZE), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 376 | + r = write_string_file(path, one_zero(action == FREEZER_FREEZE), 0); |
| 377 | if (r < 0) |
| 378 | return r; |
| 379 | |
| 380 | --- a/src/home/homework.c |
| 381 | +++ b/src/home/homework.c |
| 382 | @@ -284,7 +284,7 @@ static void drop_caches_now(void) { |
| 383 | * details. We write "2" into /proc/sys/vm/drop_caches to ensure dentries/inodes are flushed, but not |
| 384 | * more. */ |
| 385 | |
| 386 | - r = write_string_file("/proc/sys/vm/drop_caches", "2\n", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 387 | + r = write_string_file("/proc/sys/vm/drop_caches", "2\n", 0); |
| 388 | if (r < 0) |
| 389 | log_warning_errno(r, "Failed to drop caches, ignoring: %m"); |
| 390 | else |
| 391 | --- a/src/shared/binfmt-util.c |
| 392 | +++ b/src/shared/binfmt-util.c |
| 393 | @@ -26,7 +26,7 @@ int disable_binfmt(void) { |
| 394 | if (r < 0) |
| 395 | return log_warning_errno(r, "Failed to determine whether binfmt_misc is mounted: %m"); |
| 396 | |
| 397 | - r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 398 | + r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); |
| 399 | if (r < 0) |
| 400 | return log_warning_errno(r, "Failed to unregister binfmt_misc entries: %m"); |
| 401 | |
| 402 | --- a/src/shared/coredump-util.c |
| 403 | +++ b/src/shared/coredump-util.c |
| 404 | @@ -70,5 +70,5 @@ int set_coredump_filter(uint64_t value) |
| 405 | sprintf(t, "0x%"PRIx64, value); |
| 406 | |
| 407 | return write_string_file("/proc/self/coredump_filter", t, |
| 408 | - WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER); |
| 409 | + WRITE_STRING_FILE_VERIFY_ON_FAILURE); |
| 410 | } |
| 411 | --- a/src/udev/udev-rules.c |
| 412 | +++ b/src/udev/udev-rules.c |
| 413 | @@ -2181,7 +2181,6 @@ static int udev_rule_apply_token_to_even |
| 414 | log_rule_debug(dev, rules, "ATTR '%s' writing '%s'", buf, value); |
| 415 | r = write_string_file(buf, value, |
| 416 | WRITE_STRING_FILE_VERIFY_ON_FAILURE | |
| 417 | - WRITE_STRING_FILE_DISABLE_BUFFER | |
| 418 | WRITE_STRING_FILE_AVOID_NEWLINE | |
| 419 | WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE); |
| 420 | if (r < 0) |