chiark / gitweb /
Remove src/core
authorAndy Wingo <wingo@pobox.com>
Sun, 19 Apr 2015 10:58:44 +0000 (12:58 +0200)
committerAndy Wingo <wingo@pobox.com>
Sun, 19 Apr 2015 10:58:44 +0000 (12:58 +0200)
135 files changed:
Makefile.am
src/core/.gitignore [deleted file]
src/core/Makefile [deleted symlink]
src/core/audit-fd.c [deleted file]
src/core/audit-fd.h [deleted file]
src/core/automount.c [deleted file]
src/core/automount.h [deleted file]
src/core/bus-endpoint.c [deleted file]
src/core/bus-endpoint.h [deleted file]
src/core/bus-policy.c [deleted file]
src/core/bus-policy.h [deleted file]
src/core/busname.c [deleted file]
src/core/busname.h [deleted file]
src/core/cgroup.c [deleted file]
src/core/cgroup.h [deleted file]
src/core/dbus-automount.c [deleted file]
src/core/dbus-automount.h [deleted file]
src/core/dbus-busname.c [deleted file]
src/core/dbus-busname.h [deleted file]
src/core/dbus-cgroup.c [deleted file]
src/core/dbus-cgroup.h [deleted file]
src/core/dbus-device.c [deleted file]
src/core/dbus-device.h [deleted file]
src/core/dbus-execute.c [deleted file]
src/core/dbus-execute.h [deleted file]
src/core/dbus-job.c [deleted file]
src/core/dbus-job.h [deleted file]
src/core/dbus-kill.c [deleted file]
src/core/dbus-kill.h [deleted file]
src/core/dbus-manager.c [deleted file]
src/core/dbus-manager.h [deleted file]
src/core/dbus-mount.c [deleted file]
src/core/dbus-mount.h [deleted file]
src/core/dbus-path.c [deleted file]
src/core/dbus-path.h [deleted file]
src/core/dbus-scope.c [deleted file]
src/core/dbus-scope.h [deleted file]
src/core/dbus-service.c [deleted file]
src/core/dbus-service.h [deleted file]
src/core/dbus-slice.c [deleted file]
src/core/dbus-slice.h [deleted file]
src/core/dbus-snapshot.c [deleted file]
src/core/dbus-snapshot.h [deleted file]
src/core/dbus-socket.c [deleted file]
src/core/dbus-socket.h [deleted file]
src/core/dbus-swap.c [deleted file]
src/core/dbus-swap.h [deleted file]
src/core/dbus-target.c [deleted file]
src/core/dbus-target.h [deleted file]
src/core/dbus-timer.c [deleted file]
src/core/dbus-timer.h [deleted file]
src/core/dbus-unit.c [deleted file]
src/core/dbus-unit.h [deleted file]
src/core/dbus.c [deleted file]
src/core/dbus.h [deleted file]
src/core/device.c [deleted file]
src/core/device.h [deleted file]
src/core/execute.c [deleted file]
src/core/execute.h [deleted file]
src/core/failure-action.c [deleted file]
src/core/failure-action.h [deleted file]
src/core/hostname-setup.c [deleted file]
src/core/hostname-setup.h [deleted file]
src/core/ima-setup.c [deleted file]
src/core/ima-setup.h [deleted file]
src/core/job.c [deleted file]
src/core/job.h [deleted file]
src/core/kill.c [deleted file]
src/core/kill.h [deleted file]
src/core/killall.c [deleted file]
src/core/killall.h [deleted file]
src/core/kmod-setup.c [deleted file]
src/core/kmod-setup.h [deleted file]
src/core/load-dropin.c [deleted file]
src/core/load-dropin.h [deleted file]
src/core/load-fragment-gperf.gperf.m4 [deleted file]
src/core/load-fragment.c [deleted file]
src/core/load-fragment.h [deleted file]
src/core/locale-setup.c [deleted file]
src/core/locale-setup.h [deleted file]
src/core/loopback-setup.c [deleted file]
src/core/loopback-setup.h [deleted file]
src/core/machine-id-setup.c [deleted file]
src/core/machine-id-setup.h [deleted file]
src/core/macros.systemd.in [deleted file]
src/core/main.c [deleted file]
src/core/manager.c [deleted file]
src/core/manager.h [deleted file]
src/core/mount-setup.c [deleted file]
src/core/mount-setup.h [deleted file]
src/core/mount.c [deleted file]
src/core/mount.h [deleted file]
src/core/namespace.c [deleted file]
src/core/namespace.h [deleted file]
src/core/org.freedesktop.systemd1.conf [deleted file]
src/core/org.freedesktop.systemd1.policy.in.in [deleted file]
src/core/org.freedesktop.systemd1.service [deleted file]
src/core/path.c [deleted file]
src/core/path.h [deleted file]
src/core/scope.c [deleted file]
src/core/scope.h [deleted file]
src/core/selinux-access.c [deleted file]
src/core/selinux-access.h [deleted file]
src/core/selinux-setup.c [deleted file]
src/core/selinux-setup.h [deleted file]
src/core/service.c [deleted file]
src/core/service.h [deleted file]
src/core/show-status.c [deleted file]
src/core/show-status.h [deleted file]
src/core/shutdown.c [deleted file]
src/core/slice.c [deleted file]
src/core/slice.h [deleted file]
src/core/smack-setup.c [deleted file]
src/core/smack-setup.h [deleted file]
src/core/snapshot.c [deleted file]
src/core/snapshot.h [deleted file]
src/core/socket.c [deleted file]
src/core/socket.h [deleted file]
src/core/swap.c [deleted file]
src/core/swap.h [deleted file]
src/core/system.conf [deleted file]
src/core/systemd.pc.in [deleted file]
src/core/target.c [deleted file]
src/core/target.h [deleted file]
src/core/timer.c [deleted file]
src/core/timer.h [deleted file]
src/core/transaction.c [deleted file]
src/core/transaction.h [deleted file]
src/core/umount.c [deleted file]
src/core/umount.h [deleted file]
src/core/unit-printf.c [deleted file]
src/core/unit-printf.h [deleted file]
src/core/unit.c [deleted file]
src/core/unit.h [deleted file]
src/core/user.conf [deleted file]

index e973f19..8781f1f 100644 (file)
@@ -173,8 +173,6 @@ AM_CPPFLAGS = \
        -I $(top_srcdir)/src/shared \
        -I $(top_srcdir)/src/login \
        -I $(top_srcdir)/src/systemd \
-       -I $(top_builddir)/src/core \
-       -I $(top_srcdir)/src/core \
        -I $(top_srcdir)/src/libelogind/sd-bus \
        -I $(top_srcdir)/src/libelogind/sd-event \
        -I $(top_srcdir)/src/libelogind/sd-device \
@@ -582,140 +580,6 @@ libelogind_acl_la_LIBADD = \
        $(ACL_LIBS)
 endif
 
-# ------------------------------------------------------------------------------
-#noinst_LTLIBRARIES += \
-#      elogind-core.la
-
-elogind_core_la_SOURCES = \
-       src/core/unit.c \
-       src/core/unit.h \
-       src/core/unit-printf.c \
-       src/core/unit-printf.h \
-       src/core/job.c \
-       src/core/job.h \
-       src/core/manager.c \
-       src/core/manager.h \
-       src/core/transaction.c \
-       src/core/transaction.h \
-       src/core/load-fragment.c \
-       src/core/load-fragment.h \
-       src/core/service.c \
-       src/core/service.h \
-       src/core/socket.c \
-       src/core/socket.h \
-       src/core/busname.c \
-       src/core/busname.h \
-       src/core/bus-endpoint.c \
-       src/core/bus-endpoint.h \
-       src/core/bus-policy.c \
-       src/core/bus-policy.h \
-       src/core/target.c \
-       src/core/target.h \
-       src/core/snapshot.c \
-       src/core/snapshot.h \
-       src/core/device.c \
-       src/core/device.h \
-       src/core/swap.c \
-       src/core/swap.h \
-       src/core/timer.c \
-       src/core/timer.h \
-       src/core/path.c \
-       src/core/path.h \
-       src/core/slice.c \
-       src/core/slice.h \
-       src/core/scope.c \
-       src/core/scope.h \
-       src/core/load-dropin.c \
-       src/core/load-dropin.h \
-       src/core/execute.c \
-       src/core/execute.h \
-       src/core/kill.c \
-       src/core/kill.h \
-       src/core/dbus.c \
-       src/core/dbus.h \
-       src/core/dbus-manager.c \
-       src/core/dbus-manager.h \
-       src/core/dbus-unit.c \
-       src/core/dbus-unit.h \
-       src/core/dbus-job.c \
-       src/core/dbus-job.h \
-       src/core/dbus-service.c \
-       src/core/dbus-service.h \
-       src/core/dbus-socket.c \
-       src/core/dbus-socket.h \
-       src/core/dbus-busname.c \
-       src/core/dbus-busname.h \
-       src/core/dbus-target.c \
-       src/core/dbus-target.h \
-       src/core/dbus-snapshot.c \
-       src/core/dbus-snapshot.h \
-       src/core/dbus-device.c \
-       src/core/dbus-device.h \
-       src/core/dbus-swap.c \
-       src/core/dbus-swap.h \
-       src/core/dbus-timer.c \
-       src/core/dbus-timer.h \
-       src/core/dbus-path.c \
-       src/core/dbus-path.h \
-       src/core/dbus-slice.c \
-       src/core/dbus-slice.h \
-       src/core/dbus-scope.c \
-       src/core/dbus-scope.h \
-       src/core/dbus-execute.c \
-       src/core/dbus-execute.h \
-       src/core/dbus-kill.c \
-       src/core/dbus-kill.h \
-       src/core/dbus-cgroup.c \
-       src/core/dbus-cgroup.h \
-       src/core/cgroup.c \
-       src/core/cgroup.h \
-       src/core/selinux-access.c \
-       src/core/selinux-access.h \
-       src/core/selinux-setup.c \
-       src/core/selinux-setup.h \
-       src/core/smack-setup.c \
-       src/core/smack-setup.h \
-       src/core/ima-setup.c \
-       src/core/ima-setup.h \
-       src/core/locale-setup.h \
-       src/core/locale-setup.c \
-       src/core/hostname-setup.c \
-       src/core/hostname-setup.h \
-       src/core/machine-id-setup.c \
-       src/core/machine-id-setup.h \
-       src/core/kmod-setup.c \
-       src/core/kmod-setup.h \
-       src/core/namespace.c \
-       src/core/namespace.h \
-       src/core/killall.h \
-       src/core/killall.c \
-       src/core/audit-fd.c \
-       src/core/audit-fd.h \
-       src/core/show-status.c \
-       src/core/show-status.h \
-       src/core/failure-action.c \
-       src/core/failure-action.h
-
-nodist_elogind_core_la_SOURCES = \
-       src/core/load-fragment-gperf.c \
-       src/core/load-fragment-gperf-nulstr.c
-
-elogind_core_la_CFLAGS = \
-       $(AM_CFLAGS) \
-       $(PAM_CFLAGS) \
-       -pthread
-
-elogind_core_la_LIBADD = \
-       libelogind-shared.la \
-       $(PAM_LIBS)
-
-src/core/load-fragment-gperf-nulstr.c: src/core/load-fragment-gperf.gperf
-       $(AM_V_at)$(MKDIR_P) $(dir $@)
-       $(AM_V_GEN)$(AWK) 'BEGIN{ keywords=0 ; FS="," ; print "extern const char load_fragment_gperf_nulstr[];" ; print "const char load_fragment_gperf_nulstr[] ="} ; keyword==1 { print "\"" $$1 "\\0\"" } ; /%%/ { keyword=1} ; END { print ";" }' < $< > $@
-
-gperf_gperf_m4_sources = \
-       src/core/load-fragment-gperf.gperf.m4
-
 gperf_txt_sources = \
        src/shared/errno-list.txt \
        src/shared/af-list.txt \
@@ -723,8 +587,6 @@ gperf_txt_sources = \
        src/shared/cap-list.txt
 
 BUILT_SOURCES += \
-       $(gperf_gperf_m4_sources:-gperf.gperf.m4=-gperf.c) \
-       $(gperf_gperf_m4_sources:-gperf.gperf.m4=-gperf-nulstr.c) \
        $(gperf_gperf_sources:-gperf.gperf=-gperf.c) \
        $(gperf_txt_sources:-list.txt=-from-name.h) \
        $(gperf_txt_sources:-list.txt=-to-name.h)
@@ -1180,9 +1042,6 @@ sysctl.d/%: sysctl.d/%.in
 %.conf: %.conf.in
        $(SED_PROCESS)
 
-src/core/macros.%: src/core/macros.%.in
-       $(SED_PROCESS)
-
 src/%.policy.in: src/%.policy.in.in
        $(SED_PROCESS)
 
diff --git a/src/core/.gitignore b/src/core/.gitignore
deleted file mode 100644 (file)
index f293bbd..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/macros.systemd
-/systemd.pc
diff --git a/src/core/Makefile b/src/core/Makefile
deleted file mode 120000 (symlink)
index d0b0e8e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../Makefile
\ No newline at end of file
diff --git a/src/core/audit-fd.c b/src/core/audit-fd.c
deleted file mode 100644 (file)
index 5a18e26..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2012 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-#include <errno.h>
-#include "audit-fd.h"
-
-#ifdef HAVE_AUDIT
-
-#include <stdbool.h>
-#include <libaudit.h>
-
-#include "log.h"
-#include "util.h"
-
-static bool initialized = false;
-static int audit_fd;
-
-int get_audit_fd(void) {
-
-        if (!initialized) {
-                audit_fd = audit_open();
-
-                if (audit_fd < 0) {
-                        if (errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
-                                log_error_errno(errno, "Failed to connect to audit log: %m");
-
-                        audit_fd = errno ? -errno : -EINVAL;
-                }
-
-                initialized = true;
-        }
-
-        return audit_fd;
-}
-
-void close_audit_fd(void) {
-
-        if (initialized && audit_fd >= 0)
-                safe_close(audit_fd);
-
-        initialized = true;
-        audit_fd = -ECONNRESET;
-}
-
-#else
-
-int get_audit_fd(void) {
-        return -EAFNOSUPPORT;
-}
-
-void close_audit_fd(void) {
-}
-
-#endif
diff --git a/src/core/audit-fd.h b/src/core/audit-fd.h
deleted file mode 100644 (file)
index 8b58289..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2012 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-int get_audit_fd(void);
-void close_audit_fd(void);
diff --git a/src/core/automount.c b/src/core/automount.c
deleted file mode 100644 (file)
index cec90cb..0000000
+++ /dev/null
@@ -1,878 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <limits.h>
-#include <sys/mount.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/epoll.h>
-#include <sys/stat.h>
-#include <linux/auto_fs4.h>
-#include <linux/auto_dev-ioctl.h>
-
-#include "unit.h"
-#include "automount.h"
-#include "mount.h"
-#include "unit-name.h"
-#include "special.h"
-#include "label.h"
-#include "mkdir.h"
-#include "path-util.h"
-#include "dbus-automount.h"
-#include "bus-util.h"
-#include "bus-error.h"
-
-static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
-        [AUTOMOUNT_DEAD] = UNIT_INACTIVE,
-        [AUTOMOUNT_WAITING] = UNIT_ACTIVE,
-        [AUTOMOUNT_RUNNING] = UNIT_ACTIVE,
-        [AUTOMOUNT_FAILED] = UNIT_FAILED
-};
-
-static int open_dev_autofs(Manager *m);
-static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, void *userdata);
-
-static void automount_init(Unit *u) {
-        Automount *a = AUTOMOUNT(u);
-
-        assert(u);
-        assert(u->load_state == UNIT_STUB);
-
-        a->pipe_fd = -1;
-        a->directory_mode = 0755;
-        UNIT(a)->ignore_on_isolate = true;
-}
-
-static void repeat_unmount(const char *path) {
-        assert(path);
-
-        for (;;) {
-                /* If there are multiple mounts on a mount point, this
-                 * removes them all */
-
-                if (umount2(path, MNT_DETACH) >= 0)
-                        continue;
-
-                if (errno != EINVAL)
-                        log_error_errno(errno, "Failed to unmount: %m");
-
-                break;
-        }
-}
-
-static void unmount_autofs(Automount *a) {
-        assert(a);
-
-        if (a->pipe_fd < 0)
-                return;
-
-        automount_send_ready(a, -EHOSTDOWN);
-
-        a->pipe_event_source = sd_event_source_unref(a->pipe_event_source);
-        a->pipe_fd = safe_close(a->pipe_fd);
-
-        /* If we reload/reexecute things we keep the mount point
-         * around */
-        if (a->where &&
-            (UNIT(a)->manager->exit_code != MANAGER_RELOAD &&
-             UNIT(a)->manager->exit_code != MANAGER_REEXECUTE))
-                repeat_unmount(a->where);
-}
-
-static void automount_done(Unit *u) {
-        Automount *a = AUTOMOUNT(u);
-
-        assert(a);
-
-        unmount_autofs(a);
-
-        free(a->where);
-        a->where = NULL;
-
-        set_free(a->tokens);
-        a->tokens = NULL;
-}
-
-static int automount_add_mount_links(Automount *a) {
-        _cleanup_free_ char *parent = NULL;
-        int r;
-
-        assert(a);
-
-        r = path_get_parent(a->where, &parent);
-        if (r < 0)
-                return r;
-
-        return unit_require_mounts_for(UNIT(a), parent);
-}
-
-static int automount_add_default_dependencies(Automount *a) {
-        int r;
-
-        assert(a);
-
-        if (UNIT(a)->manager->running_as != SYSTEMD_SYSTEM)
-                return 0;
-
-        r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
-        if (r < 0)
-                return r;
-
-        return 0;
-}
-
-static int automount_verify(Automount *a) {
-        bool b;
-        _cleanup_free_ char *e = NULL;
-        assert(a);
-
-        if (UNIT(a)->load_state != UNIT_LOADED)
-                return 0;
-
-        if (path_equal(a->where, "/")) {
-                log_unit_error(UNIT(a)->id, "Cannot have an automount unit for the root directory. Refusing.");
-                return -EINVAL;
-        }
-
-        e = unit_name_from_path(a->where, ".automount");
-        if (!e)
-                return -ENOMEM;
-
-        b = unit_has_name(UNIT(a), e);
-
-        if (!b) {
-                log_unit_error(UNIT(a)->id, "%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id);
-                return -EINVAL;
-        }
-
-        return 0;
-}
-
-static int automount_load(Unit *u) {
-        Automount *a = AUTOMOUNT(u);
-        int r;
-
-        assert(u);
-        assert(u->load_state == UNIT_STUB);
-
-        /* Load a .automount file */
-        r = unit_load_fragment_and_dropin_optional(u);
-        if (r < 0)
-                return r;
-
-        if (u->load_state == UNIT_LOADED) {
-                Unit *x;
-
-                if (!a->where) {
-                        a->where = unit_name_to_path(u->id);
-                        if (!a->where)
-                                return -ENOMEM;
-                }
-
-                path_kill_slashes(a->where);
-
-                r = unit_load_related_unit(u, ".mount", &x);
-                if (r < 0)
-                        return r;
-
-                r = unit_add_two_dependencies(u, UNIT_BEFORE, UNIT_TRIGGERS, x, true);
-                if (r < 0)
-                        return r;
-
-                r = automount_add_mount_links(a);
-                if (r < 0)
-                        return r;
-
-                if (UNIT(a)->default_dependencies) {
-                        r = automount_add_default_dependencies(a);
-                        if (r < 0)
-                                return r;
-                }
-        }
-
-        return automount_verify(a);
-}
-
-static void automount_set_state(Automount *a, AutomountState state) {
-        AutomountState old_state;
-        assert(a);
-
-        old_state = a->state;
-        a->state = state;
-
-        if (state != AUTOMOUNT_WAITING &&
-            state != AUTOMOUNT_RUNNING)
-                unmount_autofs(a);
-
-        if (state != old_state)
-                log_unit_debug(UNIT(a)->id,
-                               "%s changed %s -> %s",
-                               UNIT(a)->id,
-                               automount_state_to_string(old_state),
-                               automount_state_to_string(state));
-
-        unit_notify(UNIT(a), state_translation_table[old_state], state_translation_table[state], true);
-}
-
-static int automount_coldplug(Unit *u, Hashmap *deferred_work) {
-        Automount *a = AUTOMOUNT(u);
-        int r;
-
-        assert(a);
-        assert(a->state == AUTOMOUNT_DEAD);
-
-        if (a->deserialized_state != a->state) {
-
-                r = open_dev_autofs(u->manager);
-                if (r < 0)
-                        return r;
-
-                if (a->deserialized_state == AUTOMOUNT_WAITING ||
-                    a->deserialized_state == AUTOMOUNT_RUNNING) {
-
-                        assert(a->pipe_fd >= 0);
-
-                        r = sd_event_add_io(u->manager->event, &a->pipe_event_source, a->pipe_fd, EPOLLIN, automount_dispatch_io, u);
-                        if (r < 0)
-                                return r;
-                }
-
-                automount_set_state(a, a->deserialized_state);
-        }
-
-        return 0;
-}
-
-static void automount_dump(Unit *u, FILE *f, const char *prefix) {
-        Automount *a = AUTOMOUNT(u);
-
-        assert(a);
-
-        fprintf(f,
-                "%sAutomount State: %s\n"
-                "%sResult: %s\n"
-                "%sWhere: %s\n"
-                "%sDirectoryMode: %04o\n",
-                prefix, automount_state_to_string(a->state),
-                prefix, automount_result_to_string(a->result),
-                prefix, a->where,
-                prefix, a->directory_mode);
-}
-
-static void automount_enter_dead(Automount *a, AutomountResult f) {
-        assert(a);
-
-        if (f != AUTOMOUNT_SUCCESS)
-                a->result = f;
-
-        automount_set_state(a, a->result != AUTOMOUNT_SUCCESS ? AUTOMOUNT_FAILED : AUTOMOUNT_DEAD);
-}
-
-static int open_dev_autofs(Manager *m) {
-        struct autofs_dev_ioctl param;
-
-        assert(m);
-
-        if (m->dev_autofs_fd >= 0)
-                return m->dev_autofs_fd;
-
-        label_fix("/dev/autofs", false, false);
-
-        m->dev_autofs_fd = open("/dev/autofs", O_CLOEXEC|O_RDONLY);
-        if (m->dev_autofs_fd < 0)
-                return log_error_errno(errno, "Failed to open /dev/autofs: %m");
-
-        init_autofs_dev_ioctl(&param);
-        if (ioctl(m->dev_autofs_fd, AUTOFS_DEV_IOCTL_VERSION, &param) < 0) {
-                m->dev_autofs_fd = safe_close(m->dev_autofs_fd);
-                return -errno;
-        }
-
-        log_debug("Autofs kernel version %i.%i", param.ver_major, param.ver_minor);
-
-        return m->dev_autofs_fd;
-}
-
-static int open_ioctl_fd(int dev_autofs_fd, const char *where, dev_t devid) {
-        struct autofs_dev_ioctl *param;
-        size_t l;
-
-        assert(dev_autofs_fd >= 0);
-        assert(where);
-
-        l = sizeof(struct autofs_dev_ioctl) + strlen(where) + 1;
-        param = alloca(l);
-
-        init_autofs_dev_ioctl(param);
-        param->size = l;
-        param->ioctlfd = -1;
-        param->openmount.devid = devid;
-        strcpy(param->path, where);
-
-        if (ioctl(dev_autofs_fd, AUTOFS_DEV_IOCTL_OPENMOUNT, param) < 0)
-                return -errno;
-
-        if (param->ioctlfd < 0)
-                return -EIO;
-
-        fd_cloexec(param->ioctlfd, true);
-        return param->ioctlfd;
-}
-
-static int autofs_protocol(int dev_autofs_fd, int ioctl_fd) {
-        uint32_t major, minor;
-        struct autofs_dev_ioctl param;
-
-        assert(dev_autofs_fd >= 0);
-        assert(ioctl_fd >= 0);
-
-        init_autofs_dev_ioctl(&param);
-        param.ioctlfd = ioctl_fd;
-
-        if (ioctl(dev_autofs_fd, AUTOFS_DEV_IOCTL_PROTOVER, &param) < 0)
-                return -errno;
-
-        major = param.protover.version;
-
-        init_autofs_dev_ioctl(&param);
-        param.ioctlfd = ioctl_fd;
-
-        if (ioctl(dev_autofs_fd, AUTOFS_DEV_IOCTL_PROTOSUBVER, &param) < 0)
-                return -errno;
-
-        minor = param.protosubver.sub_version;
-
-        log_debug("Autofs protocol version %i.%i", major, minor);
-        return 0;
-}
-
-static int autofs_set_timeout(int dev_autofs_fd, int ioctl_fd, time_t sec) {
-        struct autofs_dev_ioctl param;
-
-        assert(dev_autofs_fd >= 0);
-        assert(ioctl_fd >= 0);
-
-        init_autofs_dev_ioctl(&param);
-        param.ioctlfd = ioctl_fd;
-        param.timeout.timeout = sec;
-
-        if (ioctl(dev_autofs_fd, AUTOFS_DEV_IOCTL_TIMEOUT, &param) < 0)
-                return -errno;
-
-        return 0;
-}
-
-static int autofs_send_ready(int dev_autofs_fd, int ioctl_fd, uint32_t token, int status) {
-        struct autofs_dev_ioctl param;
-
-        assert(dev_autofs_fd >= 0);
-        assert(ioctl_fd >= 0);
-
-        init_autofs_dev_ioctl(&param);
-        param.ioctlfd = ioctl_fd;
-
-        if (status) {
-                param.fail.token = token;
-                param.fail.status = status;
-        } else
-                param.ready.token = token;
-
-        if (ioctl(dev_autofs_fd, status ? AUTOFS_DEV_IOCTL_FAIL : AUTOFS_DEV_IOCTL_READY, &param) < 0)
-                return -errno;
-
-        return 0;
-}
-
-int automount_send_ready(Automount *a, int status) {
-        _cleanup_close_ int ioctl_fd = -1;
-        unsigned token;
-        int r;
-
-        assert(a);
-        assert(status <= 0);
-
-        if (set_isempty(a->tokens))
-                return 0;
-
-        ioctl_fd = open_ioctl_fd(UNIT(a)->manager->dev_autofs_fd, a->where, a->dev_id);
-        if (ioctl_fd < 0)
-                return ioctl_fd;
-
-        if (status)
-                log_unit_debug_errno(UNIT(a)->id, status, "Sending failure: %m");
-        else
-                log_unit_debug(UNIT(a)->id, "Sending success.");
-
-        r = 0;
-
-        /* Autofs thankfully does not hand out 0 as a token */
-        while ((token = PTR_TO_UINT(set_steal_first(a->tokens)))) {
-                int k;
-
-                /* Autofs fun fact II:
-                 *
-                 * if you pass a positive status code here, the kernel will
-                 * freeze! Yay! */
-
-                k = autofs_send_ready(UNIT(a)->manager->dev_autofs_fd,
-                                      ioctl_fd,
-                                      token,
-                                      status);
-                if (k < 0)
-                        r = k;
-        }
-
-        return r;
-}
-
-static void automount_enter_waiting(Automount *a) {
-        _cleanup_close_ int ioctl_fd = -1;
-        int p[2] = { -1, -1 };
-        char name[sizeof("systemd-")-1 + DECIMAL_STR_MAX(pid_t) + 1];
-        char options[sizeof("fd=,pgrp=,minproto=5,maxproto=5,direct")-1
-                     + DECIMAL_STR_MAX(int) + DECIMAL_STR_MAX(gid_t) + 1];
-        bool mounted = false;
-        int r, dev_autofs_fd;
-        struct stat st;
-
-        assert(a);
-        assert(a->pipe_fd < 0);
-        assert(a->where);
-
-        if (a->tokens)
-                set_clear(a->tokens);
-
-        dev_autofs_fd = open_dev_autofs(UNIT(a)->manager);
-        if (dev_autofs_fd < 0) {
-                r = dev_autofs_fd;
-                goto fail;
-        }
-
-        /* We knowingly ignore the results of this call */
-        mkdir_p_label(a->where, 0555);
-
-        warn_if_dir_nonempty(a->meta.id, a->where);
-
-        if (pipe2(p, O_NONBLOCK|O_CLOEXEC) < 0) {
-                r = -errno;
-                goto fail;
-        }
-
-        xsprintf(options, "fd=%i,pgrp="PID_FMT",minproto=5,maxproto=5,direct", p[1], getpgrp());
-        xsprintf(name, "systemd-"PID_FMT, getpid());
-        if (mount(name, a->where, "autofs", 0, options) < 0) {
-                r = -errno;
-                goto fail;
-        }
-
-        mounted = true;
-
-        p[1] = safe_close(p[1]);
-
-        if (stat(a->where, &st) < 0) {
-                r = -errno;
-                goto fail;
-        }
-
-        ioctl_fd = open_ioctl_fd(dev_autofs_fd, a->where, st.st_dev);
-        if (ioctl_fd < 0) {
-                r = ioctl_fd;
-                goto fail;
-        }
-
-        r = autofs_protocol(dev_autofs_fd, ioctl_fd);
-        if (r < 0)
-                goto fail;
-
-        r = autofs_set_timeout(dev_autofs_fd, ioctl_fd, 300);
-        if (r < 0)
-                goto fail;
-
-        /* Autofs fun fact:
-         *
-         * Unless we close the ioctl fd here, for some weird reason
-         * the direct mount will not receive events from the
-         * kernel. */
-
-        r = sd_event_add_io(UNIT(a)->manager->event, &a->pipe_event_source, p[0], EPOLLIN, automount_dispatch_io, a);
-        if (r < 0)
-                goto fail;
-
-        a->pipe_fd = p[0];
-        a->dev_id = st.st_dev;
-
-        automount_set_state(a, AUTOMOUNT_WAITING);
-
-        return;
-
-fail:
-        safe_close_pair(p);
-
-        if (mounted)
-                repeat_unmount(a->where);
-
-        log_unit_error(UNIT(a)->id,
-                       "Failed to initialize automounter: %s", strerror(-r));
-        automount_enter_dead(a, AUTOMOUNT_FAILURE_RESOURCES);
-}
-
-static void automount_enter_runnning(Automount *a) {
-        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        struct stat st;
-        int r;
-
-        assert(a);
-
-        /* We don't take mount requests anymore if we are supposed to
-         * shut down anyway */
-        if (unit_stop_pending(UNIT(a))) {
-                log_unit_debug(UNIT(a)->id,
-                               "Suppressing automount request on %s since unit stop is scheduled.", UNIT(a)->id);
-                automount_send_ready(a, -EHOSTDOWN);
-                return;
-        }
-
-        mkdir_p_label(a->where, a->directory_mode);
-
-        /* Before we do anything, let's see if somebody is playing games with us? */
-        if (lstat(a->where, &st) < 0) {
-                log_unit_warning(UNIT(a)->id,
-                                 "%s failed to stat automount point: %m", UNIT(a)->id);
-                goto fail;
-        }
-
-        if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id)
-                log_unit_info(UNIT(a)->id,
-                              "%s's automount point already active?", UNIT(a)->id);
-        else {
-                r = manager_add_job(UNIT(a)->manager, JOB_START, UNIT_TRIGGER(UNIT(a)),
-                                    JOB_REPLACE, true, &error, NULL);
-                if (r < 0) {
-                        log_unit_warning(UNIT(a)->id,
-                                         "%s failed to queue mount startup job: %s",
-                                         UNIT(a)->id, bus_error_message(&error, r));
-                        goto fail;
-                }
-        }
-
-        automount_set_state(a, AUTOMOUNT_RUNNING);
-        return;
-
-fail:
-        automount_enter_dead(a, AUTOMOUNT_FAILURE_RESOURCES);
-}
-
-static int automount_start(Unit *u) {
-        Automount *a = AUTOMOUNT(u);
-
-        assert(a);
-        assert(a->state == AUTOMOUNT_DEAD || a->state == AUTOMOUNT_FAILED);
-
-        if (path_is_mount_point(a->where, false)) {
-                log_unit_error(u->id,
-                               "Path %s is already a mount point, refusing start for %s",
-                               a->where, u->id);
-                return -EEXIST;
-        }
-
-        if (UNIT_TRIGGER(u)->load_state != UNIT_LOADED)
-                return -ENOENT;
-
-        a->result = AUTOMOUNT_SUCCESS;
-        automount_enter_waiting(a);
-        return 1;
-}
-
-static int automount_stop(Unit *u) {
-        Automount *a = AUTOMOUNT(u);
-
-        assert(a);
-        assert(a->state == AUTOMOUNT_WAITING || a->state == AUTOMOUNT_RUNNING);
-
-        automount_enter_dead(a, AUTOMOUNT_SUCCESS);
-        return 1;
-}
-
-static int automount_serialize(Unit *u, FILE *f, FDSet *fds) {
-        Automount *a = AUTOMOUNT(u);
-        void *p;
-        Iterator i;
-
-        assert(a);
-        assert(f);
-        assert(fds);
-
-        unit_serialize_item(u, f, "state", automount_state_to_string(a->state));
-        unit_serialize_item(u, f, "result", automount_result_to_string(a->result));
-        unit_serialize_item_format(u, f, "dev-id", "%u", (unsigned) a->dev_id);
-
-        SET_FOREACH(p, a->tokens, i)
-                unit_serialize_item_format(u, f, "token", "%u", PTR_TO_UINT(p));
-
-        if (a->pipe_fd >= 0) {
-                int copy;
-
-                copy = fdset_put_dup(fds, a->pipe_fd);
-                if (copy < 0)
-                        return copy;
-
-                unit_serialize_item_format(u, f, "pipe-fd", "%i", copy);
-        }
-
-        return 0;
-}
-
-static int automount_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
-        Automount *a = AUTOMOUNT(u);
-        int r;
-
-        assert(a);
-        assert(fds);
-
-        if (streq(key, "state")) {
-                AutomountState state;
-
-                state = automount_state_from_string(value);
-                if (state < 0)
-                        log_unit_debug(u->id, "Failed to parse state value %s", value);
-                else
-                        a->deserialized_state = state;
-        } else if (streq(key, "result")) {
-                AutomountResult f;
-
-                f = automount_result_from_string(value);
-                if (f < 0)
-                        log_unit_debug(u->id, "Failed to parse result value %s", value);
-                else if (f != AUTOMOUNT_SUCCESS)
-                        a->result = f;
-
-        } else if (streq(key, "dev-id")) {
-                unsigned d;
-
-                if (safe_atou(value, &d) < 0)
-                        log_unit_debug(u->id, "Failed to parse dev-id value %s", value);
-                else
-                        a->dev_id = (unsigned) d;
-        } else if (streq(key, "token")) {
-                unsigned token;
-
-                if (safe_atou(value, &token) < 0)
-                        log_unit_debug(u->id, "Failed to parse token value %s", value);
-                else {
-                        if (!a->tokens)
-                                if (!(a->tokens = set_new(NULL)))
-                                        return -ENOMEM;
-
-                        r = set_put(a->tokens, UINT_TO_PTR(token));
-                        if (r < 0)
-                                return r;
-                }
-        } else if (streq(key, "pipe-fd")) {
-                int fd;
-
-                if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
-                        log_unit_debug(u->id, "Failed to parse pipe-fd value %s", value);
-                else {
-                        safe_close(a->pipe_fd);
-                        a->pipe_fd = fdset_remove(fds, fd);
-                }
-        } else
-                log_unit_debug(u->id, "Unknown serialization key '%s'", key);
-
-        return 0;
-}
-
-static UnitActiveState automount_active_state(Unit *u) {
-        assert(u);
-
-        return state_translation_table[AUTOMOUNT(u)->state];
-}
-
-static const char *automount_sub_state_to_string(Unit *u) {
-        assert(u);
-
-        return automount_state_to_string(AUTOMOUNT(u)->state);
-}
-
-static bool automount_check_gc(Unit *u) {
-        assert(u);
-
-        if (!UNIT_TRIGGER(u))
-                return false;
-
-        return UNIT_VTABLE(UNIT_TRIGGER(u))->check_gc(UNIT_TRIGGER(u));
-}
-
-static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, void *userdata) {
-        union autofs_v5_packet_union packet;
-        Automount *a = AUTOMOUNT(userdata);
-        int r;
-
-        assert(a);
-        assert(fd == a->pipe_fd);
-
-        if (events != EPOLLIN) {
-                log_unit_error(UNIT(a)->id, "Got invalid poll event on pipe.");
-                goto fail;
-        }
-
-        r = loop_read_exact(a->pipe_fd, &packet, sizeof(packet), true);
-        if (r < 0) {
-                log_unit_error_errno(UNIT(a)->id, r, "Invalid read from pipe: %m");
-                goto fail;
-        }
-
-        switch (packet.hdr.type) {
-
-        case autofs_ptype_missing_direct:
-
-                if (packet.v5_packet.pid > 0) {
-                        _cleanup_free_ char *p = NULL;
-
-                        get_process_comm(packet.v5_packet.pid, &p);
-                        log_unit_info(UNIT(a)->id,
-                                       "Got automount request for %s, triggered by %"PRIu32" (%s)",
-                                       a->where, packet.v5_packet.pid, strna(p));
-                } else
-                        log_unit_debug(UNIT(a)->id, "Got direct mount request on %s", a->where);
-
-                r = set_ensure_allocated(&a->tokens, NULL);
-                if (r < 0) {
-                        log_unit_error(UNIT(a)->id, "Failed to allocate token set.");
-                        goto fail;
-                }
-
-                r = set_put(a->tokens, UINT_TO_PTR(packet.v5_packet.wait_queue_token));
-                if (r < 0) {
-                        log_unit_error_errno(UNIT(a)->id, r, "Failed to remember token: %m");
-                        goto fail;
-                }
-
-                automount_enter_runnning(a);
-                break;
-
-        default:
-                log_unit_error(UNIT(a)->id, "Received unknown automount request %i", packet.hdr.type);
-                break;
-        }
-
-        return 0;
-
-fail:
-        automount_enter_dead(a, AUTOMOUNT_FAILURE_RESOURCES);
-        return 0;
-}
-
-static void automount_shutdown(Manager *m) {
-        assert(m);
-
-        m->dev_autofs_fd = safe_close(m->dev_autofs_fd);
-}
-
-static void automount_reset_failed(Unit *u) {
-        Automount *a = AUTOMOUNT(u);
-
-        assert(a);
-
-        if (a->state == AUTOMOUNT_FAILED)
-                automount_set_state(a, AUTOMOUNT_DEAD);
-
-        a->result = AUTOMOUNT_SUCCESS;
-}
-
-static bool automount_supported(Manager *m) {
-        static int supported = -1;
-
-        assert(m);
-
-        if (supported < 0)
-                supported = access("/dev/autofs", F_OK) >= 0;
-
-        return supported;
-}
-
-static const char* const automount_state_table[_AUTOMOUNT_STATE_MAX] = {
-        [AUTOMOUNT_DEAD] = "dead",
-        [AUTOMOUNT_WAITING] = "waiting",
-        [AUTOMOUNT_RUNNING] = "running",
-        [AUTOMOUNT_FAILED] = "failed"
-};
-
-DEFINE_STRING_TABLE_LOOKUP(automount_state, AutomountState);
-
-static const char* const automount_result_table[_AUTOMOUNT_RESULT_MAX] = {
-        [AUTOMOUNT_SUCCESS] = "success",
-        [AUTOMOUNT_FAILURE_RESOURCES] = "resources"
-};
-
-DEFINE_STRING_TABLE_LOOKUP(automount_result, AutomountResult);
-
-const UnitVTable automount_vtable = {
-        .object_size = sizeof(Automount),
-
-        .sections =
-                "Unit\0"
-                "Automount\0"
-                "Install\0",
-
-        .no_alias = true,
-        .no_instances = true,
-
-        .init = automount_init,
-        .load = automount_load,
-        .done = automount_done,
-
-        .coldplug = automount_coldplug,
-
-        .dump = automount_dump,
-
-        .start = automount_start,
-        .stop = automount_stop,
-
-        .serialize = automount_serialize,
-        .deserialize_item = automount_deserialize_item,
-
-        .active_state = automount_active_state,
-        .sub_state_to_string = automount_sub_state_to_string,
-
-        .check_gc = automount_check_gc,
-
-        .reset_failed = automount_reset_failed,
-
-        .bus_interface = "org.freedesktop.systemd1.Automount",
-        .bus_vtable = bus_automount_vtable,
-
-        .shutdown = automount_shutdown,
-        .supported = automount_supported,
-
-        .status_message_formats = {
-                .finished_start_job = {
-                        [JOB_DONE]       = "Set up automount %s.",
-                        [JOB_FAILED]     = "Failed to set up automount %s.",
-                        [JOB_DEPENDENCY] = "Dependency failed for %s.",
-                },
-                .finished_stop_job = {
-                        [JOB_DONE]       = "Unset automount %s.",
-                        [JOB_FAILED]     = "Failed to unset automount %s.",
-                },
-        },
-};
diff --git a/src/core/automount.h b/src/core/automount.h
deleted file mode 100644 (file)
index 60f5522..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-typedef struct Automount Automount;
-
-#include "unit.h"
-
-typedef enum AutomountState {
-        AUTOMOUNT_DEAD,
-        AUTOMOUNT_WAITING,
-        AUTOMOUNT_RUNNING,
-        AUTOMOUNT_FAILED,
-        _AUTOMOUNT_STATE_MAX,
-        _AUTOMOUNT_STATE_INVALID = -1
-} AutomountState;
-
-typedef enum AutomountResult {
-        AUTOMOUNT_SUCCESS,
-        AUTOMOUNT_FAILURE_RESOURCES,
-        _AUTOMOUNT_RESULT_MAX,
-        _AUTOMOUNT_RESULT_INVALID = -1
-} AutomountResult;
-
-struct Automount {
-        Unit meta;
-
-        AutomountState state, deserialized_state;
-
-        char *where;
-
-        int pipe_fd;
-        sd_event_source *pipe_event_source;
-        mode_t directory_mode;
-        dev_t dev_id;
-
-        Set *tokens;
-
-        AutomountResult result;
-};
-
-extern const UnitVTable automount_vtable;
-
-int automount_send_ready(Automount *a, int status);
-
-const char* automount_state_to_string(AutomountState i) _const_;
-AutomountState automount_state_from_string(const char *s) _pure_;
-
-const char* automount_result_to_string(AutomountResult i) _const_;
-AutomountResult automount_result_from_string(const char *s) _pure_;
diff --git a/src/core/bus-endpoint.c b/src/core/bus-endpoint.c
deleted file mode 100644 (file)
index 0c4b3e7..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Daniel Mack
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdlib.h>
-
-#include "kdbus.h"
-#include "bus-kernel.h"
-#include "bus-policy.h"
-#include "bus-endpoint.h"
-
-int bus_kernel_set_endpoint_policy(int fd, uid_t uid, BusEndpoint *ep) {
-
-        struct kdbus_cmd *update;
-        struct kdbus_item *n;
-        BusEndpointPolicy *po;
-        Iterator i;
-        size_t size;
-        int r;
-
-        size = ALIGN8(offsetof(struct kdbus_cmd, items));
-
-        HASHMAP_FOREACH(po, ep->policy_hash, i) {
-                size += ALIGN8(offsetof(struct kdbus_item, str) + strlen(po->name) + 1);
-                size += ALIGN8(offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access));
-        }
-
-        update = alloca0_align(size, 8);
-        update->size = size;
-
-        n = update->items;
-
-        HASHMAP_FOREACH(po, ep->policy_hash, i) {
-                n->type = KDBUS_ITEM_NAME;
-                n->size = offsetof(struct kdbus_item, str) + strlen(po->name) + 1;
-                strcpy(n->str, po->name);
-                n = KDBUS_ITEM_NEXT(n);
-
-                n->type = KDBUS_ITEM_POLICY_ACCESS;
-                n->size = offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access);
-
-                n->policy_access.type = KDBUS_POLICY_ACCESS_USER;
-                n->policy_access.access = bus_kernel_translate_access(po->access);
-                n->policy_access.id = uid;
-
-                n = KDBUS_ITEM_NEXT(n);
-        }
-
-        r = ioctl(fd, KDBUS_CMD_ENDPOINT_UPDATE, update);
-        if (r < 0)
-                return -errno;
-
-        return 0;
-}
-
-int bus_endpoint_new(BusEndpoint **ep) {
-        assert(ep);
-
-        *ep = new0(BusEndpoint, 1);
-        if (!*ep)
-                return -ENOMEM;
-
-        return 0;
-}
-
-int bus_endpoint_add_policy(BusEndpoint *ep, const char *name, BusPolicyAccess access) {
-        _cleanup_free_ BusEndpointPolicy *po = NULL;
-        _cleanup_free_ char *key = NULL;
-        int r;
-
-        assert(ep);
-        assert(name);
-        assert(access > _BUS_POLICY_ACCESS_INVALID && access < _BUS_POLICY_ACCESS_MAX);
-
-        /* check if we already have this name in the policy list. If we do, see if the new access level
-         * is higher than the exising one, and upgrade the entry in that case. Otherwise, do nothing.
-         */
-
-        if (ep->policy_hash) {
-                po = hashmap_get(ep->policy_hash, name);
-                if (po) {
-                        if (po->access < access)
-                                po->access = access;
-
-                        return 0;
-                }
-        } else {
-                ep->policy_hash = hashmap_new(&string_hash_ops);
-                if (!ep->policy_hash)
-                        return -ENOMEM;
-        }
-
-        po = new0(BusEndpointPolicy, 1);
-        if (!po)
-                return -ENOMEM;
-
-        key = strdup(name);
-        if (!key)
-                return -ENOMEM;
-
-        po->name = key;
-        po->access = access;
-
-        r = hashmap_put(ep->policy_hash, key, po);
-        if (r < 0)
-                return r;
-
-        po = NULL;
-        key = NULL;
-        return 0;
-}
-
-void bus_endpoint_free(BusEndpoint *endpoint) {
-        if (!endpoint)
-                return;
-
-        hashmap_free_free_free(endpoint->policy_hash);
-        free(endpoint);
-}
diff --git a/src/core/bus-endpoint.h b/src/core/bus-endpoint.h
deleted file mode 100644 (file)
index 4a31f4c..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Daniel Mack
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-typedef struct BusEndpoint BusEndpoint;
-typedef struct BusEndpointPolicy BusEndpointPolicy;
-
-#include "hashmap.h"
-#include "bus-policy.h"
-
-struct BusEndpointPolicy {
-        char *name;
-        BusPolicyAccess access;
-};
-
-struct BusEndpoint {
-        Hashmap *policy_hash;
-};
-
-int bus_endpoint_new(BusEndpoint **ep);
-void bus_endpoint_free(BusEndpoint *endpoint);
-
-int bus_endpoint_add_policy(BusEndpoint *ep, const char *name, BusPolicyAccess access);
-
-int bus_kernel_set_endpoint_policy(int fd, uid_t uid, BusEndpoint *ep);
diff --git a/src/core/bus-policy.c b/src/core/bus-policy.c
deleted file mode 100644 (file)
index 064eee1..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Daniel Mack
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdlib.h>
-
-#include "kdbus.h"
-#include "util.h"
-#include "bus-kernel.h"
-#include "bus-policy.h"
-
-int bus_kernel_translate_access(BusPolicyAccess access) {
-        assert(access >= 0);
-        assert(access < _BUS_POLICY_ACCESS_MAX);
-
-        switch (access) {
-
-        case BUS_POLICY_ACCESS_SEE:
-                return KDBUS_POLICY_SEE;
-
-        case BUS_POLICY_ACCESS_TALK:
-                return KDBUS_POLICY_TALK;
-
-        case BUS_POLICY_ACCESS_OWN:
-                return KDBUS_POLICY_OWN;
-
-        default:
-                assert_not_reached("Unknown policy access");
-        }
-}
-
-int bus_kernel_translate_policy(const BusNamePolicy *policy, struct kdbus_item *item) {
-        int r;
-
-        assert(policy);
-        assert(item);
-
-        switch (policy->type) {
-
-        case BUSNAME_POLICY_TYPE_USER: {
-                const char *user = policy->name;
-                uid_t uid;
-
-                r = get_user_creds(&user, &uid, NULL, NULL, NULL);
-                if (r < 0)
-                        return r;
-
-                item->policy_access.type = KDBUS_POLICY_ACCESS_USER;
-                item->policy_access.id = uid;
-                break;
-        }
-
-        case BUSNAME_POLICY_TYPE_GROUP: {
-                const char *group = policy->name;
-                gid_t gid;
-
-                r = get_group_creds(&group, &gid);
-                if (r < 0)
-                        return r;
-
-                item->policy_access.type = KDBUS_POLICY_ACCESS_GROUP;
-                item->policy_access.id = gid;
-                break;
-        }
-
-        default:
-                assert_not_reached("Unknown policy type");
-        }
-
-        item->policy_access.access = bus_kernel_translate_access(policy->access);
-
-        return 0;
-}
-
-int bus_kernel_make_starter(
-                int fd,
-                const char *name,
-                bool activating,
-                bool accept_fd,
-                BusNamePolicy *policy,
-                BusPolicyAccess world_policy) {
-
-        struct kdbus_cmd_free cmd_free = { .size = sizeof(cmd_free) };
-        struct kdbus_cmd_hello *hello;
-        struct kdbus_item *n;
-        size_t policy_cnt = 0;
-        BusNamePolicy *po;
-        size_t size;
-        int r;
-
-        assert(fd >= 0);
-        assert(name);
-
-        LIST_FOREACH(policy, po, policy)
-                policy_cnt++;
-
-        if (world_policy >= 0)
-                policy_cnt++;
-
-        size = offsetof(struct kdbus_cmd_hello, items) +
-               ALIGN8(offsetof(struct kdbus_item, str) + strlen(name) + 1) +
-               policy_cnt * ALIGN8(offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access));
-
-        hello = alloca0_align(size, 8);
-
-        n = hello->items;
-        strcpy(n->str, name);
-        n->size = offsetof(struct kdbus_item, str) + strlen(n->str) + 1;
-        n->type = KDBUS_ITEM_NAME;
-        n = KDBUS_ITEM_NEXT(n);
-
-        LIST_FOREACH(policy, po, policy) {
-                n->type = KDBUS_ITEM_POLICY_ACCESS;
-                n->size = offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access);
-
-                r = bus_kernel_translate_policy(po, n);
-                if (r < 0)
-                        return r;
-
-                n = KDBUS_ITEM_NEXT(n);
-        }
-
-        if (world_policy >= 0) {
-                n->type = KDBUS_ITEM_POLICY_ACCESS;
-                n->size = offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access);
-                n->policy_access.type = KDBUS_POLICY_ACCESS_WORLD;
-                n->policy_access.access = bus_kernel_translate_access(world_policy);
-        }
-
-        hello->size = size;
-        hello->flags =
-                (activating ? KDBUS_HELLO_ACTIVATOR : KDBUS_HELLO_POLICY_HOLDER) |
-                (accept_fd ? KDBUS_HELLO_ACCEPT_FD : 0);
-        hello->pool_size = KDBUS_POOL_SIZE;
-        hello->attach_flags_send = _KDBUS_ATTACH_ANY;
-        hello->attach_flags_recv = _KDBUS_ATTACH_ANY;
-
-        if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0)
-                return -errno;
-
-        /* not interested in any output values */
-        cmd_free.offset = hello->offset;
-        (void) ioctl(fd, KDBUS_CMD_FREE, &cmd_free);
-
-        /* The higher 32bit of the bus_flags fields are considered
-         * 'incompatible flags'. Refuse them all for now. */
-        if (hello->bus_flags > 0xFFFFFFFFULL)
-                return -EOPNOTSUPP;
-
-        return fd;
-}
-
-static const char* const bus_policy_access_table[_BUS_POLICY_ACCESS_MAX] = {
-        [BUS_POLICY_ACCESS_SEE] = "see",
-        [BUS_POLICY_ACCESS_TALK] = "talk",
-        [BUS_POLICY_ACCESS_OWN] = "own",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(bus_policy_access, BusPolicyAccess);
diff --git a/src/core/bus-policy.h b/src/core/bus-policy.h
deleted file mode 100644 (file)
index 3b04f54..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Daniel Mack
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "list.h"
-#include "macro.h"
-#include "kdbus.h"
-
-typedef struct BusNamePolicy BusNamePolicy;
-
-typedef enum BusPolicyAccess {
-        BUS_POLICY_ACCESS_SEE,
-        BUS_POLICY_ACCESS_TALK,
-        BUS_POLICY_ACCESS_OWN,
-        _BUS_POLICY_ACCESS_MAX,
-        _BUS_POLICY_ACCESS_INVALID = -1
-} BusPolicyAccess;
-
-typedef enum BusNamePolicyType {
-        BUSNAME_POLICY_TYPE_USER,
-        BUSNAME_POLICY_TYPE_GROUP,
-        _BUSNAME_POLICY_TYPE_MAX,
-        _BUSNAME_POLICY_TYPE_INVALID = -1
-} BusNamePolicyType;
-
-struct BusNamePolicy {
-        BusNamePolicyType type;
-        BusPolicyAccess access;
-
-        char *name;
-
-        LIST_FIELDS(BusNamePolicy, policy);
-};
-
-int bus_kernel_translate_access(BusPolicyAccess access);
-int bus_kernel_translate_policy(const BusNamePolicy *policy, struct kdbus_item *item);
-
-const char* bus_policy_access_to_string(BusPolicyAccess i) _const_;
-BusPolicyAccess bus_policy_access_from_string(const char *s) _pure_;
-
-int bus_kernel_make_starter(
-                int fd,
-                const char *name,
-                bool activating,
-                bool accept_fd,
-                BusNamePolicy *policy,
-                BusPolicyAccess world_policy);
diff --git a/src/core/busname.c b/src/core/busname.c
deleted file mode 100644 (file)
index 43d7607..0000000
+++ /dev/null
@@ -1,1066 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/mman.h>
-
-#include "special.h"
-#include "bus-kernel.h"
-#include "bus-internal.h"
-#include "bus-util.h"
-#include "service.h"
-#include "kdbus.h"
-#include "bus-policy.h"
-#include "dbus-busname.h"
-#include "busname.h"
-
-static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = {
-        [BUSNAME_DEAD] = UNIT_INACTIVE,
-        [BUSNAME_MAKING] = UNIT_ACTIVATING,
-        [BUSNAME_REGISTERED] = UNIT_ACTIVE,
-        [BUSNAME_LISTENING] = UNIT_ACTIVE,
-        [BUSNAME_RUNNING] = UNIT_ACTIVE,
-        [BUSNAME_SIGTERM] = UNIT_DEACTIVATING,
-        [BUSNAME_SIGKILL] = UNIT_DEACTIVATING,
-        [BUSNAME_FAILED] = UNIT_FAILED
-};
-
-static int busname_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata);
-static int busname_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata);
-
-static void busname_init(Unit *u) {
-        BusName *n = BUSNAME(u);
-
-        assert(u);
-        assert(u->load_state == UNIT_STUB);
-
-        n->starter_fd = -1;
-        n->accept_fd = true;
-        n->activating = true;
-
-        n->timeout_usec = u->manager->default_timeout_start_usec;
-}
-
-static void busname_unwatch_control_pid(BusName *n) {
-        assert(n);
-
-        if (n->control_pid <= 0)
-                return;
-
-        unit_unwatch_pid(UNIT(n), n->control_pid);
-        n->control_pid = 0;
-}
-
-static void busname_free_policy(BusName *n) {
-        BusNamePolicy *p;
-
-        assert(n);
-
-        while ((p = n->policy)) {
-                LIST_REMOVE(policy, n->policy, p);
-
-                free(p->name);
-                free(p);
-        }
-}
-
-static void busname_close_fd(BusName *n) {
-        assert(n);
-
-        n->starter_event_source = sd_event_source_unref(n->starter_event_source);
-        n->starter_fd = safe_close(n->starter_fd);
-}
-
-static void busname_done(Unit *u) {
-        BusName *n = BUSNAME(u);
-
-        assert(n);
-
-        free(n->name);
-        n->name = NULL;
-
-        busname_free_policy(n);
-        busname_unwatch_control_pid(n);
-        busname_close_fd(n);
-
-        unit_ref_unset(&n->service);
-
-        n->timer_event_source = sd_event_source_unref(n->timer_event_source);
-}
-
-static int busname_arm_timer(BusName *n) {
-        int r;
-
-        assert(n);
-
-        if (n->timeout_usec <= 0) {
-                n->timer_event_source = sd_event_source_unref(n->timer_event_source);
-                return 0;
-        }
-
-        if (n->timer_event_source) {
-                r = sd_event_source_set_time(n->timer_event_source, now(CLOCK_MONOTONIC) + n->timeout_usec);
-                if (r < 0)
-                        return r;
-
-                return sd_event_source_set_enabled(n->timer_event_source, SD_EVENT_ONESHOT);
-        }
-
-        return sd_event_add_time(
-                        UNIT(n)->manager->event,
-                        &n->timer_event_source,
-                        CLOCK_MONOTONIC,
-                        now(CLOCK_MONOTONIC) + n->timeout_usec, 0,
-                        busname_dispatch_timer, n);
-}
-
-static int busname_add_default_default_dependencies(BusName *n) {
-        int r;
-
-        assert(n);
-
-        r = unit_add_dependency_by_name(UNIT(n), UNIT_BEFORE, SPECIAL_BUSNAMES_TARGET, NULL, true);
-        if (r < 0)
-                return r;
-
-        if (UNIT(n)->manager->running_as == SYSTEMD_SYSTEM) {
-                r = unit_add_two_dependencies_by_name(UNIT(n), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true);
-                if (r < 0)
-                        return r;
-        }
-
-        return unit_add_two_dependencies_by_name(UNIT(n), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
-}
-
-static int busname_add_extras(BusName *n) {
-        Unit *u = UNIT(n);
-        int r;
-
-        assert(n);
-
-        if (!n->name) {
-                n->name = unit_name_to_prefix(u->id);
-                if (!n->name)
-                        return -ENOMEM;
-        }
-
-        if (!u->description) {
-                r = unit_set_description(u, n->name);
-                if (r < 0)
-                        return r;
-        }
-
-        if (n->activating) {
-                if (!UNIT_DEREF(n->service)) {
-                        Unit *x;
-
-                        r = unit_load_related_unit(u, ".service", &x);
-                        if (r < 0)
-                                return r;
-
-                        unit_ref_set(&n->service, x);
-                }
-
-                r = unit_add_two_dependencies(u, UNIT_BEFORE, UNIT_TRIGGERS, UNIT_DEREF(n->service), true);
-                if (r < 0)
-                        return r;
-        }
-
-        if (u->default_dependencies) {
-                r = busname_add_default_default_dependencies(n);
-                if (r < 0)
-                        return r;
-        }
-
-        return 0;
-}
-
-static int busname_verify(BusName *n) {
-        char *e;
-
-        assert(n);
-
-        if (UNIT(n)->load_state != UNIT_LOADED)
-                return 0;
-
-        if (!service_name_is_valid(n->name)) {
-                log_unit_error(UNIT(n)->id, "%s's Name= setting is not a valid service name Refusing.", UNIT(n)->id);
-                return -EINVAL;
-        }
-
-        e = strjoina(n->name, ".busname");
-        if (!unit_has_name(UNIT(n), e)) {
-                log_unit_error(UNIT(n)->id, "%s's Name= setting doesn't match unit name. Refusing.", UNIT(n)->id);
-                return -EINVAL;
-        }
-
-        return 0;
-}
-
-static int busname_load(Unit *u) {
-        BusName *n = BUSNAME(u);
-        int r;
-
-        assert(u);
-        assert(u->load_state == UNIT_STUB);
-
-        r = unit_load_fragment_and_dropin(u);
-        if (r < 0)
-                return r;
-
-        if (u->load_state == UNIT_LOADED) {
-                /* This is a new unit? Then let's add in some extras */
-                r = busname_add_extras(n);
-                if (r < 0)
-                        return r;
-        }
-
-        return busname_verify(n);
-}
-
-static void busname_dump(Unit *u, FILE *f, const char *prefix) {
-        BusName *n = BUSNAME(u);
-
-        assert(n);
-        assert(f);
-
-        fprintf(f,
-                "%sBus Name State: %s\n"
-                "%sResult: %s\n"
-                "%sName: %s\n"
-                "%sActivating: %s\n"
-                "%sAccept FD: %s\n",
-                prefix, busname_state_to_string(n->state),
-                prefix, busname_result_to_string(n->result),
-                prefix, n->name,
-                prefix, yes_no(n->activating),
-                prefix, yes_no(n->accept_fd));
-
-        if (n->control_pid > 0)
-                fprintf(f,
-                        "%sControl PID: "PID_FMT"\n",
-                        prefix, n->control_pid);
-}
-
-static void busname_unwatch_fd(BusName *n) {
-        int r;
-
-        assert(n);
-
-        if (!n->starter_event_source)
-                return;
-
-        r = sd_event_source_set_enabled(n->starter_event_source, SD_EVENT_OFF);
-        if (r < 0)
-                log_unit_debug(UNIT(n)->id, "Failed to disable event source.");
-}
-
-static int busname_watch_fd(BusName *n) {
-        int r;
-
-        assert(n);
-
-        if (n->starter_fd < 0)
-                return 0;
-
-        if (n->starter_event_source)
-                r = sd_event_source_set_enabled(n->starter_event_source, SD_EVENT_ON);
-        else
-                r = sd_event_add_io(UNIT(n)->manager->event, &n->starter_event_source, n->starter_fd, EPOLLIN, busname_dispatch_io, n);
-        if (r < 0) {
-                log_unit_warning_errno(UNIT(n)->id, r, "Failed to watch starter fd: %m");
-                busname_unwatch_fd(n);
-                return r;
-        }
-
-        return 0;
-}
-
-static int busname_open_fd(BusName *n) {
-        _cleanup_free_ char *path = NULL;
-        const char *mode;
-
-        assert(n);
-
-        if (n->starter_fd >= 0)
-                return 0;
-
-        mode = UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user";
-        n->starter_fd = bus_kernel_open_bus_fd(mode, &path);
-        if (n->starter_fd < 0)
-                return log_unit_warning_errno(UNIT(n)->id, n->starter_fd, "Failed to open %s: %m", path ?: "kdbus");
-
-        return 0;
-}
-
-static void busname_set_state(BusName *n, BusNameState state) {
-        BusNameState old_state;
-        assert(n);
-
-        old_state = n->state;
-        n->state = state;
-
-        if (!IN_SET(state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {
-                n->timer_event_source = sd_event_source_unref(n->timer_event_source);
-                busname_unwatch_control_pid(n);
-        }
-
-        if (state != BUSNAME_LISTENING)
-                busname_unwatch_fd(n);
-
-        if (!IN_SET(state, BUSNAME_LISTENING, BUSNAME_MAKING, BUSNAME_REGISTERED, BUSNAME_RUNNING))
-                busname_close_fd(n);
-
-        if (state != old_state)
-                log_unit_debug(UNIT(n)->id, "%s changed %s -> %s",
-                               UNIT(n)->id, busname_state_to_string(old_state), busname_state_to_string(state));
-
-        unit_notify(UNIT(n), state_translation_table[old_state], state_translation_table[state], true);
-}
-
-static int busname_coldplug(Unit *u, Hashmap *deferred_work) {
-        BusName *n = BUSNAME(u);
-        int r;
-
-        assert(n);
-        assert(n->state == BUSNAME_DEAD);
-
-        if (n->deserialized_state == n->state)
-                return 0;
-
-        if (IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {
-
-                if (n->control_pid <= 0)
-                        return -EBADMSG;
-
-                r = unit_watch_pid(UNIT(n), n->control_pid);
-                if (r < 0)
-                        return r;
-
-                r = busname_arm_timer(n);
-                if (r < 0)
-                        return r;
-        }
-
-        if (IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_LISTENING, BUSNAME_REGISTERED, BUSNAME_RUNNING)) {
-                r = busname_open_fd(n);
-                if (r < 0)
-                        return r;
-        }
-
-        if (n->deserialized_state == BUSNAME_LISTENING) {
-                r = busname_watch_fd(n);
-                if (r < 0)
-                        return r;
-        }
-
-        busname_set_state(n, n->deserialized_state);
-        return 0;
-}
-
-static int busname_make_starter(BusName *n, pid_t *_pid) {
-        pid_t pid;
-        int r;
-
-        r = busname_arm_timer(n);
-        if (r < 0)
-                goto fail;
-
-        /* We have to resolve the user/group names out-of-process,
-         * hence let's fork here. It's messy, but well, what can we
-         * do? */
-
-        pid = fork();
-        if (pid < 0)
-                return -errno;
-
-        if (pid == 0) {
-                int ret;
-
-                default_signals(SIGNALS_CRASH_HANDLER, SIGNALS_IGNORE, -1);
-                ignore_signals(SIGPIPE, -1);
-                log_forget_fds();
-
-                r = bus_kernel_make_starter(n->starter_fd, n->name, n->activating, n->accept_fd, n->policy, n->policy_world);
-                if (r < 0) {
-                        ret = EXIT_MAKE_STARTER;
-                        goto fail_child;
-                }
-
-                _exit(0);
-
-        fail_child:
-                log_open();
-                log_error_errno(r, "Failed to create starter connection at step %s: %m", exit_status_to_string(ret, EXIT_STATUS_SYSTEMD));
-
-                _exit(ret);
-        }
-
-        r = unit_watch_pid(UNIT(n), pid);
-        if (r < 0)
-                goto fail;
-
-        *_pid = pid;
-        return 0;
-
-fail:
-        n->timer_event_source = sd_event_source_unref(n->timer_event_source);
-        return r;
-}
-
-static void busname_enter_dead(BusName *n, BusNameResult f) {
-        assert(n);
-
-        if (f != BUSNAME_SUCCESS)
-                n->result = f;
-
-        busname_set_state(n, n->result != BUSNAME_SUCCESS ? BUSNAME_FAILED : BUSNAME_DEAD);
-}
-
-static void busname_enter_signal(BusName *n, BusNameState state, BusNameResult f) {
-        KillContext kill_context = {};
-        int r;
-
-        assert(n);
-
-        if (f != BUSNAME_SUCCESS)
-                n->result = f;
-
-        kill_context_init(&kill_context);
-
-        r = unit_kill_context(UNIT(n),
-                              &kill_context,
-                              state != BUSNAME_SIGTERM ? KILL_KILL : KILL_TERMINATE,
-                              -1,
-                              n->control_pid,
-                              false);
-        if (r < 0) {
-                log_unit_warning_errno(UNIT(n)->id, r, "%s failed to kill control process: %m", UNIT(n)->id);
-                goto fail;
-        }
-
-        if (r > 0) {
-                r = busname_arm_timer(n);
-                if (r < 0) {
-                        log_unit_warning_errno(UNIT(n)->id, r, "%s failed to arm timer: %m", UNIT(n)->id);
-                        goto fail;
-                }
-
-                busname_set_state(n, state);
-        } else if (state == BUSNAME_SIGTERM)
-                busname_enter_signal(n, BUSNAME_SIGKILL, BUSNAME_SUCCESS);
-        else
-                busname_enter_dead(n, BUSNAME_SUCCESS);
-
-        return;
-
-fail:
-        busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
-}
-
-static void busname_enter_listening(BusName *n) {
-        int r;
-
-        assert(n);
-
-        if (n->activating) {
-                r = busname_watch_fd(n);
-                if (r < 0) {
-                        log_unit_warning_errno(UNIT(n)->id, r, "%s failed to watch names: %m", UNIT(n)->id);
-                        goto fail;
-                }
-
-                busname_set_state(n, BUSNAME_LISTENING);
-        } else
-                busname_set_state(n, BUSNAME_REGISTERED);
-
-        return;
-
-fail:
-        busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_FAILURE_RESOURCES);
-}
-
-static void busname_enter_making(BusName *n) {
-        int r;
-
-        assert(n);
-
-        r = busname_open_fd(n);
-        if (r < 0)
-                goto fail;
-
-        if (n->policy) {
-                /* If there is a policy, we need to resolve user/group
-                 * names, which we can't do from PID1, hence let's
-                 * fork. */
-                busname_unwatch_control_pid(n);
-
-                r = busname_make_starter(n, &n->control_pid);
-                if (r < 0) {
-                        log_unit_warning_errno(UNIT(n)->id, r, "%s failed to fork 'making' task: %m", UNIT(n)->id);
-                        goto fail;
-                }
-
-                busname_set_state(n, BUSNAME_MAKING);
-        } else {
-                /* If there is no policy, we can do everything
-                 * directly from PID 1, hence do so. */
-
-                r = bus_kernel_make_starter(n->starter_fd, n->name, n->activating, n->accept_fd, NULL, n->policy_world);
-                if (r < 0) {
-                        log_unit_warning_errno(UNIT(n)->id, r, "%s failed to make starter: %m", UNIT(n)->id);
-                        goto fail;
-                }
-
-                busname_enter_listening(n);
-        }
-
-        return;
-
-fail:
-        busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
-}
-
-static void busname_enter_running(BusName *n) {
-        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        bool pending = false;
-        Unit *other;
-        Iterator i;
-        int r;
-
-        assert(n);
-
-        if (!n->activating)
-                return;
-
-        /* We don't take conenctions anymore if we are supposed to
-         * shut down anyway */
-
-        if (unit_stop_pending(UNIT(n))) {
-                log_unit_debug(UNIT(n)->id, "Suppressing activation request on %s since unit stop is scheduled.", UNIT(n)->id);
-
-                /* Flush all queued activation reqeuest by closing and reopening the connection */
-                bus_kernel_drop_one(n->starter_fd);
-
-                busname_enter_listening(n);
-                return;
-        }
-
-        /* If there's already a start pending don't bother to do
-         * anything */
-        SET_FOREACH(other, UNIT(n)->dependencies[UNIT_TRIGGERS], i)
-                if (unit_active_or_pending(other)) {
-                        pending = true;
-                        break;
-                }
-
-        if (!pending) {
-                r = manager_add_job(UNIT(n)->manager, JOB_START, UNIT_DEREF(n->service), JOB_REPLACE, true, &error, NULL);
-                if (r < 0)
-                        goto fail;
-        }
-
-        busname_set_state(n, BUSNAME_RUNNING);
-        return;
-
-fail:
-        log_unit_warning(UNIT(n)->id, "%s failed to queue service startup job: %s", UNIT(n)->id, bus_error_message(&error, r));
-        busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
-}
-
-static int busname_start(Unit *u) {
-        BusName *n = BUSNAME(u);
-
-        assert(n);
-
-        /* We cannot fulfill this request right now, try again later
-         * please! */
-        if (IN_SET(n->state, BUSNAME_SIGTERM, BUSNAME_SIGKILL))
-                return -EAGAIN;
-
-        /* Already on it! */
-        if (n->state == BUSNAME_MAKING)
-                return 0;
-
-        if (n->activating && UNIT_ISSET(n->service)) {
-                Service *service;
-
-                service = SERVICE(UNIT_DEREF(n->service));
-
-                if (UNIT(service)->load_state != UNIT_LOADED) {
-                        log_unit_error(u->id, "Bus service %s not loaded, refusing.", UNIT(service)->id);
-                        return -ENOENT;
-                }
-        }
-
-        assert(IN_SET(n->state, BUSNAME_DEAD, BUSNAME_FAILED));
-
-        n->result = BUSNAME_SUCCESS;
-        busname_enter_making(n);
-
-        return 1;
-}
-
-static int busname_stop(Unit *u) {
-        BusName *n = BUSNAME(u);
-
-        assert(n);
-
-        /* Already on it */
-        if (IN_SET(n->state, BUSNAME_SIGTERM, BUSNAME_SIGKILL))
-                return 0;
-
-        /* If there's already something running, we go directly into
-         * kill mode. */
-
-        if (n->state == BUSNAME_MAKING) {
-                busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_SUCCESS);
-                return -EAGAIN;
-        }
-
-        assert(IN_SET(n->state, BUSNAME_REGISTERED, BUSNAME_LISTENING, BUSNAME_RUNNING));
-
-        busname_enter_dead(n, BUSNAME_SUCCESS);
-        return 1;
-}
-
-static int busname_serialize(Unit *u, FILE *f, FDSet *fds) {
-        BusName *n = BUSNAME(u);
-
-        assert(n);
-        assert(f);
-        assert(fds);
-
-        unit_serialize_item(u, f, "state", busname_state_to_string(n->state));
-        unit_serialize_item(u, f, "result", busname_result_to_string(n->result));
-
-        if (n->control_pid > 0)
-                unit_serialize_item_format(u, f, "control-pid", PID_FMT, n->control_pid);
-
-        if (n->starter_fd >= 0) {
-                int copy;
-
-                copy = fdset_put_dup(fds, n->starter_fd);
-                if (copy < 0)
-                        return copy;
-
-                unit_serialize_item_format(u, f, "starter-fd", "%i", copy);
-        }
-
-        return 0;
-}
-
-static int busname_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
-        BusName *n = BUSNAME(u);
-
-        assert(n);
-        assert(key);
-        assert(value);
-
-        if (streq(key, "state")) {
-                BusNameState state;
-
-                state = busname_state_from_string(value);
-                if (state < 0)
-                        log_unit_debug(u->id, "Failed to parse state value %s", value);
-                else
-                        n->deserialized_state = state;
-
-        } else if (streq(key, "result")) {
-                BusNameResult f;
-
-                f = busname_result_from_string(value);
-                if (f < 0)
-                        log_unit_debug(u->id, "Failed to parse result value %s", value);
-                else if (f != BUSNAME_SUCCESS)
-                        n->result = f;
-
-        } else if (streq(key, "control-pid")) {
-                pid_t pid;
-
-                if (parse_pid(value, &pid) < 0)
-                        log_unit_debug(u->id, "Failed to parse control-pid value %s", value);
-                else
-                        n->control_pid = pid;
-        } else if (streq(key, "starter-fd")) {
-                int fd;
-
-                if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
-                        log_unit_debug(u->id, "Failed to parse starter fd value %s", value);
-                else {
-                        safe_close(n->starter_fd);
-                        n->starter_fd = fdset_remove(fds, fd);
-                }
-        } else
-                log_unit_debug(u->id, "Unknown serialization key '%s'", key);
-
-        return 0;
-}
-
-_pure_ static UnitActiveState busname_active_state(Unit *u) {
-        assert(u);
-
-        return state_translation_table[BUSNAME(u)->state];
-}
-
-_pure_ static const char *busname_sub_state_to_string(Unit *u) {
-        assert(u);
-
-        return busname_state_to_string(BUSNAME(u)->state);
-}
-
-static int busname_peek_message(BusName *n) {
-        struct kdbus_cmd_recv cmd_recv = {
-                .size = sizeof(cmd_recv),
-                .flags = KDBUS_RECV_PEEK,
-        };
-        struct kdbus_cmd_free cmd_free = {
-                .size = sizeof(cmd_free),
-        };
-        const char *comm = NULL;
-        struct kdbus_item *d;
-        struct kdbus_msg *k;
-        size_t start, ps, sz, delta;
-        void *p = NULL;
-        pid_t pid = 0;
-        int r;
-
-        /* Generate a friendly debug log message about which process
-         * caused triggering of this bus name. This simply peeks the
-         * metadata of the first queued message and logs it. */
-
-        assert(n);
-
-        /* Let's shortcut things a bit, if debug logging is turned off
-         * anyway. */
-
-        if (log_get_max_level() < LOG_DEBUG)
-                return 0;
-
-        r = ioctl(n->starter_fd, KDBUS_CMD_RECV, &cmd_recv);
-        if (r < 0) {
-                if (errno == EINTR || errno == EAGAIN)
-                        return 0;
-
-                log_unit_error(UNIT(n)->id, "%s: Failed to query activation message: %m", UNIT(n)->id);
-                return -errno;
-        }
-
-        /* We map as late as possible, and unmap imemdiately after
-         * use. On 32bit address space is scarce and we want to be
-         * able to handle a lot of activator connections at the same
-         * time, and hence shouldn't keep the mmap()s around for
-         * longer than necessary. */
-
-        ps = page_size();
-        start = (cmd_recv.msg.offset / ps) * ps;
-        delta = cmd_recv.msg.offset - start;
-        sz = PAGE_ALIGN(delta + cmd_recv.msg.msg_size);
-
-        p = mmap(NULL, sz, PROT_READ, MAP_SHARED, n->starter_fd, start);
-        if (p == MAP_FAILED) {
-                log_unit_error(UNIT(n)->id, "%s: Failed to map activation message: %m", UNIT(n)->id);
-                r = -errno;
-                goto finish;
-        }
-
-        k = (struct kdbus_msg *) ((uint8_t *) p + delta);
-        KDBUS_ITEM_FOREACH(d, k, items) {
-                switch (d->type) {
-
-                case KDBUS_ITEM_PIDS:
-                        pid = d->pids.pid;
-                        break;
-
-                case KDBUS_ITEM_PID_COMM:
-                        comm = d->str;
-                        break;
-                }
-        }
-
-        if (pid > 0)
-                log_unit_debug(UNIT(n)->id, "%s: Activation triggered by process " PID_FMT " (%s)", UNIT(n)->id, pid, strna(comm));
-
-        r = 0;
-
-finish:
-        if (p)
-                (void) munmap(p, sz);
-
-        cmd_free.offset = cmd_recv.msg.offset;
-        if (ioctl(n->starter_fd, KDBUS_CMD_FREE, &cmd_free) < 0)
-                log_unit_warning(UNIT(n)->id, "Failed to free peeked message, ignoring: %m");
-
-        return r;
-}
-
-static int busname_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
-        BusName *n = userdata;
-
-        assert(n);
-        assert(fd >= 0);
-
-        if (n->state != BUSNAME_LISTENING)
-                return 0;
-
-        log_unit_debug(UNIT(n)->id, "Activation request on %s", UNIT(n)->id);
-
-        if (revents != EPOLLIN) {
-                log_unit_error(UNIT(n)->id, "%s: Got unexpected poll event (0x%x) on starter fd.",
-                               UNIT(n)->id, revents);
-                goto fail;
-        }
-
-        busname_peek_message(n);
-        busname_enter_running(n);
-        return 0;
-fail:
-
-        busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
-        return 0;
-}
-
-static void busname_sigchld_event(Unit *u, pid_t pid, int code, int status) {
-        BusName *n = BUSNAME(u);
-        BusNameResult f;
-
-        assert(n);
-        assert(pid >= 0);
-
-        if (pid != n->control_pid)
-                return;
-
-        n->control_pid = 0;
-
-        if (is_clean_exit(code, status, NULL))
-                f = BUSNAME_SUCCESS;
-        else if (code == CLD_EXITED)
-                f = BUSNAME_FAILURE_EXIT_CODE;
-        else if (code == CLD_KILLED)
-                f = BUSNAME_FAILURE_SIGNAL;
-        else if (code == CLD_DUMPED)
-                f = BUSNAME_FAILURE_CORE_DUMP;
-        else
-                assert_not_reached("Unknown sigchld code");
-
-        log_unit_full(u->id,
-                      f == BUSNAME_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
-                      "%s control process exited, code=%s status=%i",
-                      u->id, sigchld_code_to_string(code), status);
-
-        if (f != BUSNAME_SUCCESS)
-                n->result = f;
-
-        switch (n->state) {
-
-        case BUSNAME_MAKING:
-                if (f == BUSNAME_SUCCESS)
-                        busname_enter_listening(n);
-                else
-                        busname_enter_signal(n, BUSNAME_SIGTERM, f);
-                break;
-
-        case BUSNAME_SIGTERM:
-        case BUSNAME_SIGKILL:
-                busname_enter_dead(n, f);
-                break;
-
-        default:
-                assert_not_reached("Uh, control process died at wrong time.");
-        }
-
-        /* Notify clients about changed exit status */
-        unit_add_to_dbus_queue(u);
-}
-
-static int busname_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata) {
-        BusName *n = BUSNAME(userdata);
-
-        assert(n);
-        assert(n->timer_event_source == source);
-
-        switch (n->state) {
-
-        case BUSNAME_MAKING:
-                log_unit_warning(UNIT(n)->id, "%s making timed out. Terminating.", UNIT(n)->id);
-                busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_FAILURE_TIMEOUT);
-                break;
-
-        case BUSNAME_SIGTERM:
-                log_unit_warning(UNIT(n)->id, "%s stopping timed out. Killing.", UNIT(n)->id);
-                busname_enter_signal(n, BUSNAME_SIGKILL, BUSNAME_FAILURE_TIMEOUT);
-                break;
-
-        case BUSNAME_SIGKILL:
-                log_unit_warning(UNIT(n)->id, "%s still around after SIGKILL. Ignoring.", UNIT(n)->id);
-                busname_enter_dead(n, BUSNAME_FAILURE_TIMEOUT);
-                break;
-
-        default:
-                assert_not_reached("Timeout at wrong time.");
-        }
-
-        return 0;
-}
-
-static void busname_reset_failed(Unit *u) {
-        BusName *n = BUSNAME(u);
-
-        assert(n);
-
-        if (n->state == BUSNAME_FAILED)
-                busname_set_state(n, BUSNAME_DEAD);
-
-        n->result = BUSNAME_SUCCESS;
-}
-
-static void busname_trigger_notify(Unit *u, Unit *other) {
-        BusName *n = BUSNAME(u);
-        Service *s;
-
-        assert(n);
-        assert(other);
-
-        if (!IN_SET(n->state, BUSNAME_RUNNING, BUSNAME_LISTENING))
-                return;
-
-        if (other->load_state != UNIT_LOADED || other->type != UNIT_SERVICE)
-                return;
-
-        s = SERVICE(other);
-
-        if (s->state == SERVICE_FAILED && s->result == SERVICE_FAILURE_START_LIMIT)
-                busname_enter_dead(n, BUSNAME_FAILURE_SERVICE_FAILED_PERMANENT);
-        else if (IN_SET(s->state,
-                        SERVICE_DEAD, SERVICE_FAILED,
-                        SERVICE_STOP, SERVICE_STOP_SIGTERM, SERVICE_STOP_SIGKILL,
-                        SERVICE_STOP_POST, SERVICE_FINAL_SIGTERM, SERVICE_FINAL_SIGKILL,
-                        SERVICE_AUTO_RESTART))
-                busname_enter_listening(n);
-}
-
-static int busname_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
-        return unit_kill_common(u, who, signo, -1, BUSNAME(u)->control_pid, error);
-}
-
-static int busname_get_timeout(Unit *u, uint64_t *timeout) {
-        BusName *n = BUSNAME(u);
-        int r;
-
-        if (!n->timer_event_source)
-                return 0;
-
-        r = sd_event_source_get_time(n->timer_event_source, timeout);
-        if (r < 0)
-                return r;
-
-        return 1;
-}
-
-static bool busname_supported(Manager *m) {
-        static int supported = -1;
-        assert(m);
-
-        if (supported < 0)
-                supported = access("/sys/fs/kdbus", F_OK) >= 0;
-
-        return supported;
-}
-
-static const char* const busname_state_table[_BUSNAME_STATE_MAX] = {
-        [BUSNAME_DEAD] = "dead",
-        [BUSNAME_MAKING] = "making",
-        [BUSNAME_REGISTERED] = "registered",
-        [BUSNAME_LISTENING] = "listening",
-        [BUSNAME_RUNNING] = "running",
-        [BUSNAME_SIGTERM] = "sigterm",
-        [BUSNAME_SIGKILL] = "sigkill",
-        [BUSNAME_FAILED] = "failed",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(busname_state, BusNameState);
-
-static const char* const busname_result_table[_BUSNAME_RESULT_MAX] = {
-        [BUSNAME_SUCCESS] = "success",
-        [BUSNAME_FAILURE_RESOURCES] = "resources",
-        [BUSNAME_FAILURE_TIMEOUT] = "timeout",
-        [BUSNAME_FAILURE_EXIT_CODE] = "exit-code",
-        [BUSNAME_FAILURE_SIGNAL] = "signal",
-        [BUSNAME_FAILURE_CORE_DUMP] = "core-dump",
-        [BUSNAME_FAILURE_SERVICE_FAILED_PERMANENT] = "service-failed-permanent",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(busname_result, BusNameResult);
-
-const UnitVTable busname_vtable = {
-        .object_size = sizeof(BusName),
-
-        .sections =
-                "Unit\0"
-                "BusName\0"
-                "Install\0",
-        .private_section = "BusName",
-
-        .init = busname_init,
-        .done = busname_done,
-        .load = busname_load,
-
-        .coldplug = busname_coldplug,
-
-        .dump = busname_dump,
-
-        .start = busname_start,
-        .stop = busname_stop,
-
-        .kill = busname_kill,
-
-        .get_timeout = busname_get_timeout,
-
-        .serialize = busname_serialize,
-        .deserialize_item = busname_deserialize_item,
-
-        .active_state = busname_active_state,
-        .sub_state_to_string = busname_sub_state_to_string,
-
-        .sigchld_event = busname_sigchld_event,
-
-        .trigger_notify = busname_trigger_notify,
-
-        .reset_failed = busname_reset_failed,
-
-        .supported = busname_supported,
-
-        .bus_interface = "org.freedesktop.systemd1.BusName",
-        .bus_vtable = bus_busname_vtable,
-
-        .status_message_formats = {
-                .finished_start_job = {
-                        [JOB_DONE]       = "Listening on %s.",
-                        [JOB_FAILED]     = "Failed to listen on %s.",
-                        [JOB_DEPENDENCY] = "Dependency failed for %s.",
-                        [JOB_TIMEOUT]    = "Timed out starting %s.",
-                },
-                .finished_stop_job = {
-                        [JOB_DONE]       = "Closed %s.",
-                        [JOB_FAILED]     = "Failed stopping %s.",
-                        [JOB_TIMEOUT]    = "Timed out stopping %s.",
-                },
-        },
-};
diff --git a/src/core/busname.h b/src/core/busname.h
deleted file mode 100644 (file)
index 69528a2..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-typedef struct BusName BusName;
-typedef struct BusNamePolicy BusNamePolicy;
-
-
-typedef enum BusNameState {
-        BUSNAME_DEAD,
-        BUSNAME_MAKING,
-        BUSNAME_REGISTERED,
-        BUSNAME_LISTENING,
-        BUSNAME_RUNNING,
-        BUSNAME_SIGTERM,
-        BUSNAME_SIGKILL,
-        BUSNAME_FAILED,
-        _BUSNAME_STATE_MAX,
-        _BUSNAME_STATE_INVALID = -1
-} BusNameState;
-
-typedef enum BusNameResult {
-        BUSNAME_SUCCESS,
-        BUSNAME_FAILURE_RESOURCES,
-        BUSNAME_FAILURE_TIMEOUT,
-        BUSNAME_FAILURE_EXIT_CODE,
-        BUSNAME_FAILURE_SIGNAL,
-        BUSNAME_FAILURE_CORE_DUMP,
-        BUSNAME_FAILURE_SERVICE_FAILED_PERMANENT,
-        _BUSNAME_RESULT_MAX,
-        _BUSNAME_RESULT_INVALID = -1
-} BusNameResult;
-
-struct BusName {
-        Unit meta;
-
-        char *name;
-        int starter_fd;
-
-        bool activating;
-        bool accept_fd;
-
-        UnitRef service;
-
-        BusNameState state, deserialized_state;
-        BusNameResult result;
-
-        usec_t timeout_usec;
-
-        sd_event_source *starter_event_source;
-        sd_event_source *timer_event_source;
-
-        pid_t control_pid;
-
-        LIST_HEAD(BusNamePolicy, policy);
-        BusPolicyAccess policy_world;
-};
-
-extern const UnitVTable busname_vtable;
-
-const char* busname_state_to_string(BusNameState i) _const_;
-BusNameState busname_state_from_string(const char *s) _pure_;
-
-const char* busname_result_to_string(BusNameResult i) _const_;
-BusNameResult busname_result_from_string(const char *s) _pure_;
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
deleted file mode 100644 (file)
index b281377..0000000
+++ /dev/null
@@ -1,1136 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <fcntl.h>
-#include <fnmatch.h>
-
-#include "path-util.h"
-#include "special.h"
-#include "cgroup-util.h"
-#include "cgroup.h"
-
-#define CGROUP_CPU_QUOTA_PERIOD_USEC ((usec_t) 100 * USEC_PER_MSEC)
-
-void cgroup_context_init(CGroupContext *c) {
-        assert(c);
-
-        /* Initialize everything to the kernel defaults, assuming the
-         * structure is preinitialized to 0 */
-
-        c->cpu_shares = (unsigned long) -1;
-        c->startup_cpu_shares = (unsigned long) -1;
-        c->memory_limit = (uint64_t) -1;
-        c->blockio_weight = (unsigned long) -1;
-        c->startup_blockio_weight = (unsigned long) -1;
-
-        c->cpu_quota_per_sec_usec = USEC_INFINITY;
-}
-
-void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a) {
-        assert(c);
-        assert(a);
-
-        LIST_REMOVE(device_allow, c->device_allow, a);
-        free(a->path);
-        free(a);
-}
-
-void cgroup_context_free_blockio_device_weight(CGroupContext *c, CGroupBlockIODeviceWeight *w) {
-        assert(c);
-        assert(w);
-
-        LIST_REMOVE(device_weights, c->blockio_device_weights, w);
-        free(w->path);
-        free(w);
-}
-
-void cgroup_context_free_blockio_device_bandwidth(CGroupContext *c, CGroupBlockIODeviceBandwidth *b) {
-        assert(c);
-        assert(b);
-
-        LIST_REMOVE(device_bandwidths, c->blockio_device_bandwidths, b);
-        free(b->path);
-        free(b);
-}
-
-void cgroup_context_done(CGroupContext *c) {
-        assert(c);
-
-        while (c->blockio_device_weights)
-                cgroup_context_free_blockio_device_weight(c, c->blockio_device_weights);
-
-        while (c->blockio_device_bandwidths)
-                cgroup_context_free_blockio_device_bandwidth(c, c->blockio_device_bandwidths);
-
-        while (c->device_allow)
-                cgroup_context_free_device_allow(c, c->device_allow);
-}
-
-void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
-        CGroupBlockIODeviceBandwidth *b;
-        CGroupBlockIODeviceWeight *w;
-        CGroupDeviceAllow *a;
-        char u[FORMAT_TIMESPAN_MAX];
-
-        assert(c);
-        assert(f);
-
-        prefix = strempty(prefix);
-
-        fprintf(f,
-                "%sCPUAccounting=%s\n"
-                "%sBlockIOAccounting=%s\n"
-                "%sMemoryAccounting=%s\n"
-                "%sCPUShares=%lu\n"
-                "%sStartupCPUShares=%lu\n"
-                "%sCPUQuotaPerSecSec=%s\n"
-                "%sBlockIOWeight=%lu\n"
-                "%sStartupBlockIOWeight=%lu\n"
-                "%sMemoryLimit=%" PRIu64 "\n"
-                "%sDevicePolicy=%s\n"
-                "%sDelegate=%s\n",
-                prefix, yes_no(c->cpu_accounting),
-                prefix, yes_no(c->blockio_accounting),
-                prefix, yes_no(c->memory_accounting),
-                prefix, c->cpu_shares,
-                prefix, c->startup_cpu_shares,
-                prefix, format_timespan(u, sizeof(u), c->cpu_quota_per_sec_usec, 1),
-                prefix, c->blockio_weight,
-                prefix, c->startup_blockio_weight,
-                prefix, c->memory_limit,
-                prefix, cgroup_device_policy_to_string(c->device_policy),
-                prefix, yes_no(c->delegate));
-
-        LIST_FOREACH(device_allow, a, c->device_allow)
-                fprintf(f,
-                        "%sDeviceAllow=%s %s%s%s\n",
-                        prefix,
-                        a->path,
-                        a->r ? "r" : "", a->w ? "w" : "", a->m ? "m" : "");
-
-        LIST_FOREACH(device_weights, w, c->blockio_device_weights)
-                fprintf(f,
-                        "%sBlockIODeviceWeight=%s %lu",
-                        prefix,
-                        w->path,
-                        w->weight);
-
-        LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths) {
-                char buf[FORMAT_BYTES_MAX];
-
-                fprintf(f,
-                        "%s%s=%s %s\n",
-                        prefix,
-                        b->read ? "BlockIOReadBandwidth" : "BlockIOWriteBandwidth",
-                        b->path,
-                        format_bytes(buf, sizeof(buf), b->bandwidth));
-        }
-}
-
-static int lookup_blkio_device(const char *p, dev_t *dev) {
-        struct stat st;
-        int r;
-
-        assert(p);
-        assert(dev);
-
-        r = stat(p, &st);
-        if (r < 0)
-                return log_warning_errno(errno, "Couldn't stat device %s: %m", p);
-
-        if (S_ISBLK(st.st_mode))
-                *dev = st.st_rdev;
-        else if (major(st.st_dev) != 0) {
-                /* If this is not a device node then find the block
-                 * device this file is stored on */
-                *dev = st.st_dev;
-
-                /* If this is a partition, try to get the originating
-                 * block device */
-                block_get_whole_disk(*dev, dev);
-        } else {
-                log_warning("%s is not a block device and file system block device cannot be determined or is not local.", p);
-                return -ENODEV;
-        }
-
-        return 0;
-}
-
-static int whitelist_device(const char *path, const char *node, const char *acc) {
-        char buf[2+DECIMAL_STR_MAX(dev_t)*2+2+4];
-        struct stat st;
-        int r;
-
-        assert(path);
-        assert(acc);
-
-        if (stat(node, &st) < 0) {
-                log_warning("Couldn't stat device %s", node);
-                return -errno;
-        }
-
-        if (!S_ISCHR(st.st_mode) && !S_ISBLK(st.st_mode)) {
-                log_warning("%s is not a device.", node);
-                return -ENODEV;
-        }
-
-        sprintf(buf,
-                "%c %u:%u %s",
-                S_ISCHR(st.st_mode) ? 'c' : 'b',
-                major(st.st_rdev), minor(st.st_rdev),
-                acc);
-
-        r = cg_set_attribute("devices", path, "devices.allow", buf);
-        if (r < 0)
-                log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EINVAL) ? LOG_DEBUG : LOG_WARNING, r,
-                               "Failed to set devices.allow on %s: %m", path);
-
-        return r;
-}
-
-static int whitelist_major(const char *path, const char *name, char type, const char *acc) {
-        _cleanup_fclose_ FILE *f = NULL;
-        char line[LINE_MAX];
-        bool good = false;
-        int r;
-
-        assert(path);
-        assert(acc);
-        assert(type == 'b' || type == 'c');
-
-        f = fopen("/proc/devices", "re");
-        if (!f)
-                return log_warning_errno(errno, "Cannot open /proc/devices to resolve %s (%c): %m", name, type);
-
-        FOREACH_LINE(line, f, goto fail) {
-                char buf[2+DECIMAL_STR_MAX(unsigned)+3+4], *p, *w;
-                unsigned maj;
-
-                truncate_nl(line);
-
-                if (type == 'c' && streq(line, "Character devices:")) {
-                        good = true;
-                        continue;
-                }
-
-                if (type == 'b' && streq(line, "Block devices:")) {
-                        good = true;
-                        continue;
-                }
-
-                if (isempty(line)) {
-                        good = false;
-                        continue;
-                }
-
-                if (!good)
-                        continue;
-
-                p = strstrip(line);
-
-                w = strpbrk(p, WHITESPACE);
-                if (!w)
-                        continue;
-                *w = 0;
-
-                r = safe_atou(p, &maj);
-                if (r < 0)
-                        continue;
-                if (maj <= 0)
-                        continue;
-
-                w++;
-                w += strspn(w, WHITESPACE);
-
-                if (fnmatch(name, w, 0) != 0)
-                        continue;
-
-                sprintf(buf,
-                        "%c %u:* %s",
-                        type,
-                        maj,
-                        acc);
-
-                r = cg_set_attribute("devices", path, "devices.allow", buf);
-                if (r < 0)
-                        log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EINVAL) ? LOG_DEBUG : LOG_WARNING, r,
-                                       "Failed to set devices.allow on %s: %m", path);
-        }
-
-        return 0;
-
-fail:
-        log_warning_errno(errno, "Failed to read /proc/devices: %m");
-        return -errno;
-}
-
-void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const char *path, ManagerState state) {
-        bool is_root;
-        int r;
-
-        assert(c);
-        assert(path);
-
-        if (mask == 0)
-                return;
-
-        /* Some cgroup attributes are not supported on the root cgroup,
-         * hence silently ignore */
-        is_root = isempty(path) || path_equal(path, "/");
-        if (is_root)
-                /* Make sure we don't try to display messages with an empty path. */
-                path = "/";
-
-        /* We generally ignore errors caused by read-only mounted
-         * cgroup trees (assuming we are running in a container then),
-         * and missing cgroups, i.e. EROFS and ENOENT. */
-
-        if ((mask & CGROUP_CPU) && !is_root) {
-                char buf[MAX(DECIMAL_STR_MAX(unsigned long), DECIMAL_STR_MAX(usec_t)) + 1];
-
-                sprintf(buf, "%lu\n",
-                        IN_SET(state, MANAGER_STARTING, MANAGER_INITIALIZING) && c->startup_cpu_shares != (unsigned long) -1 ? c->startup_cpu_shares :
-                        c->cpu_shares != (unsigned long) -1 ? c->cpu_shares : 1024);
-                r = cg_set_attribute("cpu", path, "cpu.shares", buf);
-                if (r < 0)
-                        log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
-                                       "Failed to set cpu.shares on %s: %m", path);
-
-                sprintf(buf, USEC_FMT "\n", CGROUP_CPU_QUOTA_PERIOD_USEC);
-                r = cg_set_attribute("cpu", path, "cpu.cfs_period_us", buf);
-                if (r < 0)
-                        log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
-                                       "Failed to set cpu.cfs_period_us on %s: %m", path);
-
-                if (c->cpu_quota_per_sec_usec != USEC_INFINITY) {
-                        sprintf(buf, USEC_FMT "\n", c->cpu_quota_per_sec_usec * CGROUP_CPU_QUOTA_PERIOD_USEC / USEC_PER_SEC);
-                        r = cg_set_attribute("cpu", path, "cpu.cfs_quota_us", buf);
-                } else
-                        r = cg_set_attribute("cpu", path, "cpu.cfs_quota_us", "-1");
-                if (r < 0)
-                        log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
-                                       "Failed to set cpu.cfs_quota_us on %s: %m", path);
-        }
-
-        if (mask & CGROUP_BLKIO) {
-                char buf[MAX3(DECIMAL_STR_MAX(unsigned long)+1,
-                              DECIMAL_STR_MAX(dev_t)*2+2+DECIMAL_STR_MAX(unsigned long)*1,
-                              DECIMAL_STR_MAX(dev_t)*2+2+DECIMAL_STR_MAX(uint64_t)+1)];
-                CGroupBlockIODeviceWeight *w;
-                CGroupBlockIODeviceBandwidth *b;
-
-                if (!is_root) {
-                        sprintf(buf, "%lu\n", IN_SET(state, MANAGER_STARTING, MANAGER_INITIALIZING) && c->startup_blockio_weight != (unsigned long) -1 ? c->startup_blockio_weight :
-                                c->blockio_weight != (unsigned long) -1 ? c->blockio_weight : 1000);
-                        r = cg_set_attribute("blkio", path, "blkio.weight", buf);
-                        if (r < 0)
-                                log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
-                                               "Failed to set blkio.weight on %s: %m", path);
-
-                        /* FIXME: no way to reset this list */
-                        LIST_FOREACH(device_weights, w, c->blockio_device_weights) {
-                                dev_t dev;
-
-                                r = lookup_blkio_device(w->path, &dev);
-                                if (r < 0)
-                                        continue;
-
-                                sprintf(buf, "%u:%u %lu", major(dev), minor(dev), w->weight);
-                                r = cg_set_attribute("blkio", path, "blkio.weight_device", buf);
-                                if (r < 0)
-                                        log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
-                                                       "Failed to set blkio.weight_device on %s: %m", path);
-                        }
-                }
-
-                /* FIXME: no way to reset this list */
-                LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths) {
-                        const char *a;
-                        dev_t dev;
-
-                        r = lookup_blkio_device(b->path, &dev);
-                        if (r < 0)
-                                continue;
-
-                        a = b->read ? "blkio.throttle.read_bps_device" : "blkio.throttle.write_bps_device";
-
-                        sprintf(buf, "%u:%u %" PRIu64 "\n", major(dev), minor(dev), b->bandwidth);
-                        r = cg_set_attribute("blkio", path, a, buf);
-                        if (r < 0)
-                                log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
-                                               "Failed to set %s on %s: %m", a, path);
-                }
-        }
-
-        if ((mask & CGROUP_MEMORY) && !is_root) {
-                if (c->memory_limit != (uint64_t) -1) {
-                        char buf[DECIMAL_STR_MAX(uint64_t) + 1];
-
-                        sprintf(buf, "%" PRIu64 "\n", c->memory_limit);
-                        r = cg_set_attribute("memory", path, "memory.limit_in_bytes", buf);
-                } else
-                        r = cg_set_attribute("memory", path, "memory.limit_in_bytes", "-1");
-
-                if (r < 0)
-                        log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
-                                       "Failed to set memory.limit_in_bytes on %s: %m", path);
-        }
-
-        if ((mask & CGROUP_DEVICE) && !is_root) {
-                CGroupDeviceAllow *a;
-
-                /* Changing the devices list of a populated cgroup
-                 * might result in EINVAL, hence ignore EINVAL
-                 * here. */
-
-                if (c->device_allow || c->device_policy != CGROUP_AUTO)
-                        r = cg_set_attribute("devices", path, "devices.deny", "a");
-                else
-                        r = cg_set_attribute("devices", path, "devices.allow", "a");
-                if (r < 0)
-                        log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EINVAL) ? LOG_DEBUG : LOG_WARNING, r,
-                                       "Failed to reset devices.list on %s: %m", path);
-
-                if (c->device_policy == CGROUP_CLOSED ||
-                    (c->device_policy == CGROUP_AUTO && c->device_allow)) {
-                        static const char auto_devices[] =
-                                "/dev/null\0" "rwm\0"
-                                "/dev/zero\0" "rwm\0"
-                                "/dev/full\0" "rwm\0"
-                                "/dev/random\0" "rwm\0"
-                                "/dev/urandom\0" "rwm\0"
-                                "/dev/tty\0" "rwm\0"
-                                "/dev/pts/ptmx\0" "rw\0"; /* /dev/pts/ptmx may not be duplicated, but accessed */
-
-                        const char *x, *y;
-
-                        NULSTR_FOREACH_PAIR(x, y, auto_devices)
-                                whitelist_device(path, x, y);
-
-                        whitelist_major(path, "pts", 'c', "rw");
-                        whitelist_major(path, "kdbus", 'c', "rw");
-                        whitelist_major(path, "kdbus/*", 'c', "rw");
-                }
-
-                LIST_FOREACH(device_allow, a, c->device_allow) {
-                        char acc[4];
-                        unsigned k = 0;
-
-                        if (a->r)
-                                acc[k++] = 'r';
-                        if (a->w)
-                                acc[k++] = 'w';
-                        if (a->m)
-                                acc[k++] = 'm';
-
-                        if (k == 0)
-                                continue;
-
-                        acc[k++] = 0;
-
-                        if (startswith(a->path, "/dev/"))
-                                whitelist_device(path, a->path, acc);
-                        else if (startswith(a->path, "block-"))
-                                whitelist_major(path, a->path + 6, 'b', acc);
-                        else if (startswith(a->path, "char-"))
-                                whitelist_major(path, a->path + 5, 'c', acc);
-                        else
-                                log_debug("Ignoring device %s while writing cgroup attribute.", a->path);
-                }
-        }
-}
-
-CGroupControllerMask cgroup_context_get_mask(CGroupContext *c) {
-        CGroupControllerMask mask = 0;
-
-        /* Figure out which controllers we need */
-
-        if (c->cpu_accounting ||
-            c->cpu_shares != (unsigned long) -1 ||
-            c->startup_cpu_shares != (unsigned long) -1 ||
-            c->cpu_quota_per_sec_usec != USEC_INFINITY)
-                mask |= CGROUP_CPUACCT | CGROUP_CPU;
-
-        if (c->blockio_accounting ||
-            c->blockio_weight != (unsigned long) -1 ||
-            c->startup_blockio_weight != (unsigned long) -1 ||
-            c->blockio_device_weights ||
-            c->blockio_device_bandwidths)
-                mask |= CGROUP_BLKIO;
-
-        if (c->memory_accounting ||
-            c->memory_limit != (uint64_t) -1)
-                mask |= CGROUP_MEMORY;
-
-        if (c->device_allow ||
-            c->device_policy != CGROUP_AUTO)
-                mask |= CGROUP_DEVICE;
-
-        return mask;
-}
-
-CGroupControllerMask unit_get_cgroup_mask(Unit *u) {
-        CGroupContext *c;
-
-        c = unit_get_cgroup_context(u);
-        if (!c)
-                return 0;
-
-        /* If delegation is turned on, then turn on all cgroups,
-         * unless the process we fork into it is known to drop
-         * privileges anyway, and shouldn't get access to the
-         * controllers anyway. */
-
-        if (c->delegate) {
-                ExecContext *e;
-
-                e = unit_get_exec_context(u);
-                if (!e || exec_context_maintains_privileges(e))
-                        return _CGROUP_CONTROLLER_MASK_ALL;
-        }
-
-        return cgroup_context_get_mask(c);
-}
-
-CGroupControllerMask unit_get_members_mask(Unit *u) {
-        assert(u);
-
-        if (u->cgroup_members_mask_valid)
-                return u->cgroup_members_mask;
-
-        u->cgroup_members_mask = 0;
-
-        if (u->type == UNIT_SLICE) {
-                Unit *member;
-                Iterator i;
-
-                SET_FOREACH(member, u->dependencies[UNIT_BEFORE], i) {
-
-                        if (member == u)
-                                continue;
-
-                        if (UNIT_DEREF(member->slice) != u)
-                                continue;
-
-                        u->cgroup_members_mask |=
-                                unit_get_cgroup_mask(member) |
-                                unit_get_members_mask(member);
-                }
-        }
-
-        u->cgroup_members_mask_valid = true;
-        return u->cgroup_members_mask;
-}
-
-CGroupControllerMask unit_get_siblings_mask(Unit *u) {
-        assert(u);
-
-        if (UNIT_ISSET(u->slice))
-                return unit_get_members_mask(UNIT_DEREF(u->slice));
-
-        return unit_get_cgroup_mask(u) | unit_get_members_mask(u);
-}
-
-CGroupControllerMask unit_get_target_mask(Unit *u) {
-        CGroupControllerMask mask;
-
-        mask = unit_get_cgroup_mask(u) | unit_get_members_mask(u) | unit_get_siblings_mask(u);
-        mask &= u->manager->cgroup_supported;
-
-        return mask;
-}
-
-/* Recurse from a unit up through its containing slices, propagating
- * mask bits upward. A unit is also member of itself. */
-void unit_update_cgroup_members_masks(Unit *u) {
-        CGroupControllerMask m;
-        bool more;
-
-        assert(u);
-
-        /* Calculate subtree mask */
-        m = unit_get_cgroup_mask(u) | unit_get_members_mask(u);
-
-        /* See if anything changed from the previous invocation. If
-         * not, we're done. */
-        if (u->cgroup_subtree_mask_valid && m == u->cgroup_subtree_mask)
-                return;
-
-        more =
-                u->cgroup_subtree_mask_valid &&
-                ((m & ~u->cgroup_subtree_mask) != 0) &&
-                ((~m & u->cgroup_subtree_mask) == 0);
-
-        u->cgroup_subtree_mask = m;
-        u->cgroup_subtree_mask_valid = true;
-
-        if (UNIT_ISSET(u->slice)) {
-                Unit *s = UNIT_DEREF(u->slice);
-
-                if (more)
-                        /* There's more set now than before. We
-                         * propagate the new mask to the parent's mask
-                         * (not caring if it actually was valid or
-                         * not). */
-
-                        s->cgroup_members_mask |= m;
-
-                else
-                        /* There's less set now than before (or we
-                         * don't know), we need to recalculate
-                         * everything, so let's invalidate the
-                         * parent's members mask */
-
-                        s->cgroup_members_mask_valid = false;
-
-                /* And now make sure that this change also hits our
-                 * grandparents */
-                unit_update_cgroup_members_masks(s);
-        }
-}
-
-static const char *migrate_callback(CGroupControllerMask mask, void *userdata) {
-        Unit *u = userdata;
-
-        assert(mask != 0);
-        assert(u);
-
-        while (u) {
-                if (u->cgroup_path &&
-                    u->cgroup_realized &&
-                    (u->cgroup_realized_mask & mask) == mask)
-                        return u->cgroup_path;
-
-                u = UNIT_DEREF(u->slice);
-        }
-
-        return NULL;
-}
-
-static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
-        CGroupContext *c;
-        int r;
-
-        assert(u);
-
-        c = unit_get_cgroup_context(u);
-        if (!c)
-                return 0;
-
-        if (!u->cgroup_path) {
-                _cleanup_free_ char *path = NULL;
-
-                path = unit_default_cgroup_path(u);
-                if (!path)
-                        return log_oom();
-
-                r = hashmap_put(u->manager->cgroup_unit, path, u);
-                if (r < 0) {
-                        log_error(r == -EEXIST ? "cgroup %s exists already: %s" : "hashmap_put failed for %s: %s", path, strerror(-r));
-                        return r;
-                }
-                if (r > 0) {
-                        u->cgroup_path = path;
-                        path = NULL;
-                }
-        }
-
-        /* First, create our own group */
-        r = cg_create_everywhere(u->manager->cgroup_supported, mask, u->cgroup_path);
-        if (r < 0)
-                return log_error_errno(r, "Failed to create cgroup %s: %m", u->cgroup_path);
-
-        /* Keep track that this is now realized */
-        u->cgroup_realized = true;
-        u->cgroup_realized_mask = mask;
-
-        if (u->type != UNIT_SLICE && !c->delegate) {
-
-                /* Then, possibly move things over, but not if
-                 * subgroups may contain processes, which is the case
-                 * for slice and delegation units. */
-                r = cg_migrate_everywhere(u->manager->cgroup_supported, u->cgroup_path, u->cgroup_path, migrate_callback, u);
-                if (r < 0)
-                        log_warning_errno(r, "Failed to migrate cgroup from to %s: %m", u->cgroup_path);
-        }
-
-        return 0;
-}
-
-int unit_attach_pids_to_cgroup(Unit *u) {
-        int r;
-        assert(u);
-
-        r = unit_realize_cgroup(u);
-        if (r < 0)
-                return r;
-
-        r = cg_attach_many_everywhere(u->manager->cgroup_supported, u->cgroup_path, u->pids, migrate_callback, u);
-        if (r < 0)
-                return r;
-
-        return 0;
-}
-
-static bool unit_has_mask_realized(Unit *u, CGroupControllerMask mask) {
-        assert(u);
-
-        return u->cgroup_realized && u->cgroup_realized_mask == mask;
-}
-
-/* Check if necessary controllers and attributes for a unit are in place.
- *
- * If so, do nothing.
- * If not, create paths, move processes over, and set attributes.
- *
- * Returns 0 on success and < 0 on failure. */
-static int unit_realize_cgroup_now(Unit *u, ManagerState state) {
-        CGroupControllerMask mask;
-        int r;
-
-        assert(u);
-
-        if (u->in_cgroup_queue) {
-                LIST_REMOVE(cgroup_queue, u->manager->cgroup_queue, u);
-                u->in_cgroup_queue = false;
-        }
-
-        mask = unit_get_target_mask(u);
-
-        if (unit_has_mask_realized(u, mask))
-                return 0;
-
-        /* First, realize parents */
-        if (UNIT_ISSET(u->slice)) {
-                r = unit_realize_cgroup_now(UNIT_DEREF(u->slice), state);
-                if (r < 0)
-                        return r;
-        }
-
-        /* And then do the real work */
-        r = unit_create_cgroups(u, mask);
-        if (r < 0)
-                return r;
-
-        /* Finally, apply the necessary attributes. */
-        cgroup_context_apply(unit_get_cgroup_context(u), mask, u->cgroup_path, state);
-
-        return 0;
-}
-
-static void unit_add_to_cgroup_queue(Unit *u) {
-
-        if (u->in_cgroup_queue)
-                return;
-
-        LIST_PREPEND(cgroup_queue, u->manager->cgroup_queue, u);
-        u->in_cgroup_queue = true;
-}
-
-unsigned manager_dispatch_cgroup_queue(Manager *m) {
-        ManagerState state;
-        unsigned n = 0;
-        Unit *i;
-        int r;
-
-        state = manager_state(m);
-
-        while ((i = m->cgroup_queue)) {
-                assert(i->in_cgroup_queue);
-
-                r = unit_realize_cgroup_now(i, state);
-                if (r < 0)
-                        log_warning_errno(r, "Failed to realize cgroups for queued unit %s: %m", i->id);
-
-                n++;
-        }
-
-        return n;
-}
-
-static void unit_queue_siblings(Unit *u) {
-        Unit *slice;
-
-        /* This adds the siblings of the specified unit and the
-         * siblings of all parent units to the cgroup queue. (But
-         * neither the specified unit itself nor the parents.) */
-
-        while ((slice = UNIT_DEREF(u->slice))) {
-                Iterator i;
-                Unit *m;
-
-                SET_FOREACH(m, slice->dependencies[UNIT_BEFORE], i) {
-                        if (m == u)
-                                continue;
-
-                        /* Skip units that have a dependency on the slice
-                         * but aren't actually in it. */
-                        if (UNIT_DEREF(m->slice) != slice)
-                                continue;
-
-                        /* No point in doing cgroup application for units
-                         * without active processes. */
-                        if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(m)))
-                                continue;
-
-                        /* If the unit doesn't need any new controllers
-                         * and has current ones realized, it doesn't need
-                         * any changes. */
-                        if (unit_has_mask_realized(m, unit_get_target_mask(m)))
-                                continue;
-
-                        unit_add_to_cgroup_queue(m);
-                }
-
-                u = slice;
-        }
-}
-
-int unit_realize_cgroup(Unit *u) {
-        CGroupContext *c;
-
-        assert(u);
-
-        c = unit_get_cgroup_context(u);
-        if (!c)
-                return 0;
-
-        /* So, here's the deal: when realizing the cgroups for this
-         * unit, we need to first create all parents, but there's more
-         * actually: for the weight-based controllers we also need to
-         * make sure that all our siblings (i.e. units that are in the
-         * same slice as we are) have cgroups, too. Otherwise, things
-         * would become very uneven as each of their processes would
-         * get as much resources as all our group together. This call
-         * will synchronously create the parent cgroups, but will
-         * defer work on the siblings to the next event loop
-         * iteration. */
-
-        /* Add all sibling slices to the cgroup queue. */
-        unit_queue_siblings(u);
-
-        /* And realize this one now (and apply the values) */
-        return unit_realize_cgroup_now(u, manager_state(u->manager));
-}
-
-void unit_destroy_cgroup_if_empty(Unit *u) {
-        int r;
-
-        assert(u);
-
-        if (!u->cgroup_path)
-                return;
-
-        r = cg_trim_everywhere(u->manager->cgroup_supported, u->cgroup_path, !unit_has_name(u, SPECIAL_ROOT_SLICE));
-        if (r < 0) {
-                log_debug_errno(r, "Failed to destroy cgroup %s: %m", u->cgroup_path);
-                return;
-        }
-
-        hashmap_remove(u->manager->cgroup_unit, u->cgroup_path);
-
-        free(u->cgroup_path);
-        u->cgroup_path = NULL;
-        u->cgroup_realized = false;
-        u->cgroup_realized_mask = 0;
-}
-
-pid_t unit_search_main_pid(Unit *u) {
-        _cleanup_fclose_ FILE *f = NULL;
-        pid_t pid = 0, npid, mypid;
-
-        assert(u);
-
-        if (!u->cgroup_path)
-                return 0;
-
-        if (cg_enumerate_processes(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, &f) < 0)
-                return 0;
-
-        mypid = getpid();
-        while (cg_read_pid(f, &npid) > 0)  {
-                pid_t ppid;
-
-                if (npid == pid)
-                        continue;
-
-                /* Ignore processes that aren't our kids */
-                if (get_parent_of_pid(npid, &ppid) >= 0 && ppid != mypid)
-                        continue;
-
-                if (pid != 0) {
-                        /* Dang, there's more than one daemonized PID
-                        in this group, so we don't know what process
-                        is the main process. */
-                        pid = 0;
-                        break;
-                }
-
-                pid = npid;
-        }
-
-        return pid;
-}
-
-int manager_setup_cgroup(Manager *m) {
-        _cleanup_free_ char *path = NULL;
-        int r;
-
-        assert(m);
-
-        /* 1. Determine hierarchy */
-        free(m->cgroup_root);
-        m->cgroup_root = NULL;
-
-        r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, 0, &m->cgroup_root);
-        if (r < 0)
-                return log_error_errno(r, "Cannot determine cgroup we are running in: %m");
-
-        /* LEGACY: Already in /system.slice? If so, let's cut this
-         * off. This is to support live upgrades from older systemd
-         * versions where PID 1 was moved there. */
-        if (m->running_as == SYSTEMD_SYSTEM) {
-                char *e;
-
-                e = endswith(m->cgroup_root, "/" SPECIAL_SYSTEM_SLICE);
-                if (!e)
-                        e = endswith(m->cgroup_root, "/system");
-                if (e)
-                        *e = 0;
-        }
-
-        /* And make sure to store away the root value without trailing
-         * slash, even for the root dir, so that we can easily prepend
-         * it everywhere. */
-        if (streq(m->cgroup_root, "/"))
-                m->cgroup_root[0] = 0;
-
-        /* 2. Show data */
-        r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, NULL, &path);
-        if (r < 0)
-                return log_error_errno(r, "Cannot find cgroup mount point: %m");
-
-        log_debug("Using cgroup controller " SYSTEMD_CGROUP_CONTROLLER ". File system hierarchy is at %s.", path);
-        if (!m->test_run) {
-
-                /* 3. Install agent */
-                if (m->running_as == SYSTEMD_SYSTEM) {
-                        r = -EINVAL;
-                        // cg_install_release_agent(SYSTEMD_CGROUP_CONTROLLER, SYSTEMD_CGROUP_AGENT_PATH);
-                        if (r < 0)
-                                log_warning_errno(r, "Failed to install release agent, ignoring: %m");
-                        else if (r > 0)
-                                log_debug("Installed release agent.");
-                        else
-                                log_debug("Release agent already installed.");
-                }
-
-                /* 4. Make sure we are in the root cgroup */
-                r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, 0);
-                if (r < 0)
-                        return log_error_errno(r, "Failed to create root cgroup hierarchy: %m");
-
-                /* 5. And pin it, so that it cannot be unmounted */
-                safe_close(m->pin_cgroupfs_fd);
-
-                m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK);
-                if (m->pin_cgroupfs_fd < 0)
-                        return log_error_errno(errno, "Failed to open pin file: %m");
-
-                /* 6.  Always enable hierarchical support if it exists... */
-                cg_set_attribute("memory", "/", "memory.use_hierarchy", "1");
-        }
-
-        /* 7. Figure out which controllers are supported */
-        m->cgroup_supported = cg_mask_supported();
-
-        return 0;
-}
-
-void manager_shutdown_cgroup(Manager *m, bool delete) {
-        assert(m);
-
-        /* We can't really delete the group, since we are in it. But
-         * let's trim it. */
-        if (delete && m->cgroup_root)
-                cg_trim(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, false);
-
-        m->pin_cgroupfs_fd = safe_close(m->pin_cgroupfs_fd);
-
-        free(m->cgroup_root);
-        m->cgroup_root = NULL;
-}
-
-Unit* manager_get_unit_by_cgroup(Manager *m, const char *cgroup) {
-        char *p;
-        Unit *u;
-
-        assert(m);
-        assert(cgroup);
-
-        u = hashmap_get(m->cgroup_unit, cgroup);
-        if (u)
-                return u;
-
-        p = strdupa(cgroup);
-        for (;;) {
-                char *e;
-
-                e = strrchr(p, '/');
-                if (e == p || !e)
-                        return NULL;
-
-                *e = 0;
-
-                u = hashmap_get(m->cgroup_unit, p);
-                if (u)
-                        return u;
-        }
-}
-
-Unit *manager_get_unit_by_pid(Manager *m, pid_t pid) {
-        _cleanup_free_ char *cgroup = NULL;
-        int r;
-
-        assert(m);
-
-        if (pid <= 1)
-                return NULL;
-
-        r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid, &cgroup);
-        if (r < 0)
-                return NULL;
-
-        return manager_get_unit_by_cgroup(m, cgroup);
-}
-
-int manager_notify_cgroup_empty(Manager *m, const char *cgroup) {
-        Unit *u;
-        int r;
-
-        assert(m);
-        assert(cgroup);
-
-        u = manager_get_unit_by_cgroup(m, cgroup);
-        if (!u)
-                return 0;
-
-        r = cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, true);
-        if (r <= 0)
-                return r;
-
-        if (UNIT_VTABLE(u)->notify_cgroup_empty)
-                UNIT_VTABLE(u)->notify_cgroup_empty(u);
-
-        unit_add_to_gc_queue(u);
-        return 0;
-}
-
-int unit_get_memory_current(Unit *u, uint64_t *ret) {
-        _cleanup_free_ char *v = NULL;
-        int r;
-
-        assert(u);
-        assert(ret);
-
-        if (!u->cgroup_path)
-                return -ENODATA;
-
-        if ((u->cgroup_realized_mask & CGROUP_MEMORY) == 0)
-                return -ENODATA;
-
-        r = cg_get_attribute("memory", u->cgroup_path, "memory.usage_in_bytes", &v);
-        if (r == -ENOENT)
-                return -ENODATA;
-        if (r < 0)
-                return r;
-
-        return safe_atou64(v, ret);
-}
-
-static int unit_get_cpu_usage_raw(Unit *u, nsec_t *ret) {
-        _cleanup_free_ char *v = NULL;
-        uint64_t ns;
-        int r;
-
-        assert(u);
-        assert(ret);
-
-        if (!u->cgroup_path)
-                return -ENODATA;
-
-        if ((u->cgroup_realized_mask & CGROUP_CPUACCT) == 0)
-                return -ENODATA;
-
-        r = cg_get_attribute("cpuacct", u->cgroup_path, "cpuacct.usage", &v);
-        if (r == -ENOENT)
-                return -ENODATA;
-        if (r < 0)
-                return r;
-
-        r = safe_atou64(v, &ns);
-        if (r < 0)
-                return r;
-
-        *ret = ns;
-        return 0;
-}
-
-int unit_get_cpu_usage(Unit *u, nsec_t *ret) {
-        nsec_t ns;
-        int r;
-
-        r = unit_get_cpu_usage_raw(u, &ns);
-        if (r < 0)
-                return r;
-
-        if (ns > u->cpuacct_usage_base)
-                ns -= u->cpuacct_usage_base;
-        else
-                ns = 0;
-
-        *ret = ns;
-        return 0;
-}
-
-int unit_reset_cpu_usage(Unit *u) {
-        nsec_t ns;
-        int r;
-
-        assert(u);
-
-        r = unit_get_cpu_usage_raw(u, &ns);
-        if (r < 0) {
-                u->cpuacct_usage_base = 0;
-                return r;
-        }
-
-        u->cpuacct_usage_base = ns;
-        return 0;
-}
-
-static const char* const cgroup_device_policy_table[_CGROUP_DEVICE_POLICY_MAX] = {
-        [CGROUP_AUTO] = "auto",
-        [CGROUP_CLOSED] = "closed",
-        [CGROUP_STRICT] = "strict",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(cgroup_device_policy, CGroupDevicePolicy);
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
deleted file mode 100644 (file)
index 869ddae..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdbool.h>
-
-#include "list.h"
-#include "time-util.h"
-
-typedef struct CGroupContext CGroupContext;
-typedef struct CGroupDeviceAllow CGroupDeviceAllow;
-typedef struct CGroupBlockIODeviceWeight CGroupBlockIODeviceWeight;
-typedef struct CGroupBlockIODeviceBandwidth CGroupBlockIODeviceBandwidth;
-
-typedef enum CGroupDevicePolicy {
-
-        /* When devices listed, will allow those, plus built-in ones,
-        if none are listed will allow everything. */
-        CGROUP_AUTO,
-
-        /* Everything forbidden, except built-in ones and listed ones. */
-        CGROUP_CLOSED,
-
-        /* Everythings forbidden, except for the listed devices */
-        CGROUP_STRICT,
-
-        _CGROUP_DEVICE_POLICY_MAX,
-        _CGROUP_DEVICE_POLICY_INVALID = -1
-} CGroupDevicePolicy;
-
-struct CGroupDeviceAllow {
-        LIST_FIELDS(CGroupDeviceAllow, device_allow);
-        char *path;
-        bool r:1;
-        bool w:1;
-        bool m:1;
-};
-
-struct CGroupBlockIODeviceWeight {
-        LIST_FIELDS(CGroupBlockIODeviceWeight, device_weights);
-        char *path;
-        unsigned long weight;
-};
-
-struct CGroupBlockIODeviceBandwidth {
-        LIST_FIELDS(CGroupBlockIODeviceBandwidth, device_bandwidths);
-        char *path;
-        uint64_t bandwidth;
-        bool read;
-};
-
-struct CGroupContext {
-        bool cpu_accounting;
-        bool blockio_accounting;
-        bool memory_accounting;
-
-        unsigned long cpu_shares;
-        unsigned long startup_cpu_shares;
-        usec_t cpu_quota_per_sec_usec;
-
-        unsigned long blockio_weight;
-        unsigned long startup_blockio_weight;
-        LIST_HEAD(CGroupBlockIODeviceWeight, blockio_device_weights);
-        LIST_HEAD(CGroupBlockIODeviceBandwidth, blockio_device_bandwidths);
-
-        uint64_t memory_limit;
-
-        CGroupDevicePolicy device_policy;
-        LIST_HEAD(CGroupDeviceAllow, device_allow);
-
-        bool delegate;
-};
-
-#include "unit.h"
-#include "cgroup-util.h"
-
-void cgroup_context_init(CGroupContext *c);
-void cgroup_context_done(CGroupContext *c);
-void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix);
-void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const char *path, ManagerState state);
-
-CGroupControllerMask cgroup_context_get_mask(CGroupContext *c);
-
-void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a);
-void cgroup_context_free_blockio_device_weight(CGroupContext *c, CGroupBlockIODeviceWeight *w);
-void cgroup_context_free_blockio_device_bandwidth(CGroupContext *c, CGroupBlockIODeviceBandwidth *b);
-
-CGroupControllerMask unit_get_cgroup_mask(Unit *u);
-CGroupControllerMask unit_get_siblings_mask(Unit *u);
-CGroupControllerMask unit_get_members_mask(Unit *u);
-CGroupControllerMask unit_get_target_mask(Unit *u);
-
-void unit_update_cgroup_members_masks(Unit *u);
-int unit_realize_cgroup(Unit *u);
-void unit_destroy_cgroup_if_empty(Unit *u);
-int unit_attach_pids_to_cgroup(Unit *u);
-
-int manager_setup_cgroup(Manager *m);
-void manager_shutdown_cgroup(Manager *m, bool delete);
-
-unsigned manager_dispatch_cgroup_queue(Manager *m);
-
-Unit *manager_get_unit_by_cgroup(Manager *m, const char *cgroup);
-Unit* manager_get_unit_by_pid(Manager *m, pid_t pid);
-
-pid_t unit_search_main_pid(Unit *u);
-
-int manager_notify_cgroup_empty(Manager *m, const char *group);
-
-int unit_get_memory_current(Unit *u, uint64_t *ret);
-int unit_get_cpu_usage(Unit *u, nsec_t *ret);
-int unit_reset_cpu_usage(Unit *u);
-
-const char* cgroup_device_policy_to_string(CGroupDevicePolicy i) _const_;
-CGroupDevicePolicy cgroup_device_policy_from_string(const char *s) _pure_;
diff --git a/src/core/dbus-automount.c b/src/core/dbus-automount.c
deleted file mode 100644 (file)
index 38acbd0..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "automount.h"
-#include "dbus-automount.h"
-#include "bus-util.h"
-
-static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, automount_result, AutomountResult);
-
-const sd_bus_vtable bus_automount_vtable[] = {
-        SD_BUS_VTABLE_START(0),
-        SD_BUS_PROPERTY("Where", "s", NULL, offsetof(Automount, where), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Automount, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Automount, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
-        SD_BUS_VTABLE_END
-};
diff --git a/src/core/dbus-automount.h b/src/core/dbus-automount.h
deleted file mode 100644 (file)
index a2b124d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-extern const sd_bus_vtable bus_automount_vtable[];
diff --git a/src/core/dbus-busname.c b/src/core/dbus-busname.c
deleted file mode 100644 (file)
index b1ceb05..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "unit.h"
-#include "busname.h"
-#include "dbus-busname.h"
-#include "bus-util.h"
-
-static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, busname_result, BusNameResult);
-
-const sd_bus_vtable bus_busname_vtable[] = {
-        SD_BUS_VTABLE_START(0),
-        SD_BUS_PROPERTY("Name", "s", NULL, offsetof(BusName, name), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("TimeoutUSec", "t", bus_property_get_usec, offsetof(BusName, timeout_usec), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(BusName, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
-        SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(BusName, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
-        SD_BUS_PROPERTY("Activating", "b", bus_property_get_bool, offsetof(BusName, activating), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("AcceptFileDescriptors", "b", bus_property_get_bool, offsetof(BusName, accept_fd), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_VTABLE_END
-};
diff --git a/src/core/dbus-busname.h b/src/core/dbus-busname.h
deleted file mode 100644 (file)
index ea55b6c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-extern const sd_bus_vtable bus_busname_vtable[];
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
deleted file mode 100644 (file)
index 4a9df06..0000000
+++ /dev/null
@@ -1,680 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "bus-util.h"
-#include "path-util.h"
-#include "cgroup-util.h"
-#include "cgroup.h"
-#include "dbus-cgroup.h"
-
-static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_cgroup_device_policy, cgroup_device_policy, CGroupDevicePolicy);
-
-static int property_get_blockio_device_weight(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        CGroupContext *c = userdata;
-        CGroupBlockIODeviceWeight *w;
-        int r;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        r = sd_bus_message_open_container(reply, 'a', "(st)");
-        if (r < 0)
-                return r;
-
-        LIST_FOREACH(device_weights, w, c->blockio_device_weights) {
-                r = sd_bus_message_append(reply, "(st)", w->path, w->weight);
-                if (r < 0)
-                        return r;
-        }
-
-        return sd_bus_message_close_container(reply);
-}
-
-static int property_get_blockio_device_bandwidths(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        CGroupContext *c = userdata;
-        CGroupBlockIODeviceBandwidth *b;
-        int r;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        r = sd_bus_message_open_container(reply, 'a', "(st)");
-        if (r < 0)
-                return r;
-
-        LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths) {
-
-                if (streq(property, "BlockIOReadBandwidth") != b->read)
-                        continue;
-
-                r = sd_bus_message_append(reply, "(st)", b->path, b->bandwidth);
-                if (r < 0)
-                        return r;
-        }
-
-        return sd_bus_message_close_container(reply);
-}
-
-static int property_get_device_allow(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        CGroupContext *c = userdata;
-        CGroupDeviceAllow *a;
-        int r;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        r = sd_bus_message_open_container(reply, 'a', "(ss)");
-        if (r < 0)
-                return r;
-
-        LIST_FOREACH(device_allow, a, c->device_allow) {
-                unsigned k = 0;
-                char rwm[4];
-
-                if (a->r)
-                        rwm[k++] = 'r';
-                if (a->w)
-                        rwm[k++] = 'w';
-                if (a->m)
-                        rwm[k++] = 'm';
-
-                rwm[k] = 0;
-
-                r = sd_bus_message_append(reply, "(ss)", a->path, rwm);
-                if (r < 0)
-                        return r;
-        }
-
-        return sd_bus_message_close_container(reply);
-}
-
-static int property_get_ulong_as_u64(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        unsigned long *ul = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(ul);
-
-        return sd_bus_message_append(reply, "t", *ul == (unsigned long) -1 ? (uint64_t) -1 : (uint64_t) *ul);
-}
-
-const sd_bus_vtable bus_cgroup_vtable[] = {
-        SD_BUS_VTABLE_START(0),
-        SD_BUS_PROPERTY("Delegate", "b", bus_property_get_bool, offsetof(CGroupContext, delegate), 0),
-        SD_BUS_PROPERTY("CPUAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, cpu_accounting), 0),
-        SD_BUS_PROPERTY("CPUShares", "t", property_get_ulong_as_u64, offsetof(CGroupContext, cpu_shares), 0),
-        SD_BUS_PROPERTY("StartupCPUShares", "t", property_get_ulong_as_u64, offsetof(CGroupContext, startup_cpu_shares), 0),
-        SD_BUS_PROPERTY("CPUQuotaPerSecUSec", "t", bus_property_get_usec, offsetof(CGroupContext, cpu_quota_per_sec_usec), 0),
-        SD_BUS_PROPERTY("BlockIOAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, blockio_accounting), 0),
-        SD_BUS_PROPERTY("BlockIOWeight", "t", property_get_ulong_as_u64, offsetof(CGroupContext, blockio_weight), 0),
-        SD_BUS_PROPERTY("StartupBlockIOWeight", "t", property_get_ulong_as_u64, offsetof(CGroupContext, startup_blockio_weight), 0),
-        SD_BUS_PROPERTY("BlockIODeviceWeight", "a(st)", property_get_blockio_device_weight, 0, 0),
-        SD_BUS_PROPERTY("BlockIOReadBandwidth", "a(st)", property_get_blockio_device_bandwidths, 0, 0),
-        SD_BUS_PROPERTY("BlockIOWriteBandwidth", "a(st)", property_get_blockio_device_bandwidths, 0, 0),
-        SD_BUS_PROPERTY("MemoryAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, memory_accounting), 0),
-        SD_BUS_PROPERTY("MemoryLimit", "t", NULL, offsetof(CGroupContext, memory_limit), 0),
-        SD_BUS_PROPERTY("DevicePolicy", "s", property_get_cgroup_device_policy, offsetof(CGroupContext, device_policy), 0),
-        SD_BUS_PROPERTY("DeviceAllow", "a(ss)", property_get_device_allow, 0, 0),
-        SD_BUS_VTABLE_END
-};
-
-static int bus_cgroup_set_transient_property(
-                Unit *u,
-                CGroupContext *c,
-                const char *name,
-                sd_bus_message *message,
-                UnitSetPropertiesMode mode,
-                sd_bus_error *error) {
-
-        int r;
-
-        assert(u);
-        assert(c);
-        assert(name);
-        assert(message);
-
-        if (streq(name, "Delegate")) {
-                int b;
-
-                r = sd_bus_message_read(message, "b", &b);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        c->delegate = b;
-                        unit_write_drop_in_private(u, mode, name, b ? "Delegate=yes" : "Delegate=no");
-                }
-
-                return 1;
-        }
-
-        return 0;
-}
-
-int bus_cgroup_set_property(
-                Unit *u,
-                CGroupContext *c,
-                const char *name,
-                sd_bus_message *message,
-                UnitSetPropertiesMode mode,
-                sd_bus_error *error) {
-
-        int r;
-
-        assert(u);
-        assert(c);
-        assert(name);
-        assert(message);
-
-        if (streq(name, "CPUAccounting")) {
-                int b;
-
-                r = sd_bus_message_read(message, "b", &b);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        c->cpu_accounting = b;
-                        u->cgroup_realized_mask &= ~CGROUP_CPUACCT;
-                        unit_write_drop_in_private(u, mode, name, b ? "CPUAccounting=yes" : "CPUAccounting=no");
-                }
-
-                return 1;
-
-        } else if (streq(name, "CPUShares")) {
-                uint64_t u64;
-                unsigned long ul;
-
-                r = sd_bus_message_read(message, "t", &u64);
-                if (r < 0)
-                        return r;
-
-                if (u64 == (uint64_t) -1)
-                        ul = (unsigned long) -1;
-                else {
-                        ul = (unsigned long) u64;
-                        if (ul <= 0 || (uint64_t) ul != u64)
-                                return sd_bus_error_set_errnof(error, EINVAL, "CPUShares value out of range");
-                }
-
-                if (mode != UNIT_CHECK) {
-                        c->cpu_shares = ul;
-                        u->cgroup_realized_mask &= ~CGROUP_CPU;
-                        unit_write_drop_in_private_format(u, mode, name, "CPUShares=%lu", ul);
-                }
-
-                return 1;
-
-        } else if (streq(name, "StartupCPUShares")) {
-                uint64_t u64;
-                unsigned long ul;
-
-                r = sd_bus_message_read(message, "t", &u64);
-                if (r < 0)
-                        return r;
-
-                if (u64 == (uint64_t) -1)
-                        ul = (unsigned long) -1;
-                else {
-                        ul = (unsigned long) u64;
-                        if (ul <= 0 || (uint64_t) ul != u64)
-                                return sd_bus_error_set_errnof(error, EINVAL, "StartupCPUShares value out of range");
-                }
-
-                if (mode != UNIT_CHECK) {
-                        c->startup_cpu_shares = ul;
-                        u->cgroup_realized_mask &= ~CGROUP_CPU;
-                        unit_write_drop_in_private_format(u, mode, name, "StartupCPUShares=%lu", ul);
-                }
-
-                return 1;
-
-        } else if (streq(name, "CPUQuotaPerSecUSec")) {
-                uint64_t u64;
-
-                r = sd_bus_message_read(message, "t", &u64);
-                if (r < 0)
-                        return r;
-
-                if (u64 <= 0)
-                        return sd_bus_error_set_errnof(error, EINVAL, "CPUQuotaPerSecUSec value out of range");
-
-                if (mode != UNIT_CHECK) {
-                        c->cpu_quota_per_sec_usec = u64;
-                        u->cgroup_realized_mask &= ~CGROUP_CPU;
-                        unit_write_drop_in_private_format(u, mode, "CPUQuota", "CPUQuota=%0.f%%", (double) (c->cpu_quota_per_sec_usec / 10000));
-                }
-
-                return 1;
-
-        } else if (streq(name, "BlockIOAccounting")) {
-                int b;
-
-                r = sd_bus_message_read(message, "b", &b);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        c->blockio_accounting = b;
-                        u->cgroup_realized_mask &= ~CGROUP_BLKIO;
-                        unit_write_drop_in_private(u, mode, name, b ? "BlockIOAccounting=yes" : "BlockIOAccounting=no");
-                }
-
-                return 1;
-
-        } else if (streq(name, "BlockIOWeight")) {
-                uint64_t u64;
-                unsigned long ul;
-
-                r = sd_bus_message_read(message, "t", &u64);
-                if (r < 0)
-                        return r;
-
-                if (u64 == (uint64_t) -1)
-                        ul = (unsigned long) -1;
-                else  {
-                        ul = (unsigned long) u64;
-                        if (ul < 10 || ul > 1000)
-                                return sd_bus_error_set_errnof(error, EINVAL, "BlockIOWeight value out of range");
-                }
-
-                if (mode != UNIT_CHECK) {
-                        c->blockio_weight = ul;
-                        u->cgroup_realized_mask &= ~CGROUP_BLKIO;
-                        unit_write_drop_in_private_format(u, mode, name, "BlockIOWeight=%lu", ul);
-                }
-
-                return 1;
-
-        } else if (streq(name, "StartupBlockIOWeight")) {
-                uint64_t u64;
-                unsigned long ul;
-
-                r = sd_bus_message_read(message, "t", &u64);
-                if (r < 0)
-                        return r;
-
-                if (u64 == (uint64_t) -1)
-                        ul = (unsigned long) -1;
-                else  {
-                        ul = (unsigned long) u64;
-                        if (ul < 10 || ul > 1000)
-                                return sd_bus_error_set_errnof(error, EINVAL, "StartupBlockIOWeight value out of range");
-                }
-
-                if (mode != UNIT_CHECK) {
-                        c->startup_blockio_weight = ul;
-                        u->cgroup_realized_mask &= ~CGROUP_BLKIO;
-                        unit_write_drop_in_private_format(u, mode, name, "StartupBlockIOWeight=%lu", ul);
-                }
-
-                return 1;
-
-        } else if (streq(name, "BlockIOReadBandwidth") || streq(name, "BlockIOWriteBandwidth")) {
-                const char *path;
-                bool read = true;
-                unsigned n = 0;
-                uint64_t u64;
-
-                if (streq(name, "BlockIOWriteBandwidth"))
-                        read = false;
-
-                r = sd_bus_message_enter_container(message, 'a', "(st)");
-                if (r < 0)
-                        return r;
-
-                while ((r = sd_bus_message_read(message, "(st)", &path, &u64)) > 0) {
-
-                        if (mode != UNIT_CHECK) {
-                                CGroupBlockIODeviceBandwidth *a = NULL, *b;
-
-                                LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths) {
-                                        if (path_equal(path, b->path) && read == b->read) {
-                                                a = b;
-                                                break;
-                                        }
-                                }
-
-                                if (!a) {
-                                        a = new0(CGroupBlockIODeviceBandwidth, 1);
-                                        if (!a)
-                                                return -ENOMEM;
-
-                                        a->read = read;
-                                        a->path = strdup(path);
-                                        if (!a->path) {
-                                                free(a);
-                                                return -ENOMEM;
-                                        }
-
-                                        LIST_PREPEND(device_bandwidths, c->blockio_device_bandwidths, a);
-                                }
-
-                                a->bandwidth = u64;
-                        }
-
-                        n++;
-                }
-                if (r < 0)
-                        return r;
-
-                r = sd_bus_message_exit_container(message);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        CGroupBlockIODeviceBandwidth *a, *next;
-                        _cleanup_free_ char *buf = NULL;
-                        _cleanup_fclose_ FILE *f = NULL;
-                        size_t size = 0;
-
-                        if (n == 0) {
-                                LIST_FOREACH_SAFE(device_bandwidths, a, next, c->blockio_device_bandwidths)
-                                        if (a->read == read)
-                                                cgroup_context_free_blockio_device_bandwidth(c, a);
-                        }
-
-                        u->cgroup_realized_mask &= ~CGROUP_BLKIO;
-
-                        f = open_memstream(&buf, &size);
-                        if (!f)
-                                return -ENOMEM;
-
-                         if (read) {
-                                fputs("BlockIOReadBandwidth=\n", f);
-                                 LIST_FOREACH(device_bandwidths, a, c->blockio_device_bandwidths)
-                                        if (a->read)
-                                                fprintf(f, "BlockIOReadBandwidth=%s %" PRIu64 "\n", a->path, a->bandwidth);
-                        } else {
-                                fputs("BlockIOWriteBandwidth=\n", f);
-                                LIST_FOREACH(device_bandwidths, a, c->blockio_device_bandwidths)
-                                        if (!a->read)
-                                                fprintf(f, "BlockIOWriteBandwidth=%s %" PRIu64 "\n", a->path, a->bandwidth);
-                        }
-
-                        fflush(f);
-                        unit_write_drop_in_private(u, mode, name, buf);
-                }
-
-                return 1;
-
-        } else if (streq(name, "BlockIODeviceWeight")) {
-                const char *path;
-                uint64_t u64;
-                unsigned n = 0;
-
-                r = sd_bus_message_enter_container(message, 'a', "(st)");
-                if (r < 0)
-                        return r;
-
-                while ((r = sd_bus_message_read(message, "(st)", &path, &u64)) > 0) {
-                        unsigned long ul = u64;
-
-                        if (ul < 10 || ul > 1000)
-                                return sd_bus_error_set_errnof(error, EINVAL, "BlockIODeviceWeight out of range");
-
-                        if (mode != UNIT_CHECK) {
-                                CGroupBlockIODeviceWeight *a = NULL, *b;
-
-                                LIST_FOREACH(device_weights, b, c->blockio_device_weights) {
-                                        if (path_equal(b->path, path)) {
-                                                a = b;
-                                                break;
-                                        }
-                                }
-
-                                if (!a) {
-                                        a = new0(CGroupBlockIODeviceWeight, 1);
-                                        if (!a)
-                                                return -ENOMEM;
-
-                                        a->path = strdup(path);
-                                        if (!a->path) {
-                                                free(a);
-                                                return -ENOMEM;
-                                        }
-                                        LIST_PREPEND(device_weights,c->blockio_device_weights, a);
-                                }
-
-                                a->weight = ul;
-                        }
-
-                        n++;
-                }
-
-                r = sd_bus_message_exit_container(message);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        _cleanup_free_ char *buf = NULL;
-                        _cleanup_fclose_ FILE *f = NULL;
-                        CGroupBlockIODeviceWeight *a;
-                        size_t size = 0;
-
-                        if (n == 0) {
-                                while (c->blockio_device_weights)
-                                        cgroup_context_free_blockio_device_weight(c, c->blockio_device_weights);
-                        }
-
-                        u->cgroup_realized_mask &= ~CGROUP_BLKIO;
-
-                        f = open_memstream(&buf, &size);
-                        if (!f)
-                                return -ENOMEM;
-
-                        fputs("BlockIODeviceWeight=\n", f);
-                        LIST_FOREACH(device_weights, a, c->blockio_device_weights)
-                                fprintf(f, "BlockIODeviceWeight=%s %lu\n", a->path, a->weight);
-
-                        fflush(f);
-                        unit_write_drop_in_private(u, mode, name, buf);
-                }
-
-                return 1;
-
-        } else if (streq(name, "MemoryAccounting")) {
-                int b;
-
-                r = sd_bus_message_read(message, "b", &b);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        c->memory_accounting = b;
-                        u->cgroup_realized_mask &= ~CGROUP_MEMORY;
-                        unit_write_drop_in_private(u, mode, name, b ? "MemoryAccounting=yes" : "MemoryAccounting=no");
-                }
-
-                return 1;
-
-        } else if (streq(name, "MemoryLimit")) {
-                uint64_t limit;
-
-                r = sd_bus_message_read(message, "t", &limit);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        c->memory_limit = limit;
-                        u->cgroup_realized_mask &= ~CGROUP_MEMORY;
-                        unit_write_drop_in_private_format(u, mode, name, "%s=%" PRIu64, name, limit);
-                }
-
-                return 1;
-
-        } else if (streq(name, "DevicePolicy")) {
-                const char *policy;
-                CGroupDevicePolicy p;
-
-                r = sd_bus_message_read(message, "s", &policy);
-                if (r < 0)
-                        return r;
-
-                p = cgroup_device_policy_from_string(policy);
-                if (p < 0)
-                        return -EINVAL;
-
-                if (mode != UNIT_CHECK) {
-                        char *buf;
-
-                        c->device_policy = p;
-                        u->cgroup_realized_mask &= ~CGROUP_DEVICE;
-
-                        buf = strjoina("DevicePolicy=", policy);
-                        unit_write_drop_in_private(u, mode, name, buf);
-                }
-
-                return 1;
-
-        } else if (streq(name, "DeviceAllow")) {
-                const char *path, *rwm;
-                unsigned n = 0;
-
-                r = sd_bus_message_enter_container(message, 'a', "(ss)");
-                if (r < 0)
-                        return r;
-
-                while ((r = sd_bus_message_read(message, "(ss)", &path, &rwm)) > 0) {
-
-                        if ((!startswith(path, "/dev/") &&
-                             !startswith(path, "block-") &&
-                             !startswith(path, "char-")) ||
-                            strpbrk(path, WHITESPACE))
-                            return sd_bus_error_set_errnof(error, EINVAL, "DeviceAllow= requires device node");
-
-                        if (isempty(rwm))
-                                rwm = "rwm";
-
-                        if (!in_charset(rwm, "rwm"))
-                                return sd_bus_error_set_errnof(error, EINVAL, "DeviceAllow= requires combination of rwm flags");
-
-                        if (mode != UNIT_CHECK) {
-                                CGroupDeviceAllow *a = NULL, *b;
-
-                                LIST_FOREACH(device_allow, b, c->device_allow) {
-                                        if (path_equal(b->path, path)) {
-                                                a = b;
-                                                break;
-                                        }
-                                }
-
-                                if (!a) {
-                                        a = new0(CGroupDeviceAllow, 1);
-                                        if (!a)
-                                                return -ENOMEM;
-
-                                        a->path = strdup(path);
-                                        if (!a->path) {
-                                                free(a);
-                                                return -ENOMEM;
-                                        }
-
-                                        LIST_PREPEND(device_allow, c->device_allow, a);
-                                }
-
-                                a->r = !!strchr(rwm, 'r');
-                                a->w = !!strchr(rwm, 'w');
-                                a->m = !!strchr(rwm, 'm');
-                        }
-
-                        n++;
-                }
-                if (r < 0)
-                        return r;
-
-                r = sd_bus_message_exit_container(message);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        _cleanup_free_ char *buf = NULL;
-                        _cleanup_fclose_ FILE *f = NULL;
-                        CGroupDeviceAllow *a;
-                        size_t size = 0;
-
-                        if (n == 0) {
-                                while (c->device_allow)
-                                        cgroup_context_free_device_allow(c, c->device_allow);
-                        }
-
-                        u->cgroup_realized_mask &= ~CGROUP_DEVICE;
-
-                        f = open_memstream(&buf, &size);
-                        if (!f)
-                                return -ENOMEM;
-
-                        fputs("DeviceAllow=\n", f);
-                        LIST_FOREACH(device_allow, a, c->device_allow)
-                                fprintf(f, "DeviceAllow=%s %s%s%s\n", a->path, a->r ? "r" : "", a->w ? "w" : "", a->m ? "m" : "");
-
-                        fflush(f);
-                        unit_write_drop_in_private(u, mode, name, buf);
-                }
-
-                return 1;
-
-        }
-
-        if (u->transient && u->load_state == UNIT_STUB) {
-                r = bus_cgroup_set_transient_property(u, c, name, message, mode, error);
-                if (r != 0)
-                        return r;
-
-        }
-
-        return 0;
-}
diff --git a/src/core/dbus-cgroup.h b/src/core/dbus-cgroup.h
deleted file mode 100644 (file)
index c2a3910..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "sd-bus.h"
-#include "cgroup.h"
-
-extern const sd_bus_vtable bus_cgroup_vtable[];
-
-int bus_cgroup_set_property(Unit *u, CGroupContext *c, const char *name, sd_bus_message *message, UnitSetPropertiesMode mode, sd_bus_error *error);
diff --git a/src/core/dbus-device.c b/src/core/dbus-device.c
deleted file mode 100644 (file)
index cb156fd..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "unit.h"
-#include "device.h"
-#include "dbus-device.h"
-
-const sd_bus_vtable bus_device_vtable[] = {
-        SD_BUS_VTABLE_START(0),
-        SD_BUS_PROPERTY("SysFSPath", "s", NULL, offsetof(Device, sysfs), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
-        SD_BUS_VTABLE_END
-};
diff --git a/src/core/dbus-device.h b/src/core/dbus-device.h
deleted file mode 100644 (file)
index 10e945e..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "unit.h"
-
-extern const sd_bus_vtable bus_device_vtable[];
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
deleted file mode 100644 (file)
index a9f7971..0000000
+++ /dev/null
@@ -1,1006 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/prctl.h>
-
-#ifdef HAVE_SECCOMP
-#include <seccomp.h>
-#endif
-
-#include "bus-util.h"
-#include "missing.h"
-#include "ioprio.h"
-#include "strv.h"
-#include "fileio.h"
-#include "execute.h"
-#include "capability.h"
-#include "env-util.h"
-#include "af-list.h"
-#include "namespace.h"
-#include "path-util.h"
-#include "dbus-execute.h"
-
-#ifdef HAVE_SECCOMP
-#include "seccomp-util.h"
-#endif
-
-BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_exec_output, exec_output, ExecOutput);
-
-static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_input, exec_input, ExecInput);
-
-static BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_protect_home, protect_home, ProtectHome);
-static BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_protect_system, protect_system, ProtectSystem);
-
-static int property_get_environment_files(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-        char **j;
-        int r;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        r = sd_bus_message_open_container(reply, 'a', "(sb)");
-        if (r < 0)
-                return r;
-
-        STRV_FOREACH(j, c->environment_files) {
-                const char *fn = *j;
-
-                r = sd_bus_message_append(reply, "(sb)", fn[0] == '-' ? fn + 1 : fn, fn[0] == '-');
-                if (r < 0)
-                        return r;
-        }
-
-        return sd_bus_message_close_container(reply);
-}
-
-static int property_get_rlimit(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        struct rlimit *rl;
-        uint64_t u;
-        rlim_t x;
-
-        assert(bus);
-        assert(reply);
-        assert(userdata);
-
-        rl = *(struct rlimit**) userdata;
-        if (rl)
-                x = rl->rlim_max;
-        else {
-                struct rlimit buf = {};
-                int z;
-
-                z = rlimit_from_string(property);
-                assert(z >= 0);
-
-                getrlimit(z, &buf);
-                x = buf.rlim_max;
-        }
-
-        /* rlim_t might have different sizes, let's map
-         * RLIMIT_INFINITY to (uint64_t) -1, so that it is the same on
-         * all archs */
-        u = x == RLIM_INFINITY ? (uint64_t) -1 : (uint64_t) x;
-
-        return sd_bus_message_append(reply, "t", u);
-}
-
-static int property_get_oom_score_adjust(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-
-        ExecContext *c = userdata;
-        int32_t n;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        if (c->oom_score_adjust_set)
-                n = c->oom_score_adjust;
-        else {
-                _cleanup_free_ char *t = NULL;
-
-                n = 0;
-                if (read_one_line_file("/proc/self/oom_score_adj", &t) >= 0)
-                        safe_atoi(t, &n);
-        }
-
-        return sd_bus_message_append(reply, "i", n);
-}
-
-static int property_get_nice(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-
-        ExecContext *c = userdata;
-        int32_t n;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        if (c->nice_set)
-                n = c->nice;
-        else {
-                errno = 0;
-                n = getpriority(PRIO_PROCESS, 0);
-                if (errno != 0)
-                        n = 0;
-        }
-
-        return sd_bus_message_append(reply, "i", n);
-}
-
-static int property_get_ioprio(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-
-        ExecContext *c = userdata;
-        int32_t n;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        if (c->ioprio_set)
-                n = c->ioprio;
-        else {
-                n = ioprio_get(IOPRIO_WHO_PROCESS, 0);
-                if (n < 0)
-                        n = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 4);
-        }
-
-        return sd_bus_message_append(reply, "i", n);
-}
-
-static int property_get_cpu_sched_policy(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-        int32_t n;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        if (c->cpu_sched_set)
-                n = c->cpu_sched_policy;
-        else {
-                n = sched_getscheduler(0);
-                if (n < 0)
-                        n = SCHED_OTHER;
-        }
-
-        return sd_bus_message_append(reply, "i", n);
-}
-
-static int property_get_cpu_sched_priority(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-        int32_t n;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        if (c->cpu_sched_set)
-                n = c->cpu_sched_priority;
-        else {
-                struct sched_param p = {};
-
-                if (sched_getparam(0, &p) >= 0)
-                        n = p.sched_priority;
-                else
-                        n = 0;
-        }
-
-        return sd_bus_message_append(reply, "i", n);
-}
-
-static int property_get_cpu_affinity(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        if (c->cpuset)
-                return sd_bus_message_append_array(reply, 'y', c->cpuset, CPU_ALLOC_SIZE(c->cpuset_ncpus));
-        else
-                return sd_bus_message_append_array(reply, 'y', NULL, 0);
-}
-
-static int property_get_timer_slack_nsec(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-        uint64_t u;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        if (c->timer_slack_nsec != NSEC_INFINITY)
-                u = (uint64_t) c->timer_slack_nsec;
-        else
-                u = (uint64_t) prctl(PR_GET_TIMERSLACK);
-
-        return sd_bus_message_append(reply, "t", u);
-}
-
-static int property_get_capability_bounding_set(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        /* We store this negated internally, to match the kernel, but
-         * we expose it normalized. */
-        return sd_bus_message_append(reply, "t", ~c->capability_bounding_set_drop);
-}
-
-static int property_get_capabilities(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-        _cleanup_cap_free_charp_ char *t = NULL;
-        const char *s;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        if (c->capabilities)
-                s = t = cap_to_text(c->capabilities, NULL);
-        else
-                s = "";
-
-        if (!s)
-                return -ENOMEM;
-
-        return sd_bus_message_append(reply, "s", s);
-}
-
-static int property_get_syscall_filter(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-        _cleanup_strv_free_ char **l = NULL;
-        int r;
-
-#ifdef HAVE_SECCOMP
-        Iterator i;
-        void *id;
-#endif
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        r = sd_bus_message_open_container(reply, 'r', "bas");
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_append(reply, "b", c->syscall_whitelist);
-        if (r < 0)
-                return r;
-
-#ifdef HAVE_SECCOMP
-        SET_FOREACH(id, c->syscall_filter, i) {
-                char *name;
-
-                name = seccomp_syscall_resolve_num_arch(SCMP_ARCH_NATIVE, PTR_TO_INT(id) - 1);
-                if (!name)
-                        continue;
-
-                r = strv_consume(&l, name);
-                if (r < 0)
-                        return r;
-        }
-#endif
-
-        strv_sort(l);
-
-        r = sd_bus_message_append_strv(reply, l);
-        if (r < 0)
-                return r;
-
-        return sd_bus_message_close_container(reply);
-}
-
-static int property_get_syscall_archs(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-        _cleanup_strv_free_ char **l = NULL;
-        int r;
-
-#ifdef HAVE_SECCOMP
-        Iterator i;
-        void *id;
-#endif
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-#ifdef HAVE_SECCOMP
-        SET_FOREACH(id, c->syscall_archs, i) {
-                const char *name;
-
-                name = seccomp_arch_to_string(PTR_TO_UINT32(id) - 1);
-                if (!name)
-                        continue;
-
-                r = strv_extend(&l, name);
-                if (r < 0)
-                        return -ENOMEM;
-        }
-#endif
-
-        strv_sort(l);
-
-        r = sd_bus_message_append_strv(reply, l);
-        if (r < 0)
-                return r;
-
-        return 0;
-}
-
-static int property_get_syscall_errno(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        return sd_bus_message_append(reply, "i", (int32_t) c->syscall_errno);
-}
-
-static int property_get_selinux_context(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        return sd_bus_message_append(reply, "(bs)", c->selinux_context_ignore, c->selinux_context);
-}
-
-static int property_get_apparmor_profile(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        return sd_bus_message_append(reply, "(bs)", c->apparmor_profile_ignore, c->apparmor_profile);
-}
-
-static int property_get_smack_process_label(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        return sd_bus_message_append(reply, "(bs)", c->smack_process_label_ignore, c->smack_process_label);
-}
-
-static int property_get_personality(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        return sd_bus_message_append(reply, "s", personality_to_string(c->personality));
-}
-
-static int property_get_address_families(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        ExecContext *c = userdata;
-        _cleanup_strv_free_ char **l = NULL;
-        Iterator i;
-        void *af;
-        int r;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        r = sd_bus_message_open_container(reply, 'r', "bas");
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_append(reply, "b", c->address_families_whitelist);
-        if (r < 0)
-                return r;
-
-        SET_FOREACH(af, c->address_families, i) {
-                const char *name;
-
-                name = af_to_name(PTR_TO_INT(af));
-                if (!name)
-                        continue;
-
-                r = strv_extend(&l, name);
-                if (r < 0)
-                        return -ENOMEM;
-        }
-
-        strv_sort(l);
-
-        r = sd_bus_message_append_strv(reply, l);
-        if (r < 0)
-                return r;
-
-        return sd_bus_message_close_container(reply);
-}
-
-const sd_bus_vtable bus_exec_vtable[] = {
-        SD_BUS_VTABLE_START(0),
-        SD_BUS_PROPERTY("Environment", "as", NULL, offsetof(ExecContext, environment), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("EnvironmentFiles", "a(sb)", property_get_environment_files, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("UMask", "u", bus_property_get_mode, offsetof(ExecContext, umask), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitCPU", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_CPU]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitFSIZE", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_FSIZE]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitDATA", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_DATA]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitSTACK", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_STACK]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitCORE", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_CORE]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitRSS", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_RSS]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitNOFILE", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_NOFILE]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitAS", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_AS]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitNPROC", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_NPROC]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitMEMLOCK", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_MEMLOCK]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitLOCKS", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_LOCKS]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitSIGPENDING", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_SIGPENDING]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitMSGQUEUE", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_MSGQUEUE]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitNICE", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_NICE]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitRTPRIO", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_RTPRIO]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("LimitRTTIME", "t", property_get_rlimit, offsetof(ExecContext, rlimit[RLIMIT_RTTIME]), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("WorkingDirectory", "s", NULL, offsetof(ExecContext, working_directory), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("RootDirectory", "s", NULL, offsetof(ExecContext, root_directory), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("OOMScoreAdjust", "i", property_get_oom_score_adjust, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("Nice", "i", property_get_nice, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("IOScheduling", "i", property_get_ioprio, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("CPUSchedulingPolicy", "i", property_get_cpu_sched_policy, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("CPUSchedulingPriority", "i", property_get_cpu_sched_priority, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("CPUAffinity", "ay", property_get_cpu_affinity, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("TimerSlackNSec", "t", property_get_timer_slack_nsec, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("CPUSchedulingResetOnFork", "b", bus_property_get_bool, offsetof(ExecContext, cpu_sched_reset_on_fork), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("NonBlocking", "b", bus_property_get_bool, offsetof(ExecContext, non_blocking), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("StandardInput", "s", property_get_exec_input, offsetof(ExecContext, std_input), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("StandardOutput", "s", bus_property_get_exec_output, offsetof(ExecContext, std_output), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("StandardError", "s", bus_property_get_exec_output, offsetof(ExecContext, std_error), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("TTYPath", "s", NULL, offsetof(ExecContext, tty_path), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("TTYReset", "b", bus_property_get_bool, offsetof(ExecContext, tty_reset), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("TTYVHangup", "b", bus_property_get_bool, offsetof(ExecContext, tty_vhangup), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("TTYVTDisallocate", "b", bus_property_get_bool, offsetof(ExecContext, tty_vt_disallocate), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SyslogPriority", "i", bus_property_get_int, offsetof(ExecContext, syslog_priority), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SyslogIdentifier", "s", NULL, offsetof(ExecContext, syslog_identifier), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SyslogLevelPrefix", "b", bus_property_get_bool, offsetof(ExecContext, syslog_level_prefix), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("Capabilities", "s", property_get_capabilities, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SecureBits", "i", bus_property_get_int, offsetof(ExecContext, secure_bits), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("CapabilityBoundingSet", "t", property_get_capability_bounding_set, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("User", "s", NULL, offsetof(ExecContext, user), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("Group", "s", NULL, offsetof(ExecContext, group), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SupplementaryGroups", "as", NULL, offsetof(ExecContext, supplementary_groups), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("PAMName", "s", NULL, offsetof(ExecContext, pam_name), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("ReadWriteDirectories", "as", NULL, offsetof(ExecContext, read_write_dirs), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("ReadOnlyDirectories", "as", NULL, offsetof(ExecContext, read_only_dirs), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("InaccessibleDirectories", "as", NULL, offsetof(ExecContext, inaccessible_dirs), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("MountFlags", "t", bus_property_get_ulong, offsetof(ExecContext, mount_flags), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("PrivateTmp", "b", bus_property_get_bool, offsetof(ExecContext, private_tmp), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("PrivateNetwork", "b", bus_property_get_bool, offsetof(ExecContext, private_network), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("PrivateDevices", "b", bus_property_get_bool, offsetof(ExecContext, private_devices), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("ProtectHome", "s", bus_property_get_protect_home, offsetof(ExecContext, protect_home), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("ProtectSystem", "s", bus_property_get_protect_system, offsetof(ExecContext, protect_system), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SameProcessGroup", "b", bus_property_get_bool, offsetof(ExecContext, same_pgrp), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("UtmpIdentifier", "s", NULL, offsetof(ExecContext, utmp_id), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SELinuxContext", "(bs)", property_get_selinux_context, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("AppArmorProfile", "(bs)", property_get_apparmor_profile, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SmackProcessLabel", "(bs)", property_get_smack_process_label, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("IgnoreSIGPIPE", "b", bus_property_get_bool, offsetof(ExecContext, ignore_sigpipe), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("NoNewPrivileges", "b", bus_property_get_bool, offsetof(ExecContext, no_new_privileges), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SystemCallFilter", "(bas)", property_get_syscall_filter, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SystemCallArchitectures", "as", property_get_syscall_archs, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SystemCallErrorNumber", "i", property_get_syscall_errno, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("Personality", "s", property_get_personality, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("RestrictAddressFamilies", "(bas)", property_get_address_families, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("RuntimeDirectoryMode", "u", bus_property_get_mode, offsetof(ExecContext, runtime_directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("RuntimeDirectory", "as", NULL, offsetof(ExecContext, runtime_directory), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_VTABLE_END
-};
-
-static int append_exec_command(sd_bus_message *reply, ExecCommand *c) {
-        int r;
-
-        assert(reply);
-        assert(c);
-
-        if (!c->path)
-                return 0;
-
-        r = sd_bus_message_open_container(reply, 'r', "sasbttttuii");
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_append(reply, "s", c->path);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_append_strv(reply, c->argv);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_append(reply, "bttttuii",
-                                  c->ignore,
-                                  c->exec_status.start_timestamp.realtime,
-                                  c->exec_status.start_timestamp.monotonic,
-                                  c->exec_status.exit_timestamp.realtime,
-                                  c->exec_status.exit_timestamp.monotonic,
-                                  (uint32_t) c->exec_status.pid,
-                                  (int32_t) c->exec_status.code,
-                                  (int32_t) c->exec_status.status);
-        if (r < 0)
-                return r;
-
-        return sd_bus_message_close_container(reply);
-}
-
-int bus_property_get_exec_command(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *ret_error) {
-
-        ExecCommand *c = (ExecCommand*) userdata;
-        int r;
-
-        assert(bus);
-        assert(reply);
-
-        r = sd_bus_message_open_container(reply, 'a', "(sasbttttuii)");
-        if (r < 0)
-                return r;
-
-        r = append_exec_command(reply, c);
-        if (r < 0)
-                return r;
-
-        return sd_bus_message_close_container(reply);
-}
-
-int bus_property_get_exec_command_list(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *ret_error) {
-
-        ExecCommand *c = *(ExecCommand**) userdata;
-        int r;
-
-        assert(bus);
-        assert(reply);
-
-        r = sd_bus_message_open_container(reply, 'a', "(sasbttttuii)");
-        if (r < 0)
-                return r;
-
-        LIST_FOREACH(command, c, c) {
-                r = append_exec_command(reply, c);
-                if (r < 0)
-                        return r;
-        }
-
-        return sd_bus_message_close_container(reply);
-}
-
-int bus_exec_context_set_transient_property(
-                Unit *u,
-                ExecContext *c,
-                const char *name,
-                sd_bus_message *message,
-                UnitSetPropertiesMode mode,
-                sd_bus_error *error) {
-
-        int r;
-
-        assert(u);
-        assert(c);
-        assert(name);
-        assert(message);
-
-        if (streq(name, "User")) {
-                const char *uu;
-
-                r = sd_bus_message_read(message, "s", &uu);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-
-                        if (isempty(uu)) {
-                                free(c->user);
-                                c->user = NULL;
-                        } else {
-                                char *t;
-
-                                t = strdup(uu);
-                                if (!t)
-                                        return -ENOMEM;
-
-                                free(c->user);
-                                c->user = t;
-                        }
-
-                        unit_write_drop_in_private_format(u, mode, name, "User=%s\n", uu);
-                }
-
-                return 1;
-
-        } else if (streq(name, "Group")) {
-                const char *gg;
-
-                r = sd_bus_message_read(message, "s", &gg);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-
-                        if (isempty(gg)) {
-                                free(c->group);
-                                c->group = NULL;
-                        } else {
-                                char *t;
-
-                                t = strdup(gg);
-                                if (!t)
-                                        return -ENOMEM;
-
-                                free(c->group);
-                                c->group = t;
-                        }
-
-                        unit_write_drop_in_private_format(u, mode, name, "Group=%s\n", gg);
-                }
-
-                return 1;
-
-        } else if (streq(name, "Nice")) {
-                int n;
-
-                r = sd_bus_message_read(message, "i", &n);
-                if (r < 0)
-                        return r;
-
-                if (n < PRIO_MIN || n >= PRIO_MAX)
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Nice value out of range");
-
-                if (mode != UNIT_CHECK) {
-                        c->nice = n;
-                        unit_write_drop_in_private_format(u, mode, name, "Nice=%i\n", n);
-                }
-
-                return 1;
-
-        } else if (streq(name, "TTYPath")) {
-                const char *tty;
-
-                r = sd_bus_message_read(message, "s", &tty);
-                if (r < 0)
-                        return r;
-
-                if (!path_is_absolute(tty))
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "TTY device not absolute path");
-
-                if (mode != UNIT_CHECK) {
-                        char *t;
-
-                        t = strdup(tty);
-                        if (!t)
-                                return -ENOMEM;
-
-                        free(c->tty_path);
-                        c->tty_path = t;
-
-                        unit_write_drop_in_private_format(u, mode, name, "TTYPath=%s\n", tty);
-                }
-
-                return 1;
-
-        } else if (streq(name, "StandardInput")) {
-                const char *s;
-                ExecInput p;
-
-                r = sd_bus_message_read(message, "s", &s);
-                if (r < 0)
-                        return r;
-
-                p = exec_input_from_string(s);
-                if (p < 0)
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid standard input name");
-
-                if (mode != UNIT_CHECK) {
-                        c->std_input = p;
-
-                        unit_write_drop_in_private_format(u, mode, name, "StandardInput=%s\n", exec_input_to_string(p));
-                }
-
-                return 1;
-
-
-        } else if (streq(name, "StandardOutput")) {
-                const char *s;
-                ExecOutput p;
-
-                r = sd_bus_message_read(message, "s", &s);
-                if (r < 0)
-                        return r;
-
-                p = exec_output_from_string(s);
-                if (p < 0)
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid standard output name");
-
-                if (mode != UNIT_CHECK) {
-                        c->std_output = p;
-
-                        unit_write_drop_in_private_format(u, mode, name, "StandardOutput=%s\n", exec_output_to_string(p));
-                }
-
-                return 1;
-
-        } else if (streq(name, "StandardError")) {
-                const char *s;
-                ExecOutput p;
-
-                r = sd_bus_message_read(message, "s", &s);
-                if (r < 0)
-                        return r;
-
-                p = exec_output_from_string(s);
-                if (p < 0)
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid standard error name");
-
-                if (mode != UNIT_CHECK) {
-                        c->std_error = p;
-
-                        unit_write_drop_in_private_format(u, mode, name, "StandardError=%s\n", exec_output_to_string(p));
-                }
-
-                return 1;
-
-        } else if (streq(name, "Environment")) {
-
-                _cleanup_strv_free_ char **l = NULL;
-
-                r = sd_bus_message_read_strv(message, &l);
-                if (r < 0)
-                        return r;
-
-                if (!strv_env_is_valid(l))
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment block.");
-
-                if (mode != UNIT_CHECK) {
-                        _cleanup_free_ char *joined = NULL;
-                        char **e;
-
-                        e = strv_env_merge(2, c->environment, l);
-                        if (!e)
-                                return -ENOMEM;
-
-                        strv_free(c->environment);
-                        c->environment = e;
-
-                        joined = strv_join_quoted(c->environment);
-                        if (!joined)
-                                return -ENOMEM;
-
-                        unit_write_drop_in_private_format(u, mode, name, "Environment=%s\n", joined);
-                }
-
-                return 1;
-
-        } else if (rlimit_from_string(name) >= 0) {
-                uint64_t rl;
-                rlim_t x;
-
-                r = sd_bus_message_read(message, "t", &rl);
-                if (r < 0)
-                        return r;
-
-                if (rl == (uint64_t) -1)
-                        x = RLIM_INFINITY;
-                else {
-                        x = (rlim_t) rl;
-
-                        if ((uint64_t) x != rl)
-                                return -ERANGE;
-                }
-
-                if (mode != UNIT_CHECK) {
-                        int z;
-
-                        z = rlimit_from_string(name);
-
-                        if (!c->rlimit[z]) {
-                                c->rlimit[z] = new(struct rlimit, 1);
-                                if (!c->rlimit[z])
-                                        return -ENOMEM;
-                        }
-
-                        c->rlimit[z]->rlim_cur = c->rlimit[z]->rlim_max = x;
-
-                        if (x == RLIM_INFINITY)
-                                unit_write_drop_in_private_format(u, mode, name, "%s=infinity\n", name);
-                        else
-                                unit_write_drop_in_private_format(u, mode, name, "%s=%" PRIu64 "\n", name, rl);
-                }
-
-                return 1;
-        }
-
-        return 0;
-}
diff --git a/src/core/dbus-execute.h b/src/core/dbus-execute.h
deleted file mode 100644 (file)
index e4c2d5d..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "sd-bus.h"
-#include "execute.h"
-
-#define BUS_EXEC_STATUS_VTABLE(prefix, offset, flags)                   \
-        BUS_PROPERTY_DUAL_TIMESTAMP(prefix "StartTimestamp", (offset) + offsetof(ExecStatus, start_timestamp), flags), \
-        BUS_PROPERTY_DUAL_TIMESTAMP(prefix "ExitTimestamp", (offset) + offsetof(ExecStatus, exit_timestamp), flags), \
-        SD_BUS_PROPERTY(prefix "PID", "u", bus_property_get_pid, (offset) + offsetof(ExecStatus, pid), flags), \
-        SD_BUS_PROPERTY(prefix "Code", "i", bus_property_get_int, (offset) + offsetof(ExecStatus, code), flags), \
-        SD_BUS_PROPERTY(prefix "Status", "i", bus_property_get_int, (offset) + offsetof(ExecStatus, status), flags)
-
-#define BUS_EXEC_COMMAND_VTABLE(name, offset, flags)                    \
-        SD_BUS_PROPERTY(name, "a(sasbttttuii)", bus_property_get_exec_command, offset, flags)
-
-#define BUS_EXEC_COMMAND_LIST_VTABLE(name, offset, flags)                    \
-        SD_BUS_PROPERTY(name, "a(sasbttttuii)", bus_property_get_exec_command_list, offset, flags)
-
-extern const sd_bus_vtable bus_exec_vtable[];
-
-int bus_property_get_exec_output(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *ret_error);
-int bus_property_get_exec_command(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *ret_error);
-int bus_property_get_exec_command_list(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *ret_error);
-
-int bus_exec_context_set_transient_property(Unit *u, ExecContext *c, const char *name, sd_bus_message *message, UnitSetPropertiesMode mode, sd_bus_error *error);
diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c
deleted file mode 100644 (file)
index fa1d1f3..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "log.h"
-#include "sd-bus.h"
-#include "selinux-access.h"
-#include "job.h"
-#include "dbus-job.h"
-#include "dbus.h"
-
-static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, job_type, JobType);
-static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_state, job_state, JobState);
-
-static int property_get_unit(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        _cleanup_free_ char *p = NULL;
-        Job *j = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(j);
-
-        p = unit_dbus_path(j->unit);
-        if (!p)
-                return -ENOMEM;
-
-        return sd_bus_message_append(reply, "(so)", j->unit->id, p);
-}
-
-int bus_job_method_cancel(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Job *j = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(j);
-
-        r = mac_selinux_unit_access_check(j->unit, message, "stop", error);
-        if (r < 0)
-                return r;
-
-        /* Access is granted to the job owner */
-        if (!sd_bus_track_contains(j->clients, sd_bus_message_get_sender(message))) {
-
-                /* And for everybody else consult PolicyKit */
-                r = bus_verify_manage_units_async(j->unit->manager, message, error);
-                if (r < 0)
-                        return r;
-                if (r == 0)
-                        return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
-        }
-
-        job_finish_and_invalidate(j, JOB_CANCELED, true);
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-const sd_bus_vtable bus_job_vtable[] = {
-        SD_BUS_VTABLE_START(0),
-        SD_BUS_METHOD("Cancel", NULL, NULL, bus_job_method_cancel, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_PROPERTY("Id", "u", NULL, offsetof(Job, id), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("Unit", "(so)", property_get_unit, 0, SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("JobType", "s", property_get_type, offsetof(Job, type), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("State", "s", property_get_state, offsetof(Job, state), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
-        SD_BUS_VTABLE_END
-};
-
-static int send_new_signal(sd_bus *bus, void *userdata) {
-        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
-        _cleanup_free_ char *p = NULL;
-        Job *j = userdata;
-        int r;
-
-        assert(bus);
-        assert(j);
-
-        p = job_dbus_path(j);
-        if (!p)
-                return -ENOMEM;
-
-        r = sd_bus_message_new_signal(
-                        bus,
-                        &m,
-                        "/org/freedesktop/systemd1",
-                        "org.freedesktop.systemd1.Manager",
-                        "JobNew");
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_append(m, "uos", j->id, p, j->unit->id);
-        if (r < 0)
-                return r;
-
-        return sd_bus_send(bus, m, NULL);
-}
-
-static int send_changed_signal(sd_bus *bus, void *userdata) {
-        _cleanup_free_ char *p = NULL;
-        Job *j = userdata;
-
-        assert(bus);
-        assert(j);
-
-        p = job_dbus_path(j);
-        if (!p)
-                return -ENOMEM;
-
-        return sd_bus_emit_properties_changed(bus, p, "org.freedesktop.systemd1.Job", "State", NULL);
-}
-
-void bus_job_send_change_signal(Job *j) {
-        int r;
-
-        assert(j);
-
-        if (j->in_dbus_queue) {
-                LIST_REMOVE(dbus_queue, j->manager->dbus_job_queue, j);
-                j->in_dbus_queue = false;
-        }
-
-        r = bus_foreach_bus(j->manager, j->clients, j->sent_dbus_new_signal ? send_changed_signal : send_new_signal, j);
-        if (r < 0)
-                log_debug_errno(r, "Failed to send job change signal for %u: %m", j->id);
-
-        j->sent_dbus_new_signal = true;
-}
-
-static int send_removed_signal(sd_bus *bus, void *userdata) {
-        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
-        _cleanup_free_ char *p = NULL;
-        Job *j = userdata;
-        int r;
-
-        assert(bus);
-        assert(j);
-
-        p = job_dbus_path(j);
-        if (!p)
-                return -ENOMEM;
-
-        r = sd_bus_message_new_signal(
-                        bus,
-                        &m,
-                        "/org/freedesktop/systemd1",
-                        "org.freedesktop.systemd1.Manager",
-                        "JobRemoved");
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_append(m, "uoss", j->id, p, j->unit->id, job_result_to_string(j->result));
-        if (r < 0)
-                return r;
-
-        return sd_bus_send(bus, m, NULL);
-}
-
-void bus_job_send_removed_signal(Job *j) {
-        int r;
-
-        assert(j);
-
-        if (!j->sent_dbus_new_signal)
-                bus_job_send_change_signal(j);
-
-        r = bus_foreach_bus(j->manager, j->clients, send_removed_signal, j);
-        if (r < 0)
-                log_debug_errno(r, "Failed to send job remove signal for %u: %m", j->id);
-}
diff --git a/src/core/dbus-job.h b/src/core/dbus-job.h
deleted file mode 100644 (file)
index 6c2fc07..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "sd-bus.h"
-#include "job.h"
-
-extern const sd_bus_vtable bus_job_vtable[];
-
-int bus_job_method_cancel(sd_bus *bus, sd_bus_message *message, void *job, sd_bus_error *error);
-
-void bus_job_send_change_signal(Job *j);
-void bus_job_send_removed_signal(Job *j);
diff --git a/src/core/dbus-kill.c b/src/core/dbus-kill.c
deleted file mode 100644 (file)
index fb29e14..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2012 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "kill.h"
-#include "dbus-kill.h"
-#include "bus-util.h"
-
-static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_kill_mode, kill_mode, KillMode);
-
-const sd_bus_vtable bus_kill_vtable[] = {
-        SD_BUS_VTABLE_START(0),
-        SD_BUS_PROPERTY("KillMode", "s", property_get_kill_mode, offsetof(KillContext, kill_mode), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("KillSignal", "i", bus_property_get_int, offsetof(KillContext, kill_signal), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SendSIGKILL", "b", bus_property_get_bool, offsetof(KillContext, send_sigkill), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("SendSIGHUP", "b", bus_property_get_bool,  offsetof(KillContext, send_sighup), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_VTABLE_END
-};
-
-int bus_kill_context_set_transient_property(
-                Unit *u,
-                KillContext *c,
-                const char *name,
-                sd_bus_message *message,
-                UnitSetPropertiesMode mode,
-                sd_bus_error *error) {
-
-        int r;
-
-        assert(u);
-        assert(c);
-        assert(name);
-        assert(message);
-
-        if (streq(name, "KillMode")) {
-                const char *m;
-                KillMode k;
-
-                r = sd_bus_message_read(message, "s", &m);
-                if (r < 0)
-                        return r;
-
-                k = kill_mode_from_string(m);
-                if (k < 0)
-                        return -EINVAL;
-
-                if (mode != UNIT_CHECK) {
-                        c->kill_mode = k;
-
-                        unit_write_drop_in_private_format(u, mode, name, "KillMode=%s\n", kill_mode_to_string(k));
-                }
-
-                return 1;
-
-        } else if (streq(name, "KillSignal")) {
-                int sig;
-
-                r = sd_bus_message_read(message, "i", &sig);
-                if (r < 0)
-                        return r;
-
-                if (sig <= 0 || sig >= _NSIG)
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Signal %i out of range", sig);
-
-                if (mode != UNIT_CHECK) {
-                        c->kill_signal = sig;
-
-                        unit_write_drop_in_private_format(u, mode, name, "KillSignal=%s\n", signal_to_string(sig));
-                }
-
-                return 1;
-
-        } else if (streq(name, "SendSIGHUP")) {
-                int b;
-
-                r = sd_bus_message_read(message, "b", &b);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        c->send_sighup = b;
-
-                        unit_write_drop_in_private_format(u, mode, name, "SendSIGHUP=%s\n", yes_no(b));
-                }
-
-                return 1;
-
-        } else if (streq(name, "SendSIGKILL")) {
-                int b;
-
-                r = sd_bus_message_read(message, "b", &b);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        c->send_sigkill = b;
-
-                        unit_write_drop_in_private_format(u, mode, name, "SendSIGKILL=%s\n", yes_no(b));
-                }
-
-                return 1;
-
-        }
-
-        return 0;
-}
diff --git a/src/core/dbus-kill.h b/src/core/dbus-kill.h
deleted file mode 100644 (file)
index 7c15f3a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2012 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "sd-bus.h"
-#include "unit.h"
-#include "kill.h"
-
-extern const sd_bus_vtable bus_kill_vtable[];
-
-int bus_kill_context_set_transient_property(Unit *u, KillContext *c, const char *name, sd_bus_message *message, UnitSetPropertiesMode mode, sd_bus_error *error);
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
deleted file mode 100644 (file)
index 1b26e55..0000000
+++ /dev/null
@@ -1,2157 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <unistd.h>
-
-#include "log.h"
-#include "strv.h"
-#include "build.h"
-#include "install.h"
-#include "selinux-access.h"
-#include "watchdog.h"
-#include "clock-util.h"
-#include "path-util.h"
-#include "virt.h"
-#include "architecture.h"
-#include "env-util.h"
-#include "dbus.h"
-#include "dbus-job.h"
-#include "dbus-manager.h"
-#include "dbus-unit.h"
-#include "dbus-snapshot.h"
-#include "dbus-execute.h"
-#include "bus-common-errors.h"
-
-static int property_get_version(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        assert(bus);
-        assert(reply);
-
-        return sd_bus_message_append(reply, "s", PACKAGE_VERSION);
-}
-
-static int property_get_features(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        assert(bus);
-        assert(reply);
-
-        return sd_bus_message_append(reply, "s", SYSTEMD_FEATURES);
-}
-
-static int property_get_virtualization(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        const char *id = NULL;
-
-        assert(bus);
-        assert(reply);
-
-        detect_virtualization(&id);
-
-        return sd_bus_message_append(reply, "s", id);
-}
-
-static int property_get_architecture(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        assert(bus);
-        assert(reply);
-
-        return sd_bus_message_append(reply, "s", architecture_to_string(uname_architecture()));
-}
-
-static int property_get_tainted(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        char buf[sizeof("split-usr:mtab-not-symlink:cgroups-missing:local-hwclock:")] = "", *e = buf;
-        _cleanup_free_ char *p = NULL;
-        Manager *m = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(m);
-
-        if (m->taint_usr)
-                e = stpcpy(e, "split-usr:");
-
-        if (readlink_malloc("/etc/mtab", &p) < 0)
-                e = stpcpy(e, "mtab-not-symlink:");
-
-        if (access("/proc/cgroups", F_OK) < 0)
-                e = stpcpy(e, "cgroups-missing:");
-
-        if (clock_is_localtime() > 0)
-                e = stpcpy(e, "local-hwclock:");
-
-        /* remove the last ':' */
-        if (e != buf)
-                e[-1] = 0;
-
-        return sd_bus_message_append(reply, "s", buf);
-}
-
-static int property_get_log_target(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        assert(bus);
-        assert(reply);
-
-        return sd_bus_message_append(reply, "s", log_target_to_string(log_get_target()));
-}
-
-static int property_set_log_target(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *value,
-                void *userdata,
-                sd_bus_error *error) {
-
-        const char *t;
-        int r;
-
-        assert(bus);
-        assert(value);
-
-        r = sd_bus_message_read(value, "s", &t);
-        if (r < 0)
-                return r;
-
-        return log_set_target_from_string(t);
-}
-
-static int property_get_log_level(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        _cleanup_free_ char *t = NULL;
-        int r;
-
-        assert(bus);
-        assert(reply);
-
-        r = log_level_to_string_alloc(log_get_max_level(), &t);
-        if (r < 0)
-                return r;
-
-        return sd_bus_message_append(reply, "s", t);
-}
-
-static int property_set_log_level(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *value,
-                void *userdata,
-                sd_bus_error *error) {
-
-        const char *t;
-        int r;
-
-        assert(bus);
-        assert(value);
-
-        r = sd_bus_message_read(value, "s", &t);
-        if (r < 0)
-                return r;
-
-        return log_set_max_level_from_string(t);
-}
-
-static int property_get_n_names(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        Manager *m = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(m);
-
-        return sd_bus_message_append(reply, "u", (uint32_t) hashmap_size(m->units));
-}
-
-static int property_get_n_failed_units(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        Manager *m = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(m);
-
-        return sd_bus_message_append(reply, "u", (uint32_t) set_size(m->failed_units));
-}
-
-static int property_get_n_jobs(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        Manager *m = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(m);
-
-        return sd_bus_message_append(reply, "u", (uint32_t) hashmap_size(m->jobs));
-}
-
-static int property_get_progress(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        Manager *m = userdata;
-        double d;
-
-        assert(bus);
-        assert(reply);
-        assert(m);
-
-        if (dual_timestamp_is_set(&m->finish_timestamp))
-                d = 1.0;
-        else
-                d = 1.0 - ((double) hashmap_size(m->jobs) / (double) m->n_installed_jobs);
-
-        return sd_bus_message_append(reply, "d", d);
-}
-
-static int property_get_system_state(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        Manager *m = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(m);
-
-        return sd_bus_message_append(reply, "s", manager_state_to_string(manager_state(m)));
-}
-
-static int property_set_runtime_watchdog(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *value,
-                void *userdata,
-                sd_bus_error *error) {
-
-        usec_t *t = userdata;
-        int r;
-
-        assert(bus);
-        assert(value);
-
-        assert_cc(sizeof(usec_t) == sizeof(uint64_t));
-
-        r = sd_bus_message_read(value, "t", t);
-        if (r < 0)
-                return r;
-
-        return watchdog_set_timeout(t);
-}
-
-static int method_get_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_free_ char *path = NULL;
-        Manager *m = userdata;
-        const char *name;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        /* Anyone can call this method */
-
-        r = sd_bus_message_read(message, "s", &name);
-        if (r < 0)
-                return r;
-
-        if (isempty(name)) {
-                _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
-                pid_t pid;
-
-                r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
-                if (r < 0)
-                        return r;
-
-                r = sd_bus_creds_get_pid(creds, &pid);
-                if (r < 0)
-                        return r;
-
-                u = manager_get_unit_by_pid(m, pid);
-                if (!u)
-                        return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Client not member of any unit.");
-        } else {
-                u = manager_get_unit(m, name);
-                if (!u)
-                        return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not loaded.", name);
-        }
-
-        r = mac_selinux_unit_access_check(u, message, "status", error);
-        if (r < 0)
-                return r;
-
-        path = unit_dbus_path(u);
-        if (!path)
-                return -ENOMEM;
-
-        return sd_bus_reply_method_return(message, "o", path);
-}
-
-static int method_get_unit_by_pid(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_free_ char *path = NULL;
-        Manager *m = userdata;
-        pid_t pid;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        assert_cc(sizeof(pid_t) == sizeof(uint32_t));
-
-        /* Anyone can call this method */
-
-        r = sd_bus_message_read(message, "u", &pid);
-        if (r < 0)
-                return r;
-        if (pid < 0)
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid PID " PID_FMT, pid);
-
-        if (pid == 0) {
-                _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
-
-                r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
-                if (r < 0)
-                        return r;
-
-                r = sd_bus_creds_get_pid(creds, &pid);
-                if (r < 0)
-                        return r;
-        }
-
-        u = manager_get_unit_by_pid(m, pid);
-        if (!u)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_UNIT_FOR_PID, "PID "PID_FMT" does not belong to any loaded unit.", pid);
-
-        r = mac_selinux_unit_access_check(u, message, "status", error);
-        if (r < 0)
-                return r;
-
-        path = unit_dbus_path(u);
-        if (!path)
-                return -ENOMEM;
-
-        return sd_bus_reply_method_return(message, "o", path);
-}
-
-static int method_load_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_free_ char *path = NULL;
-        Manager *m = userdata;
-        const char *name;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        /* Anyone can call this method */
-
-        r = sd_bus_message_read(message, "s", &name);
-        if (r < 0)
-                return r;
-
-        if (isempty(name)) {
-                _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
-                pid_t pid;
-
-                r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
-                if (r < 0)
-                        return r;
-
-                r = sd_bus_creds_get_pid(creds, &pid);
-                if (r < 0)
-                        return r;
-
-                u = manager_get_unit_by_pid(m, pid);
-                if (!u)
-                        return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Client not member of any unit.");
-        } else {
-                r = manager_load_unit(m, name, NULL, error, &u);
-                if (r < 0)
-                        return r;
-        }
-
-        r = mac_selinux_unit_access_check(u, message, "status", error);
-        if (r < 0)
-                return r;
-
-        path = unit_dbus_path(u);
-        if (!path)
-                return -ENOMEM;
-
-        return sd_bus_reply_method_return(message, "o", path);
-}
-
-static int method_start_unit_generic(sd_bus *bus, sd_bus_message *message, Manager *m, JobType job_type, bool reload_if_possible, sd_bus_error *error) {
-        const char *name;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = sd_bus_message_read(message, "s", &name);
-        if (r < 0)
-                return r;
-
-        r = manager_load_unit(m, name, NULL, error, &u);
-        if (r < 0)
-                return r;
-
-        return bus_unit_method_start_generic(bus, message, u, job_type, reload_if_possible, error);
-}
-
-static int method_start_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        return method_start_unit_generic(bus, message, userdata, JOB_START, false, error);
-}
-
-static int method_stop_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        return method_start_unit_generic(bus, message, userdata, JOB_STOP, false, error);
-}
-
-static int method_reload_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        return method_start_unit_generic(bus, message, userdata, JOB_RELOAD, false, error);
-}
-
-static int method_restart_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        return method_start_unit_generic(bus, message, userdata, JOB_RESTART, false, error);
-}
-
-static int method_try_restart_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        return method_start_unit_generic(bus, message, userdata, JOB_TRY_RESTART, false, error);
-}
-
-static int method_reload_or_restart_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        return method_start_unit_generic(bus, message, userdata, JOB_RESTART, true, error);
-}
-
-static int method_reload_or_try_restart_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        return method_start_unit_generic(bus, message, userdata, JOB_TRY_RESTART, true, error);
-}
-
-static int method_start_unit_replace(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        const char *old_name;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = sd_bus_message_read(message, "s", &old_name);
-        if (r < 0)
-                return r;
-
-        u = manager_get_unit(m, old_name);
-        if (!u || !u->job || u->job->type != JOB_START)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_JOB, "No job queued for unit %s", old_name);
-
-        return method_start_unit_generic(bus, message, m, JOB_START, false, error);
-}
-
-static int method_kill_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        const char *name;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = sd_bus_message_read(message, "s", &name);
-        if (r < 0)
-                return r;
-
-        u = manager_get_unit(m, name);
-        if (!u)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name);
-
-        return bus_unit_method_kill(bus, message, u, error);
-}
-
-static int method_reset_failed_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        const char *name;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = sd_bus_message_read(message, "s", &name);
-        if (r < 0)
-                return r;
-
-        u = manager_get_unit(m, name);
-        if (!u)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name);
-
-        return bus_unit_method_reset_failed(bus, message, u, error);
-}
-
-static int method_set_unit_properties(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        const char *name;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = sd_bus_message_read(message, "s", &name);
-        if (r < 0)
-                return r;
-
-        u = manager_get_unit(m, name);
-        if (!u)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name);
-
-        return bus_unit_method_set_properties(bus, message, u, error);
-}
-
-static int transient_unit_from_message(
-                Manager *m,
-                sd_bus_message *message,
-                const char *name,
-                Unit **unit,
-                sd_bus_error *error) {
-
-        Unit *u;
-        int r;
-
-        assert(m);
-        assert(message);
-        assert(name);
-
-        r = manager_load_unit(m, name, NULL, error, &u);
-        if (r < 0)
-                return r;
-
-        if (u->load_state != UNIT_NOT_FOUND ||
-            set_size(u->dependencies[UNIT_REFERENCED_BY]) > 0)
-                return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS, "Unit %s already exists.", name);
-
-        /* OK, the unit failed to load and is unreferenced, now let's
-         * fill in the transient data instead */
-        r = unit_make_transient(u);
-        if (r < 0)
-                return r;
-
-        /* Set our properties */
-        r = bus_unit_set_properties(u, message, UNIT_RUNTIME, false, error);
-        if (r < 0)
-                return r;
-
-        *unit = u;
-
-        return 0;
-}
-
-static int transient_aux_units_from_message(
-                Manager *m,
-                sd_bus_message *message,
-                sd_bus_error *error) {
-
-        Unit *u;
-        char *name = NULL;
-        int r;
-
-        assert(m);
-        assert(message);
-
-        r = sd_bus_message_enter_container(message, 'a', "(sa(sv))");
-        if (r < 0)
-                return r;
-
-        while ((r = sd_bus_message_enter_container(message, 'r', "sa(sv)")) > 0) {
-                r = sd_bus_message_read(message, "s", &name);
-                if (r < 0)
-                        return r;
-
-                r = transient_unit_from_message(m, message, name, &u, error);
-                if (r < 0 && r != -EEXIST)
-                        return r;
-
-                if (r != -EEXIST) {
-                        r = unit_load(u);
-                        if (r < 0)
-                                return r;
-                }
-
-                r = sd_bus_message_exit_container(message);
-                if (r < 0)
-                        return r;
-        }
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_exit_container(message);
-        if (r < 0)
-                return r;
-
-        return 0;
-}
-
-static int method_start_transient_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        const char *name, *smode;
-        Manager *m = userdata;
-        JobMode mode;
-        UnitType t;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "start", error);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_read(message, "ss", &name, &smode);
-        if (r < 0)
-                return r;
-
-        t = unit_name_to_type(name);
-        if (t < 0)
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid unit type.");
-
-        if (!unit_vtable[t]->can_transient)
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unit type %s does not support transient units.", unit_type_to_string(t));
-
-        mode = job_mode_from_string(smode);
-        if (mode < 0)
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Job mode %s is invalid.", smode);
-
-        r = bus_verify_manage_units_async(m, message, error);
-        if (r < 0)
-                return r;
-        if (r == 0)
-                return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
-
-        r = transient_unit_from_message(m, message, name, &u, error);
-        if (r < 0)
-                return r;
-
-        r = transient_aux_units_from_message(m, message, error);
-        if (r < 0)
-                return r;
-
-        /* And load this stub fully */
-        r = unit_load(u);
-        if (r < 0)
-                return r;
-
-        manager_dispatch_load_queue(m);
-
-        /* Finally, start it */
-        return bus_unit_queue_job(bus, message, u, JOB_START, mode, false, error);
-}
-
-static int method_get_job(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_free_ char *path = NULL;
-        Manager *m = userdata;
-        uint32_t id;
-        Job *j;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        /* Anyone can call this method */
-
-        r = sd_bus_message_read(message, "u", &id);
-        if (r < 0)
-                return r;
-
-        j = manager_get_job(m, id);
-        if (!j)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_JOB, "Job %u does not exist.", (unsigned) id);
-
-        r = mac_selinux_unit_access_check(j->unit, message, "status", error);
-        if (r < 0)
-                return r;
-
-        path = job_dbus_path(j);
-        if (!path)
-                return -ENOMEM;
-
-        return sd_bus_reply_method_return(message, "o", path);
-}
-
-static int method_cancel_job(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        uint32_t id;
-        Job *j;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = sd_bus_message_read(message, "u", &id);
-        if (r < 0)
-                return r;
-
-        j = manager_get_job(m, id);
-        if (!j)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_JOB, "Job %u does not exist.", (unsigned) id);
-
-        return bus_job_method_cancel(bus, message, j, error);
-}
-
-static int method_clear_jobs(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "reload", error);
-        if (r < 0)
-                return r;
-
-        r = bus_verify_manage_units_async(m, message, error);
-        if (r < 0)
-                return r;
-        if (r == 0)
-                return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
-
-        manager_clear_jobs(m);
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_reset_failed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "reload", error);
-        if (r < 0)
-                return r;
-
-        r = bus_verify_manage_units_async(m, message, error);
-        if (r < 0)
-                return r;
-        if (r == 0)
-                return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
-
-        manager_reset_failed(m);
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int list_units_filtered(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error, char **states) {
-        _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
-        Manager *m = userdata;
-        const char *k;
-        Iterator i;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        /* Anyone can call this method */
-
-        r = mac_selinux_access_check(message, "status", error);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_new_method_return(message, &reply);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_open_container(reply, 'a', "(ssssssouso)");
-        if (r < 0)
-                return r;
-
-        HASHMAP_FOREACH_KEY(u, k, m->units, i) {
-                _cleanup_free_ char *unit_path = NULL, *job_path = NULL;
-                Unit *following;
-
-                if (k != u->id)
-                        continue;
-
-                following = unit_following(u);
-
-                if (!strv_isempty(states) &&
-                    !strv_contains(states, unit_load_state_to_string(u->load_state)) &&
-                    !strv_contains(states, unit_active_state_to_string(unit_active_state(u))) &&
-                    !strv_contains(states, unit_sub_state_to_string(u)))
-                        continue;
-
-                unit_path = unit_dbus_path(u);
-                if (!unit_path)
-                        return -ENOMEM;
-
-                if (u->job) {
-                        job_path = job_dbus_path(u->job);
-                        if (!job_path)
-                                return -ENOMEM;
-                }
-
-                r = sd_bus_message_append(
-                                reply, "(ssssssouso)",
-                                u->id,
-                                unit_description(u),
-                                unit_load_state_to_string(u->load_state),
-                                unit_active_state_to_string(unit_active_state(u)),
-                                unit_sub_state_to_string(u),
-                                following ? following->id : "",
-                                unit_path,
-                                u->job ? u->job->id : 0,
-                                u->job ? job_type_to_string(u->job->type) : "",
-                                job_path ? job_path : "/");
-                if (r < 0)
-                        return r;
-        }
-
-        r = sd_bus_message_close_container(reply);
-        if (r < 0)
-                return r;
-
-        return sd_bus_send(bus, reply, NULL);
-}
-
-static int method_list_units(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        return list_units_filtered(bus, message, userdata, error, NULL);
-}
-
-static int method_list_units_filtered(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_strv_free_ char **states = NULL;
-        int r;
-
-        r = sd_bus_message_read_strv(message, &states);
-        if (r < 0)
-                return r;
-
-        return list_units_filtered(bus, message, userdata, error, states);
-}
-
-static int method_list_jobs(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
-        Manager *m = userdata;
-        Iterator i;
-        Job *j;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        /* Anyone can call this method */
-
-        r = mac_selinux_access_check(message, "status", error);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_new_method_return(message, &reply);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_open_container(reply, 'a', "(usssoo)");
-        if (r < 0)
-                return r;
-
-        HASHMAP_FOREACH(j, m->jobs, i) {
-                _cleanup_free_ char *unit_path = NULL, *job_path = NULL;
-
-                job_path = job_dbus_path(j);
-                if (!job_path)
-                        return -ENOMEM;
-
-                unit_path = unit_dbus_path(j->unit);
-                if (!unit_path)
-                        return -ENOMEM;
-
-                r = sd_bus_message_append(
-                                reply, "(usssoo)",
-                                j->id,
-                                j->unit->id,
-                                job_type_to_string(j->type),
-                                job_state_to_string(j->state),
-                                job_path,
-                                unit_path);
-                if (r < 0)
-                        return r;
-        }
-
-        r = sd_bus_message_close_container(reply);
-        if (r < 0)
-                return r;
-
-        return sd_bus_send(bus, reply, NULL);
-}
-
-static int method_subscribe(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        /* Anyone can call this method */
-
-        r = mac_selinux_access_check(message, "status", error);
-        if (r < 0)
-                return r;
-
-        if (bus == m->api_bus) {
-
-                /* Note that direct bus connection subscribe by
-                 * default, we only track peers on the API bus here */
-
-                if (!m->subscribed) {
-                        r = sd_bus_track_new(bus, &m->subscribed, NULL, NULL);
-                        if (r < 0)
-                                return r;
-                }
-
-                r = sd_bus_track_add_sender(m->subscribed, message);
-                if (r < 0)
-                        return r;
-                if (r == 0)
-                        return sd_bus_error_setf(error, BUS_ERROR_ALREADY_SUBSCRIBED, "Client is already subscribed.");
-        }
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_unsubscribe(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        /* Anyone can call this method */
-
-        r = mac_selinux_access_check(message, "status", error);
-        if (r < 0)
-                return r;
-
-        if (bus == m->api_bus) {
-                r = sd_bus_track_remove_sender(m->subscribed, message);
-                if (r < 0)
-                        return r;
-                if (r == 0)
-                        return sd_bus_error_setf(error, BUS_ERROR_NOT_SUBSCRIBED, "Client is not subscribed.");
-        }
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_dump(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_free_ char *dump = NULL;
-        _cleanup_fclose_ FILE *f = NULL;
-        Manager *m = userdata;
-        size_t size;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        /* Anyone can call this method */
-
-        r = mac_selinux_access_check(message, "status", error);
-        if (r < 0)
-                return r;
-
-        f = open_memstream(&dump, &size);
-        if (!f)
-                return -ENOMEM;
-
-        manager_dump_units(m, f, NULL);
-        manager_dump_jobs(m, f, NULL);
-
-        fflush(f);
-
-        if (ferror(f))
-                return -ENOMEM;
-
-        return sd_bus_reply_method_return(message, "s", dump);
-}
-
-static int method_create_snapshot(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_free_ char *path = NULL;
-        Manager *m = userdata;
-        const char *name;
-        int cleanup;
-        Snapshot *s = NULL;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "start", error);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_read(message, "sb", &name, &cleanup);
-        if (r < 0)
-                return r;
-
-        if (isempty(name))
-                name = NULL;
-
-        r = bus_verify_manage_units_async(m, message, error);
-        if (r < 0)
-                return r;
-        if (r == 0)
-                return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
-
-        r = snapshot_create(m, name, cleanup, error, &s);
-        if (r < 0)
-                return r;
-
-        path = unit_dbus_path(UNIT(s));
-        if (!path)
-                return -ENOMEM;
-
-        return sd_bus_reply_method_return(message, "o", path);
-}
-
-static int method_remove_snapshot(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        const char *name;
-        Unit *u;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = sd_bus_message_read(message, "s", &name);
-        if (r < 0)
-                return r;
-
-        u = manager_get_unit(m, name);
-        if (!u)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s does not exist.", name);
-
-        if (u->type != UNIT_SNAPSHOT)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not a snapshot", name);
-
-        return bus_snapshot_method_remove(bus, message, u, error);
-}
-
-static int method_reload(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "reload", error);
-        if (r < 0)
-                return r;
-
-        r = bus_verify_reload_daemon_async(m, message, error);
-        if (r < 0)
-                return r;
-        if (r == 0)
-                return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
-
-        /* Instead of sending the reply back right away, we just
-         * remember that we need to and then send it after the reload
-         * is finished. That way the caller knows when the reload
-         * finished. */
-
-        assert(!m->queued_message);
-        r = sd_bus_message_new_method_return(message, &m->queued_message);
-        if (r < 0)
-                return r;
-
-        m->queued_message_bus = sd_bus_ref(bus);
-        m->exit_code = MANAGER_RELOAD;
-
-        return 1;
-}
-
-static int method_reexecute(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "reload", error);
-        if (r < 0)
-                return r;
-
-        r = bus_verify_reload_daemon_async(m, message, error);
-        if (r < 0)
-                return r;
-        if (r == 0)
-                return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
-
-        /* We don't send a reply back here, the client should
-         * just wait for us disconnecting. */
-
-        m->exit_code = MANAGER_REEXECUTE;
-        return 1;
-}
-
-static int method_exit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "halt", error);
-        if (r < 0)
-                return r;
-
-        if (m->running_as == SYSTEMD_SYSTEM)
-                return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Exit is only supported for user service managers.");
-
-        m->exit_code = MANAGER_EXIT;
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_reboot(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "reboot", error);
-        if (r < 0)
-                return r;
-
-        if (m->running_as != SYSTEMD_SYSTEM)
-                return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Reboot is only supported for system managers.");
-
-        m->exit_code = MANAGER_REBOOT;
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "halt", error);
-        if (r < 0)
-                return r;
-
-        if (m->running_as != SYSTEMD_SYSTEM)
-                return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Powering off is only supported for system managers.");
-
-        m->exit_code = MANAGER_POWEROFF;
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_halt(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "halt", error);
-        if (r < 0)
-                return r;
-
-        if (m->running_as != SYSTEMD_SYSTEM)
-                return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Halt is only supported for system managers.");
-
-        m->exit_code = MANAGER_HALT;
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_kexec(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "reboot", error);
-        if (r < 0)
-                return r;
-
-        if (m->running_as != SYSTEMD_SYSTEM)
-                return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "KExec is only supported for system managers.");
-
-        m->exit_code = MANAGER_KEXEC;
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_switch_root(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        char *ri = NULL, *rt = NULL;
-        const char *root, *init;
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "reboot", error);
-        if (r < 0)
-                return r;
-
-        if (m->running_as != SYSTEMD_SYSTEM)
-                return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Root switching is only supported by system manager.");
-
-        r = sd_bus_message_read(message, "ss", &root, &init);
-        if (r < 0)
-                return r;
-
-        if (path_equal(root, "/") || !path_is_absolute(root))
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid switch root path %s", root);
-
-        /* Safety check */
-        if (isempty(init)) {
-                if (!path_is_os_tree(root))
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Specified switch root path %s does not seem to be an OS tree. os-release file is missing.", root);
-        } else {
-                _cleanup_free_ char *p = NULL;
-
-                if (!path_is_absolute(init))
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid init path %s", init);
-
-                p = strappend(root, init);
-                if (!p)
-                        return -ENOMEM;
-
-                if (access(p, X_OK) < 0)
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Specified init binary %s does not exist.", p);
-        }
-
-        rt = strdup(root);
-        if (!rt)
-                return -ENOMEM;
-
-        if (!isempty(init)) {
-                ri = strdup(init);
-                if (!ri) {
-                        free(rt);
-                        return -ENOMEM;
-                }
-        }
-
-        free(m->switch_root);
-        m->switch_root = rt;
-
-        free(m->switch_root_init);
-        m->switch_root_init = ri;
-
-        m->exit_code = MANAGER_SWITCH_ROOT;
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_set_environment(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_strv_free_ char **plus = NULL;
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "reload", error);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_read_strv(message, &plus);
-        if (r < 0)
-                return r;
-        if (!strv_env_is_valid(plus))
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments");
-
-        r = bus_verify_set_environment_async(m, message, error);
-        if (r < 0)
-                return r;
-        if (r == 0)
-                return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
-
-        r = manager_environment_add(m, NULL, plus);
-        if (r < 0)
-                return r;
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_unset_environment(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_strv_free_ char **minus = NULL;
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "reload", error);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_read_strv(message, &minus);
-        if (r < 0)
-                return r;
-
-        if (!strv_env_name_or_assignment_is_valid(minus))
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment variable names or assignments");
-
-        r = bus_verify_set_environment_async(m, message, error);
-        if (r < 0)
-                return r;
-        if (r == 0)
-                return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
-
-        r = manager_environment_add(m, minus, NULL);
-        if (r < 0)
-                return r;
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_unset_and_set_environment(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_strv_free_ char **minus = NULL, **plus = NULL;
-        Manager *m = userdata;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = mac_selinux_access_check(message, "reload", error);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_read_strv(message, &minus);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_read_strv(message, &plus);
-        if (r < 0)
-                return r;
-
-        if (!strv_env_name_or_assignment_is_valid(minus))
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment variable names or assignments");
-        if (!strv_env_is_valid(plus))
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments");
-
-        r = bus_verify_set_environment_async(m, message, error);
-        if (r < 0)
-                return r;
-        if (r == 0)
-                return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
-
-        r = manager_environment_add(m, minus, plus);
-        if (r < 0)
-                return r;
-
-        return sd_bus_reply_method_return(message, NULL);
-}
-
-static int method_list_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
-        Manager *m = userdata;
-        UnitFileList *item;
-        Hashmap *h;
-        Iterator i;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        /* Anyone can call this method */
-
-        r = mac_selinux_access_check(message, "status", error);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_new_method_return(message, &reply);
-        if (r < 0)
-                return r;
-
-        h = hashmap_new(&string_hash_ops);
-        if (!h)
-                return -ENOMEM;
-
-        r = unit_file_get_list(m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, h);
-        if (r < 0)
-                goto fail;
-
-        r = sd_bus_message_open_container(reply, 'a', "(ss)");
-        if (r < 0)
-                goto fail;
-
-        HASHMAP_FOREACH(item, h, i) {
-
-                r = sd_bus_message_append(reply, "(ss)", item->path, unit_file_state_to_string(item->state));
-                if (r < 0)
-                        goto fail;
-        }
-
-        unit_file_list_free(h);
-
-        r = sd_bus_message_close_container(reply);
-        if (r < 0)
-                return r;
-
-        return sd_bus_send(bus, reply, NULL);
-
-fail:
-        unit_file_list_free(h);
-        return r;
-}
-
-static int method_get_unit_file_state(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        const char *name;
-        UnitFileState state;
-        UnitFileScope scope;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        /* Anyone can call this method */
-
-        r = mac_selinux_access_check(message, "status", error);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_read(message, "s", &name);
-        if (r < 0)
-                return r;
-
-        scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
-
-        state = unit_file_get_state(scope, NULL, name);
-        if (state < 0)
-              &nbs