]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: fix write_string_file() user that should not create files 500/head
authorDaniel Mack <daniel@zonque.org>
Mon, 6 Jul 2015 23:27:20 +0000 (19:27 -0400)
committerDaniel Mack <daniel@zonque.org>
Mon, 6 Jul 2015 23:27:20 +0000 (19:27 -0400)
The latest consolidation cleanup of write_string_file() revealed some users
of that helper which should have used write_string_file_no_create() in the
past but didn't. Basically, all existing users that write to files in /sys
and /proc should not expect to write to a file which is not yet existant.

src/basic/smack-util.c
src/binfmt/binfmt.c
src/core/execute.c
src/nspawn/nspawn.c
src/shared/sysctl-util.c
src/udev/udevd.c
src/vconsole/vconsole-setup.c

index 0c3697b61b841b29b5c9504d336c47034058362f..047aa294f4c0a11610530adb2dd875ca7ec4ebeb 100644 (file)
@@ -139,7 +139,7 @@ int mac_smack_apply_pid(pid_t pid, const char *label) {
                 return 0;
 
         p = procfs_file_alloca(pid, "attr/current");
-        r = write_string_file(p, label, WRITE_STRING_FILE_CREATE);
+        r = write_string_file(p, label, 0);
         if (r < 0)
                 return r;
 #endif
index 24eb41057141297ac830fdd6a4d2e33d5cb3e15b..1e216f52bd4c739deb1ac2dc637b9803c8dbcaff 100644 (file)
@@ -191,7 +191,7 @@ int main(int argc, char *argv[]) {
                 }
 
                 /* Flush out all rules */
-                write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_CREATE);
+                write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0);
 
                 STRV_FOREACH(f, files) {
                         k = apply_file(*f, true);
index 61e7304dc7843094cc4b39af92cc5f7a99907199..21721dc240731e11b7e4f3eeaef64d9d538629b9 100644 (file)
@@ -1446,7 +1446,7 @@ static int exec_child(
                  * shouldn't trip up over that. */
 
                 sprintf(t, "%i", context->oom_score_adjust);
-                r = write_string_file("/proc/self/oom_score_adj", t, WRITE_STRING_FILE_CREATE);
+                r = write_string_file("/proc/self/oom_score_adj", t, 0);
                 if (r == -EPERM || r == -EACCES) {
                         log_open();
                         log_unit_debug_errno(unit, r, "Failed to adjust OOM setting, assuming containerized execution, ignoring: %m");
index c7f4d02855098e2f0afdff7eecde7bba71f2f6f1..d749eb49b642f04500fb90e17911cb9047407a2d 100644 (file)
@@ -2508,7 +2508,7 @@ static int reset_audit_loginuid(void) {
         if (streq(p, "4294967295"))
                 return 0;
 
-        r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_CREATE);
+        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"
@@ -4448,13 +4448,13 @@ static int setup_uid_map(pid_t pid) {
 
         xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid);
         xsprintf(line, UID_FMT " " UID_FMT " " UID_FMT "\n", 0, arg_uid_shift, arg_uid_range);
-        r = write_string_file(uid_map, line, WRITE_STRING_FILE_CREATE);
+        r = write_string_file(uid_map, line, 0);
         if (r < 0)
                 return log_error_errno(r, "Failed to write UID map: %m");
 
         /* We always assign the same UID and GID ranges */
         xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid);
-        r = write_string_file(uid_map, line, WRITE_STRING_FILE_CREATE);
+        r = write_string_file(uid_map, line, 0);
         if (r < 0)
                 return log_error_errno(r, "Failed to write GID map: %m");
 
index 232a005054a3584b84e48e447c8a444f64cefa95..1de0b94fd5fbb0ac4440018cd9d1c13f5039f2a8 100644 (file)
@@ -66,7 +66,7 @@ int sysctl_write(const char *property, const char *value) {
         log_debug("Setting '%s' to '%s'", property, value);
 
         p = strjoina("/proc/sys/", property);
-        return write_string_file(p, value, WRITE_STRING_FILE_CREATE);
+        return write_string_file(p, value, 0);
 }
 
 int sysctl_read(const char *property, char **content) {
index 8a31089c0c668137b320f2dc6849e7c069404480..0661f7be00fc50c3d62643e572c48816342ba1e1 100644 (file)
@@ -398,7 +398,7 @@ static void worker_spawn(Manager *manager, struct event *event) {
                 prctl(PR_SET_PDEATHSIG, SIGTERM);
 
                 /* reset OOM score, we only protect the main daemon */
-                write_string_file("/proc/self/oom_score_adj", "0", WRITE_STRING_FILE_CREATE);
+                write_string_file("/proc/self/oom_score_adj", "0", 0);
 
                 for (;;) {
                         struct udev_event *udev_event;
@@ -1747,7 +1747,7 @@ int main(int argc, char *argv[]) {
 
                 setsid();
 
-                write_string_file("/proc/self/oom_score_adj", "-1000", WRITE_STRING_FILE_CREATE);
+                write_string_file("/proc/self/oom_score_adj", "-1000", 0);
         }
 
         r = run(fd_ctrl, fd_uevent, cgroup);
index 4b211756119f308e47d01aa85609ea9deea3b74c..7bdc158ad76f2816b3f375308174fded11b765a9 100644 (file)
@@ -56,7 +56,7 @@ static int disable_utf8(int fd) {
         if (k < 0)
                 r = k;
 
-        k = write_string_file("/sys/module/vt/parameters/default_utf8", "0", WRITE_STRING_FILE_CREATE);
+        k = write_string_file("/sys/module/vt/parameters/default_utf8", "0", 0);
         if (k < 0)
                 r = k;
 
@@ -89,7 +89,7 @@ static int enable_utf8(int fd) {
         if (k < 0)
                 r = k;
 
-        k = write_string_file("/sys/module/vt/parameters/default_utf8", "1", WRITE_STRING_FILE_CREATE);
+        k = write_string_file("/sys/module/vt/parameters/default_utf8", "1", 0);
         if (k < 0)
                 r = k;