summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2015-07-06 19:27:20 -0400
committerDaniel Mack <daniel@zonque.org>2015-07-06 19:27:20 -0400
commitad118bda159d3f9c27c5a15ace54cf808a6e8788 (patch)
tree43eeba4758137b413f7f80f29dd41ded3004d051
parent4c1fc3e404d648c70bd2f50ac50aeac6ece8872e (diff)
tree-wide: fix write_string_file() user that should not create files
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.
-rw-r--r--src/basic/smack-util.c2
-rw-r--r--src/binfmt/binfmt.c2
-rw-r--r--src/core/execute.c2
-rw-r--r--src/nspawn/nspawn.c6
-rw-r--r--src/shared/sysctl-util.c2
-rw-r--r--src/udev/udevd.c4
-rw-r--r--src/vconsole/vconsole-setup.c4
7 files changed, 11 insertions, 11 deletions
diff --git a/src/basic/smack-util.c b/src/basic/smack-util.c
index 0c3697b61b..047aa294f4 100644
--- a/src/basic/smack-util.c
+++ b/src/basic/smack-util.c
@@ -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
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index 24eb410571..1e216f52bd 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -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);
diff --git a/src/core/execute.c b/src/core/execute.c
index 61e7304dc7..21721dc240 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -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");
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index c7f4d02855..d749eb49b6 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -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");
diff --git a/src/shared/sysctl-util.c b/src/shared/sysctl-util.c
index 232a005054..1de0b94fd5 100644
--- a/src/shared/sysctl-util.c
+++ b/src/shared/sysctl-util.c
@@ -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) {
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 8a31089c0c..0661f7be00 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -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);
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index 4b21175611..7bdc158ad7 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -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;