summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-09-04 12:13:45 +0200
committerDaniel Mack <github@zonque.org>2015-09-04 12:13:45 +0200
commitf6bd4cb69ee1a85dfec25fd3d8a6a68c24129569 (patch)
tree359e7367df50dc40d5187c6b899fb9ff91c10564
parentc7f837628b18b2e531fd36e175ca424c2ed30c9e (diff)
parent2cf088b56d72cb6a3243041524f1fbae7c1cb28e (diff)
Merge pull request #1141 from poettering/logind-fixes
Various logind fixes
-rw-r--r--src/login/logind-dbus.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 5b2b36b9c0..7cc68d4865 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1339,8 +1339,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);
@@ -1365,8 +1364,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),
@@ -2294,7 +2293,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);
@@ -2310,15 +2309,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);