chiark / gitweb /
tree-wide: fix write_string_file() user that should not create files
authorDaniel Mack <daniel@zonque.org>
Mon, 6 Jul 2015 23:27:20 +0000 (19:27 -0400)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:05:57 +0000 (10:05 +0100)
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/shared/smack-util.c
src/shared/sysctl-util.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 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) {