summaryrefslogtreecommitdiff
path: root/src/core/dbus-manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-16 05:47:04 +0200
committerLennart Poettering <lennart@poettering.net>2013-04-16 05:47:04 +0200
commit6606089752df90f3eeb4924af109046f1c73554c (patch)
tree6d031dd2b3eec2f02f1a25aaa680c80ae95affd6 /src/core/dbus-manager.c
parentdfb33a9737e62ab872d3937b7690b252d2892fe8 (diff)
path-util: unify code for detecting OS trees
This also makes sure we always detect an OS tree the same way, by checking for /etc/os-release.
Diffstat (limited to 'src/core/dbus-manager.c')
-rw-r--r--src/core/dbus-manager.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index c23709c2b6..d767dd5236 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1481,7 +1481,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "SwitchRoot")) {
const char *switch_root, *switch_root_init;
char *u, *v;
- int k;
+ bool good;
SELINUX_ACCESS_CHECK(connection, message, "reboot");
@@ -1506,19 +1506,18 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
/* Safety check */
if (isempty(switch_root_init))
- k = access(switch_root, F_OK);
+ good = path_is_os_tree(switch_root);
else {
- char *p;
+ _cleanup_free_ char *p = NULL;
p = strjoin(switch_root, "/", switch_root_init, NULL);
if (!p)
goto oom;
- k = access(p, X_OK);
- free(p);
+ good = access(p, X_OK) >= 0;
}
- if (k < 0)
- return bus_send_error_reply(connection, message, NULL, -errno);
+ if (!good)
+ return bus_send_error_reply(connection, message, NULL, -EINVAL);
u = strdup(switch_root);
if (!u)