summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-04 10:34:47 +0200
committerSven Eden <yamakuzure@gmx.net>2017-03-14 10:19:06 +0100
commit93309e31862f386680cd8de0e8a64b4eb268ae77 (patch)
tree57cb6615a41734508a4056fa85e2cc26867e8d06 /src/login
parentc75a803944547880dd0cf6275aa170acac27844e (diff)
logind: treat an empty wall message like a NULL one
Diffstat (limited to 'src/login')
-rw-r--r--src/login/logind-dbus.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 768aa1a31..0dfc96c18 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1340,8 +1340,7 @@ static int bus_manager_log_shutdown(
InhibitWhat w,
const char *unit_name) {
- const char *p;
- const char *q;
+ const char *p, *q;
assert(m);
assert(unit_name);
@@ -1366,8 +1365,8 @@ static int bus_manager_log_shutdown(
q = NULL;
}
- if (m->wall_message)
- p = strjoina(p, " (", m->wall_message, ")", NULL);
+ if (!isempty(m->wall_message))
+ p = strjoina(p, " (", m->wall_message, ")");
return log_struct(LOG_NOTICE,
LOG_MESSAGE_ID(SD_MESSAGE_SHUTDOWN),
@@ -2292,15 +2291,19 @@ static int method_set_wall_message(
UID_INVALID,
&m->polkit_registry,
error);
-
if (r < 0)
return r;
if (r == 0)
return 1; /* Will call us back */
- r = free_and_strdup(&m->wall_message, wall_message);
- if (r < 0)
- return log_oom();
+ if (isempty(wall_message))
+ m->wall_message = mfree(m->wall_message);
+ else {
+ r = free_and_strdup(&m->wall_message, wall_message);
+ if (r < 0)
+ return log_oom();
+ }
+
m->enable_wall_messages = enable_wall_messages;
return sd_bus_reply_method_return(message, NULL);