summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-05 20:24:08 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-05 20:27:52 +0200
commit91b3e7fb6c0b24a8d258c710304d50a45f90568a (patch)
tree57931272ed912a9bbf3d2ea42846ae641df49e97 /src
parent8ff4d2ab0d4758e914aea6d86154d85f2b2c787f (diff)
logind: make scope of wall message handling smaller
Diffstat (limited to 'src')
-rw-r--r--src/login/logind-dbus.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index e433549cb9..d2296f5311 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1785,10 +1785,9 @@ static int nologin_timeout_handler(
}
static int update_schedule_file(Manager *m) {
-
- int r;
+ _cleanup_free_ char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
- _cleanup_free_ char *t = NULL, *temp_path = NULL;
+ int r;
assert(m);
@@ -1796,12 +1795,6 @@ static int update_schedule_file(Manager *m) {
if (r < 0)
return log_error_errno(r, "Failed to create shutdown subdirectory: %m");
- if (!isempty(m->wall_message)) {
- t = cescape(m->wall_message);
- if (!t)
- return log_oom();
- }
-
r = fopen_temporary("/run/systemd/shutdown/scheduled", &f, &temp_path);
if (r < 0)
return log_error_errno(r, "Failed to save information about scheduled shutdowns: %m");
@@ -1816,8 +1809,17 @@ static int update_schedule_file(Manager *m) {
m->enable_wall_messages,
m->scheduled_shutdown_type);
- if (t)
+ if (!isempty(m->wall_message)) {
+ _cleanup_free_ char *t;
+
+ t = cescape(m->wall_message);
+ if (!t) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
fprintf(f, "WALL_MESSAGE=%s\n", t);
+ }
r = fflush_and_check(f);
if (r < 0)