William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1 | From 7cb6579572b50ef44bc0a321a4c73cce55b0c2f2 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 ++-- |
| 25 | src/basic/smack-util.c | 2 +- |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 26 | src/basic/sysctl-util.c | 2 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 27 | src/basic/util.c | 2 +- |
| 28 | src/binfmt/binfmt.c | 6 +++--- |
| 29 | src/core/main.c | 4 ++-- |
| 30 | src/core/smack-setup.c | 8 ++++---- |
| 31 | src/hibernate-resume/hibernate-resume.c | 2 +- |
| 32 | src/libsystemd/sd-device/sd-device.c | 2 +- |
| 33 | src/login/logind-dbus.c | 2 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 34 | src/nspawn/nspawn-cgroup.c | 2 +- |
| 35 | src/nspawn/nspawn.c | 6 +++--- |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 36 | src/shared/cgroup-setup.c | 4 ++-- |
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 +- |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 39 | 16 files changed, 33 insertions(+), 33 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 |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 43 | @@ -766,7 +766,7 @@ int cg_install_release_agent(const char |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 44 | |
| 45 | sc = strstrip(contents); |
| 46 | if (isempty(sc)) { |
| 47 | - r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 48 | + r = write_string_file(fs, agent, 0); |
| 49 | if (r < 0) |
| 50 | return r; |
| 51 | } else if (!path_equal(sc, agent)) |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 52 | @@ -784,7 +784,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 (streq(sc, "0")) { |
| 56 | - r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 57 | + r = write_string_file(fs, "1", 0); |
| 58 | if (r < 0) |
| 59 | return r; |
| 60 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 61 | @@ -811,7 +811,7 @@ int cg_uninstall_release_agent(const cha |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 62 | if (r < 0) |
| 63 | return r; |
| 64 | |
| 65 | - r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 66 | + r = write_string_file(fs, "0", 0); |
| 67 | if (r < 0) |
| 68 | return r; |
| 69 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 70 | @@ -821,7 +821,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, "", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 75 | + r = write_string_file(fs, "", 0); |
| 76 | if (r < 0) |
| 77 | return r; |
| 78 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 79 | @@ -1651,7 +1651,7 @@ int cg_set_attribute(const char *control |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 80 | if (r < 0) |
| 81 | return r; |
| 82 | |
| 83 | - return write_string_file(p, value, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 84 | + return write_string_file(p, value, 0); |
| 85 | } |
| 86 | |
| 87 | 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] | 88 | --- a/src/basic/procfs-util.c |
| 89 | +++ b/src/basic/procfs-util.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 90 | @@ -86,13 +86,13 @@ int procfs_tasks_set_limit(uint64_t limi |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 91 | * decrease it, as threads-max is the much more relevant sysctl. */ |
| 92 | if (limit > pid_max-1) { |
| 93 | sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */ |
| 94 | - r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 95 | + r = write_string_file("/proc/sys/kernel/pid_max", buffer, 0); |
| 96 | if (r < 0) |
| 97 | return r; |
| 98 | } |
| 99 | |
| 100 | sprintf(buffer, "%" PRIu64, limit); |
| 101 | - r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 102 | + r = write_string_file("/proc/sys/kernel/threads-max", buffer, 0); |
| 103 | if (r < 0) { |
| 104 | uint64_t threads_max; |
| 105 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 106 | --- a/src/basic/sysctl-util.c |
| 107 | +++ b/src/basic/sysctl-util.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 108 | @@ -93,7 +93,7 @@ int sysctl_write_ip_property(int af, con |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 109 | |
| 110 | log_debug("Setting '%s' to '%s'", p, value); |
| 111 | |
| 112 | - return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER); |
| 113 | + return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | 0); |
| 114 | } |
| 115 | |
| 116 | int sysctl_read(const char *property, char **ret) { |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 117 | --- a/src/basic/util.c |
| 118 | +++ b/src/basic/util.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 119 | @@ -234,7 +234,7 @@ void disable_coredumps(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 120 | if (detect_container() > 0) |
| 121 | return; |
| 122 | |
| 123 | - r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 124 | + r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); |
| 125 | if (r < 0) |
| 126 | log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m"); |
| 127 | } |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 128 | --- a/src/binfmt/binfmt.c |
| 129 | +++ b/src/binfmt/binfmt.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 130 | @@ -48,7 +48,7 @@ static int delete_rule(const char *rule) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 131 | if (!fn) |
| 132 | return log_oom(); |
| 133 | |
| 134 | - return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 135 | + return write_string_file(fn, "-1", 0); |
| 136 | } |
| 137 | |
| 138 | static int apply_rule(const char *rule) { |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 139 | @@ -56,7 +56,7 @@ static int apply_rule(const char *rule) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 140 | |
| 141 | (void) delete_rule(rule); |
| 142 | |
| 143 | - r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 144 | + r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0); |
| 145 | if (r < 0) |
| 146 | return log_error_errno(r, "Failed to add binary format: %m"); |
| 147 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 148 | @@ -223,7 +223,7 @@ static int run(int argc, char *argv[]) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | /* Flush out all rules */ |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 152 | - (void) write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 153 | + (void) write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 154 | |
| 155 | STRV_FOREACH(f, files) { |
| 156 | k = apply_file(*f, true); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 157 | --- a/src/core/main.c |
| 158 | +++ b/src/core/main.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 159 | @@ -1402,7 +1402,7 @@ static int bump_unix_max_dgram_qlen(void |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 160 | if (v >= DEFAULT_UNIX_MAX_DGRAM_QLEN) |
| 161 | return 0; |
| 162 | |
| 163 | - r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", WRITE_STRING_FILE_DISABLE_BUFFER, "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN); |
| 164 | + r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", 0, "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN); |
| 165 | if (r < 0) |
| 166 | return log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r, |
| 167 | "Failed to bump AF_UNIX datagram queue length, ignoring: %m"); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 168 | @@ -1679,7 +1679,7 @@ static void initialize_core_pattern(bool |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 169 | if (getpid_cached() != 1) |
| 170 | return; |
| 171 | |
| 172 | - r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 173 | + r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, 0); |
| 174 | if (r < 0) |
| 175 | log_warning_errno(r, "Failed to write '%s' to /proc/sys/kernel/core_pattern, ignoring: %m", arg_early_core_pattern); |
| 176 | } |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 177 | --- a/src/core/smack-setup.c |
| 178 | +++ b/src/core/smack-setup.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 179 | @@ -323,17 +323,17 @@ int mac_smack_setup(bool *loaded_policy) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | #ifdef SMACK_RUN_LABEL |
| 183 | - r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 184 | + r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0); |
| 185 | if (r < 0) |
| 186 | log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m"); |
| 187 | - r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 188 | + r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, 0); |
| 189 | if (r < 0) |
| 190 | log_warning_errno(r, "Failed to set SMACK ambient label \"" SMACK_RUN_LABEL "\": %m"); |
| 191 | r = write_string_file("/sys/fs/smackfs/netlabel", |
| 192 | - "0.0.0.0/0 " SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 193 | + "0.0.0.0/0 " SMACK_RUN_LABEL, 0); |
| 194 | if (r < 0) |
| 195 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"0.0.0.0/0 " SMACK_RUN_LABEL "\": %m"); |
| 196 | - r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 197 | + r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", 0); |
| 198 | if (r < 0) |
| 199 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m"); |
| 200 | #endif |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 201 | --- a/src/hibernate-resume/hibernate-resume.c |
| 202 | +++ b/src/hibernate-resume/hibernate-resume.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 203 | @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) { |
| 204 | return EXIT_FAILURE; |
| 205 | } |
| 206 | |
| 207 | - r = write_string_file("/sys/power/resume", major_minor, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 208 | + r = write_string_file("/sys/power/resume", major_minor, 0); |
| 209 | if (r < 0) { |
| 210 | log_error_errno(r, "Failed to write '%s' to /sys/power/resume: %m", major_minor); |
| 211 | return EXIT_FAILURE; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 212 | --- a/src/libsystemd/sd-device/sd-device.c |
| 213 | +++ b/src/libsystemd/sd-device/sd-device.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 214 | @@ -2096,7 +2096,7 @@ _public_ int sd_device_set_sysattr_value |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 215 | if (!value) |
| 216 | return -ENOMEM; |
| 217 | |
| 218 | - r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW); |
| 219 | + r = write_string_file(path, value, 0 | WRITE_STRING_FILE_NOFOLLOW); |
| 220 | if (r < 0) { |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 221 | /* On failure, clear cache entry, as we do not know how it fails. */ |
| 222 | device_remove_cached_sysattr_value(device, sysattr); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 223 | --- a/src/nspawn/nspawn-cgroup.c |
| 224 | +++ b/src/nspawn/nspawn-cgroup.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 225 | @@ -124,7 +124,7 @@ int sync_cgroup(pid_t pid, CGroupUnified |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 226 | fn = strjoina(tree, cgroup, "/cgroup.procs"); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 227 | |
| 228 | sprintf(pid_string, PID_FMT, pid); |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 229 | - r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755); |
| 230 | + r = write_string_file(fn, pid_string, WRITE_STRING_FILE_MKDIR_0755); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 231 | if (r < 0) { |
| 232 | log_error_errno(r, "Failed to move process: %m"); |
| 233 | goto finish; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 234 | --- a/src/nspawn/nspawn.c |
| 235 | +++ b/src/nspawn/nspawn.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 236 | @@ -2751,7 +2751,7 @@ static int reset_audit_loginuid(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 237 | if (streq(p, "4294967295")) |
| 238 | return 0; |
| 239 | |
| 240 | - r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 241 | + r = write_string_file("/proc/self/loginuid", "4294967295", 0); |
| 242 | if (r < 0) { |
| 243 | log_error_errno(r, |
| 244 | "Failed to reset audit login UID. This probably means that your kernel is too\n" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 245 | @@ -4148,7 +4148,7 @@ static int setup_uid_map( |
| 246 | return log_oom(); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 247 | |
| 248 | xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 249 | - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 250 | + r = write_string_file(uid_map, s, 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 251 | if (r < 0) |
| 252 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 253 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 254 | @@ -4158,7 +4158,7 @@ static int setup_uid_map( |
| 255 | return log_oom(); |
| 256 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 257 | xsprintf(uid_map, "/proc/" PID_FMT "/gid_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 GID map: %m"); |
| 262 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 263 | --- a/src/shared/cgroup-setup.c |
| 264 | +++ b/src/shared/cgroup-setup.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 265 | @@ -267,7 +267,7 @@ int cg_attach(const char *controller, co |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 266 | |
| 267 | xsprintf(c, PID_FMT "\n", pid); |
| 268 | |
| 269 | - r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 270 | + r = write_string_file(fs, c, 0); |
| 271 | if (r < 0) |
| 272 | return r; |
| 273 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 274 | @@ -799,7 +799,7 @@ int cg_enable_everywhere( |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 275 | return log_debug_errno(errno, "Failed to open cgroup.subtree_control file of %s: %m", p); |
| 276 | } |
| 277 | |
| 278 | - r = write_string_stream(f, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 279 | + r = write_string_stream(f, s, 0); |
| 280 | if (r < 0) { |
| 281 | log_debug_errno(r, "Failed to %s controller %s for %s (%s): %m", |
| 282 | FLAGS_SET(mask, bit) ? "enable" : "disable", n, p, fs); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 283 | --- a/src/sleep/sleep.c |
| 284 | +++ b/src/sleep/sleep.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 285 | @@ -46,7 +46,7 @@ static int write_hibernate_location_info |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 286 | assert(hibernate_location->swap); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 287 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 288 | xsprintf(resume_str, "%u:%u", major(hibernate_location->devno), minor(hibernate_location->devno)); |
| 289 | - r = write_string_file("/sys/power/resume", resume_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 290 | + r = write_string_file("/sys/power/resume", resume_str, 0); |
| 291 | if (r < 0) |
| 292 | return log_debug_errno(r, "Failed to write partition device to /sys/power/resume for '%s': '%s': %m", |
| 293 | hibernate_location->swap->device, resume_str); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 294 | @@ -73,7 +73,7 @@ static int write_hibernate_location_info |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 295 | } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 296 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 297 | xsprintf(offset_str, "%" PRIu64, hibernate_location->offset); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 298 | - r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 299 | + r = write_string_file("/sys/power/resume_offset", offset_str, 0); |
| 300 | if (r < 0) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 301 | return log_debug_errno(r, "Failed to write swap file offset to /sys/power/resume_offset for '%s': '%s': %m", |
| 302 | hibernate_location->swap->device, offset_str); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 303 | @@ -90,7 +90,7 @@ static int write_mode(char **modes) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 304 | STRV_FOREACH(mode, modes) { |
| 305 | int k; |
| 306 | |
| 307 | - k = write_string_file("/sys/power/disk", *mode, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 308 | + k = write_string_file("/sys/power/disk", *mode, 0); |
| 309 | if (k >= 0) |
| 310 | return 0; |
| 311 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 312 | @@ -112,7 +112,7 @@ static int write_state(FILE **f, char ** |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 313 | STRV_FOREACH(state, states) { |
| 314 | int k; |
| 315 | |
| 316 | - k = write_string_stream(*f, *state, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 317 | + k = write_string_stream(*f, *state, 0); |
| 318 | if (k >= 0) |
| 319 | return 0; |
| 320 | 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] | 321 | --- a/src/vconsole/vconsole-setup.c |
| 322 | +++ b/src/vconsole/vconsole-setup.c |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 323 | @@ -116,7 +116,7 @@ static int toggle_utf8_vc(const char *na |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 324 | static int toggle_utf8_sysfs(bool utf8) { |
| 325 | int r; |
| 326 | |
| 327 | - r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 328 | + r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), 0); |
| 329 | if (r < 0) |
| 330 | return log_warning_errno(r, "Failed to %s sysfs UTF-8 flag: %m", enable_disable(utf8)); |
| 331 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame^] | 332 | --- a/src/shared/mount-util.c |
| 333 | +++ b/src/shared/mount-util.c |
| 334 | @@ -1019,13 +1019,13 @@ static int make_userns(uid_t uid_shift, |
| 335 | xsprintf(line, UID_FMT " " UID_FMT " " UID_FMT "\n", 0, uid_shift, uid_range); |
| 336 | |
| 337 | xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid); |
| 338 | - r = write_string_file(uid_map, line, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 339 | + r = write_string_file(uid_map, line, 0); |
| 340 | if (r < 0) |
| 341 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 342 | |
| 343 | /* We always assign the same UID and GID ranges */ |
| 344 | xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid); |
| 345 | - r = write_string_file(uid_map, line, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 346 | + r = write_string_file(uid_map, line, 0); |
| 347 | if (r < 0) |
| 348 | return log_error_errno(r, "Failed to write GID map: %m"); |
| 349 | |
| 350 | --- a/src/shared/smack-util.c |
| 351 | +++ b/src/shared/smack-util.c |
| 352 | @@ -114,7 +114,7 @@ int mac_smack_apply_pid(pid_t pid, const |
| 353 | return 0; |
| 354 | |
| 355 | p = procfs_file_alloca(pid, "attr/current"); |
| 356 | - r = write_string_file(p, label, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 357 | + r = write_string_file(p, label, 0); |
| 358 | if (r < 0) |
| 359 | return r; |
| 360 | |