123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- From 414e2f97008a1f3c26a260a6dc4d51a8c1fa6900 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 | 12 ++++++------
- src/basic/namespace-util.c | 4 ++--
- src/basic/procfs-util.c | 4 ++--
- src/basic/sysctl-util.c | 2 +-
- src/basic/process-util.c | 2 +-
- src/binfmt/binfmt.c | 6 +++---
- src/core/cgroup.c | 2 +-
- src/core/main.c | 4 ++--
- src/core/smack-setup.c | 8 ++++----
- src/hibernate-resume/hibernate-resume.c | 2 +-
- src/home/homework.c | 2 +-
- src/libsystemd/sd-device/sd-device.c | 2 +-
- src/nspawn/nspawn-cgroup.c | 2 +-
- src/nspawn/nspawn.c | 6 +++---
- src/shared/binfmt-util.c | 2 +-
- src/shared/cgroup-setup.c | 4 ++--
- src/shared/coredump-util.c | 2 +-
- src/shared/smack-util.c | 2 +-
- src/sleep/sleep.c | 8 ++++----
- src/udev/udev-rules.c | 1 -
- src/vconsole/vconsole-setup.c | 2 +-
- 21 files changed, 39 insertions(+), 40 deletions(-)
- --- a/src/basic/cgroup-util.c
- +++ b/src/basic/cgroup-util.c
- @@ -399,7 +399,7 @@ int cg_kill_kernel_sigkill(const char *c
- if (r < 0)
- return r;
-
- - r = write_string_file(killfile, "1", WRITE_STRING_FILE_DISABLE_BUFFER);
- + r = write_string_file(killfile, "1", 0);
- if (r < 0)
- return r;
-
- @@ -805,7 +805,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))
- @@ -823,7 +823,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;
-
- @@ -850,7 +850,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;
-
- @@ -860,7 +860,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;
-
- @@ -1730,7 +1730,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) {
- --- a/src/basic/namespace-util.c
- +++ b/src/basic/namespace-util.c
- @@ -220,12 +220,12 @@ int userns_acquire(const char *uid_map,
- freeze();
-
- xsprintf(path, "/proc/" PID_FMT "/uid_map", pid);
- - r = write_string_file(path, uid_map, WRITE_STRING_FILE_DISABLE_BUFFER);
- + r = write_string_file(path, uid_map, 0);
- if (r < 0)
- return log_error_errno(r, "Failed to write UID map: %m");
-
- xsprintf(path, "/proc/" PID_FMT "/gid_map", pid);
- - r = write_string_file(path, gid_map, WRITE_STRING_FILE_DISABLE_BUFFER);
- + r = write_string_file(path, gid_map, 0);
- if (r < 0)
- return log_error_errno(r, "Failed to write GID map: %m");
-
- --- a/src/basic/procfs-util.c
- +++ b/src/basic/procfs-util.c
- @@ -64,13 +64,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;
-
- --- a/src/core/smack-setup.c
- +++ b/src/core/smack-setup.c
- @@ -320,17 +320,17 @@ int mac_smack_setup(bool *loaded_policy)
- }
-
- #if HAVE_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
- --- a/src/hibernate-resume/hibernate-resume.c
- +++ b/src/hibernate-resume/hibernate-resume.c
- @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
- return EXIT_FAILURE;
- }
-
- - r = write_string_file("/sys/power/resume", FORMAT_DEVNUM(st.st_rdev), WRITE_STRING_FILE_DISABLE_BUFFER);
- + r = write_string_file("/sys/power/resume", FORMAT_DEVNUM(st.st_rdev), 0);
- if (r < 0) {
- log_error_errno(r, "Failed to write '" DEVNUM_FORMAT_STR "' to /sys/power/resume: %m", DEVNUM_FORMAT_VAL(st.st_rdev));
- return EXIT_FAILURE;
- --- a/src/home/homework.c
- +++ b/src/home/homework.c
- @@ -278,7 +278,7 @@ static void drop_caches_now(void) {
- * for details. We write "2" into /proc/sys/vm/drop_caches to ensure dentries/inodes are flushed, but
- * not more. */
-
- - r = write_string_file("/proc/sys/vm/drop_caches", "2\n", WRITE_STRING_FILE_DISABLE_BUFFER);
- + r = write_string_file("/proc/sys/vm/drop_caches", "2\n", 0);
- if (r < 0)
- log_warning_errno(r, "Failed to drop caches, ignoring: %m");
- else
- --- a/src/libsystemd/sd-device/sd-device.c
- +++ b/src/libsystemd/sd-device/sd-device.c
- @@ -2444,7 +2444,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) {
- /* On failure, clear cache entry, as we do not know how it fails. */
- device_remove_cached_sysattr_value(device, sysattr);
- --- a/src/nspawn/nspawn-cgroup.c
- +++ b/src/nspawn/nspawn-cgroup.c
- @@ -123,7 +123,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;
- --- a/src/nspawn/nspawn.c
- +++ b/src/nspawn/nspawn.c
- @@ -2762,7 +2762,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"
- @@ -4187,7 +4187,7 @@ static int setup_uid_map(
- return log_oom();
-
- xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid);
- - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER);
- + r = write_string_file(uid_map, s, 0);
- if (r < 0)
- return log_error_errno(r, "Failed to write UID map: %m");
-
- @@ -4197,7 +4197,7 @@ static int setup_uid_map(
- return log_oom();
-
- xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid);
- - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER);
- + r = write_string_file(uid_map, s, 0);
- if (r < 0)
- return log_error_errno(r, "Failed to write GID map: %m");
-
- --- a/src/shared/binfmt-util.c
- +++ b/src/shared/binfmt-util.c
- @@ -26,7 +26,7 @@ int disable_binfmt(void) {
- if (r < 0)
- return log_warning_errno(r, "Failed to determine whether binfmt_misc is mounted: %m");
-
- - r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER);
- + r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0);
- if (r < 0)
- return log_warning_errno(r, "Failed to unregister binfmt_misc entries: %m");
-
- --- a/src/shared/cgroup-setup.c
- +++ b/src/shared/cgroup-setup.c
- @@ -350,7 +350,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 == -EOPNOTSUPP && cg_is_threaded(controller, path) > 0)
- /* When the threaded mode is used, we cannot read/write the file. Let's return recognizable error. */
- return -EUCLEAN;
- @@ -887,7 +887,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);
- --- a/src/shared/coredump-util.c
- +++ b/src/shared/coredump-util.c
- @@ -70,5 +70,5 @@ int set_coredump_filter(uint64_t value)
- sprintf(t, "0x%"PRIx64, value);
-
- return write_string_file("/proc/self/coredump_filter", t,
- - WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER);
- + WRITE_STRING_FILE_VERIFY_ON_FAILURE);
- }
- --- a/src/shared/smack-util.c
- +++ b/src/shared/smack-util.c
- @@ -115,7 +115,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;
-
- --- a/src/sleep/sleep.c
- +++ b/src/sleep/sleep.c
- @@ -50,7 +50,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);
- @@ -77,7 +77,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);
- @@ -93,7 +93,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);
- --- a/src/udev/udev-rules.c
- +++ b/src/udev/udev-rules.c
- @@ -2354,7 +2354,6 @@ static int udev_rule_apply_token_to_even
- log_rule_debug(dev, rules, "ATTR '%s' writing '%s'", buf, value);
- r = write_string_file(buf, value,
- WRITE_STRING_FILE_VERIFY_ON_FAILURE |
- - WRITE_STRING_FILE_DISABLE_BUFFER |
- WRITE_STRING_FILE_AVOID_NEWLINE |
- WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE);
- if (r < 0)
- --- a/src/vconsole/vconsole-setup.c
- +++ b/src/vconsole/vconsole-setup.c
- @@ -108,7 +108,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));
-
|