chiark / gitweb /
logind: make scope of wall message handling smaller
[elogind.git] / src / login / logind-dbus.c
index 0dfc96c18f0b76a264df45e3ca79cc2b6885d4b9..ac987ec57aa28fc04ac7ed4c5a4c1112a49e3b94 100644 (file)
@@ -1772,10 +1772,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);
 
@@ -1783,10 +1782,6 @@ static int update_schedule_file(Manager *m) {
         if (r < 0)
                 return log_error_errno(r, "Failed to create shutdown subdirectory: %m");
 
-        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");
@@ -1801,8 +1796,17 @@ static int update_schedule_file(Manager *m) {
                 m->enable_wall_messages,
                 m->scheduled_shutdown_type);
 
-        if (!isempty(m->wall_message))
+        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)
@@ -2275,7 +2279,7 @@ static int method_set_wall_message(
         int r;
         Manager *m = userdata;
         char *wall_message;
-        bool enable_wall_messages;
+        int enable_wall_messages;
 
         assert(message);
         assert(m);