[systemd-commits] 2 commits - src/core src/timedate
Zbigniew Jędrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Sat Mar 21 16:56:23 PDT 2015
src/core/dbus-manager.c | 6 ++--
src/timedate/timedated.c | 59 ++++++++++++++++-------------------------------
2 files changed, 24 insertions(+), 41 deletions(-)
New commits:
commit 81b843990297ad8c813c531fccd8da30bb715bd6
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sat Mar 21 19:21:17 2015 -0400
timedated: fix enable/disable reversal
Bug introduced in 984f1b1d1b. The state was flipped later,
but the enable/disable routine made use of the state to decide
what to do.
context_enable_ntp() and context_start_ntp() now get the desired
state directly, so the Context parameter can be removed.
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index db9a149..0d4a9dd 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -222,38 +222,23 @@ static int context_read_ntp(Context *c, sd_bus *bus) {
return 0;
}
-static int context_start_ntp(Context *c, sd_bus *bus, sd_bus_error *error) {
+static int context_start_ntp(sd_bus *bus, sd_bus_error *error, bool enabled) {
int r;
- assert(c);
assert(bus);
assert(error);
- if (c->use_ntp)
- r = sd_bus_call_method(
- bus,
- "org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager",
- "StartUnit",
- error,
- NULL,
- "ss",
- "systemd-timesyncd.service",
- "replace");
- else
- r = sd_bus_call_method(
- bus,
- "org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager",
- "StopUnit",
- error,
- NULL,
- "ss",
- "systemd-timesyncd.service",
- "replace");
-
+ r = sd_bus_call_method(
+ bus,
+ "org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Manager",
+ enabled ? "StartUnit" : "StopUnit",
+ error,
+ NULL,
+ "ss",
+ "systemd-timesyncd.service",
+ "replace");
if (r < 0) {
if (sd_bus_error_has_name(error, SD_BUS_ERROR_FILE_NOT_FOUND) ||
sd_bus_error_has_name(error, "org.freedesktop.systemd1.LoadFailed") ||
@@ -266,14 +251,13 @@ static int context_start_ntp(Context *c, sd_bus *bus, sd_bus_error *error) {
return 0;
}
-static int context_enable_ntp(Context*c, sd_bus *bus, sd_bus_error *error) {
+static int context_enable_ntp(sd_bus *bus, sd_bus_error *error, bool enabled) {
int r;
- assert(c);
assert(bus);
assert(error);
- if (c->use_ntp)
+ if (enabled)
r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
@@ -622,15 +606,15 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu
}
static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
- int ntp, interactive;
+ int enabled, interactive;
Context *c = userdata;
int r;
- r = sd_bus_message_read(m, "bb", &ntp, &interactive);
+ r = sd_bus_message_read(m, "bb", &enabled, &interactive);
if (r < 0)
return r;
- if ((bool)ntp == c->use_ntp)
+ if ((bool)enabled == c->use_ntp)
return sd_bus_reply_method_return(m, NULL);
r = bus_verify_polkit_async(
@@ -646,17 +630,16 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
if (r == 0)
return 1;
- r = context_enable_ntp(c, bus, error);
+ r = context_enable_ntp(bus, error, enabled);
if (r < 0)
return r;
- r = context_start_ntp(c, bus, error);
+ r = context_start_ntp(bus, error, enabled);
if (r < 0)
return r;
- c->use_ntp = ntp;
-
- log_info("Set NTP to %s", c->use_ntp ? "enabled" : "disabled");
+ c->use_ntp = enabled;
+ log_info("Set NTP to %s", enabled ? "enabled" : "disabled");
sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL);
commit df823e23f04da832ad5fc078176f8c26597a9845
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sat Mar 21 18:50:10 2015 -0400
core: make SELinux enable/disable check symmetric
We'd use the generic check for disable, and a unit-file-specific one for enable.
Use the more specific one both ways.
systemd[1]: SELinux access check scon=system_u:system_r:systemd_timedated_t:s0 tcon=system_u:system_r:init_t:s0 tclass=system perm=disable path=(null) cmdline=/usr/lib/systemd/systemd-timedated: -13
systemd[1]: SELinux access check scon=system_u:system_r:systemd_timedated_t:s0 tcon=system_u:object_r:systemd_unit_file_t:s0 tclass=service perm=enable path=/usr/lib/systemd/system/systemd-timesyncd.service cmdline=/usr/lib/systemd/systemd-timedated: -13
https://bugzilla.redhat.com/show_bug.cgi?id=1014315
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 76901c7..1b26e55 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1799,15 +1799,15 @@ static int method_disable_unit_files_generic(
assert(message);
assert(m);
- r = mac_selinux_access_check(message, verb, error);
+ r = sd_bus_message_read_strv(message, &l);
if (r < 0)
return r;
- r = sd_bus_message_read_strv(message, &l);
+ r = sd_bus_message_read(message, "b", &runtime);
if (r < 0)
return r;
- r = sd_bus_message_read(message, "b", &runtime);
+ r = mac_selinux_unit_access_check_strv(l, message, m, verb, error);
if (r < 0)
return r;
More information about the systemd-commits
mailing list