1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include "dbus-unit.h"
25 #include "dbus-execute.h"
26 #include "dbus-service.h"
28 #define BUS_SERVICE_INTERFACE \
29 " <interface name=\"org.freedesktop.systemd1.Service\">\n" \
30 " <property name=\"Type\" type=\"s\" access=\"read\"/>\n" \
31 " <property name=\"Restart\" type=\"s\" access=\"read\"/>\n" \
32 " <property name=\"PIDFile\" type=\"s\" access=\"read\"/>\n" \
33 " <property name=\"NotifyAccess\" type=\"s\" access=\"read\"/>\n" \
34 " <property name=\"RestartUSec\" type=\"t\" access=\"read\"/>\n" \
35 " <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
36 BUS_EXEC_CONTEXT_INTERFACE \
37 " <property name=\"PermissionsStartOnly\" type=\"b\" access=\"read\"/>\n" \
38 " <property name=\"RootDirectoryStartOnly\" type=\"b\" access=\"read\"/>\n" \
39 " <property name=\"ValidNoProcess\" type=\"b\" access=\"read\"/>\n" \
40 " <property name=\"KillMode\" type=\"s\" access=\"read\"/>\n" \
41 BUS_EXEC_STATUS_INTERFACE("ExecMain") \
42 " <property name=\"MainPID\" type=\"u\" access=\"read\"/>\n" \
43 " <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
44 " <property name=\"SysVStartPriority\" type=\"i\" access=\"read\"/>\n" \
45 " <property name=\"SysVRunLevels\" type=\"s\" access=\"read\"/>\n" \
46 " <property name=\"SysVPath\" type=\"s\" access=\"read\"/>\n" \
47 " <property name=\"BusName\" type=\"s\" access=\"read\"/>\n" \
48 " <property name=\"StatusText\" type=\"s\" access=\"read\"/>\n" \
51 #define INTROSPECTION \
52 DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
55 BUS_SERVICE_INTERFACE \
56 BUS_PROPERTIES_INTERFACE \
57 BUS_INTROSPECTABLE_INTERFACE \
60 const char bus_service_interface[] = BUS_SERVICE_INTERFACE;
62 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_type, service_type, ServiceType);
63 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_restart, service_restart, ServiceRestart);
64 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_notify_access, notify_access, NotifyAccess);
66 DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connection, DBusMessage *message) {
67 const BusProperty properties[] = {
69 { "org.freedesktop.systemd1.Service", "Type", bus_service_append_type, "s", &u->service.type },
70 { "org.freedesktop.systemd1.Service", "Restart", bus_service_append_restart, "s", &u->service.restart },
71 { "org.freedesktop.systemd1.Service", "PIDFile", bus_property_append_string, "s", u->service.pid_file },
72 { "org.freedesktop.systemd1.Service", "NotifyAccess", bus_service_append_notify_access, "s", &u->service.notify_access },
73 { "org.freedesktop.systemd1.Service", "RestartUSec", bus_property_append_usec, "t", &u->service.restart_usec },
74 { "org.freedesktop.systemd1.Service", "TimeoutUSec", bus_property_append_usec, "t", &u->service.timeout_usec },
76 BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Service", u->service.exec_context),
77 { "org.freedesktop.systemd1.Service", "PermissionsStartOnly", bus_property_append_bool, "b", &u->service.permissions_start_only },
78 { "org.freedesktop.systemd1.Service", "RootDirectoryStartOnly", bus_property_append_bool, "b", &u->service.root_directory_start_only },
79 { "org.freedesktop.systemd1.Service", "ValidNoProcess", bus_property_append_bool, "b", &u->service.valid_no_process },
80 { "org.freedesktop.systemd1.Service", "KillMode", bus_unit_append_kill_mode, "s", &u->service.kill_mode },
81 BUS_EXEC_STATUS_PROPERTIES("org.freedesktop.systemd1.Service", u->service.main_exec_status, "ExecMain"),
82 { "org.freedesktop.systemd1.Service", "MainPID", bus_property_append_pid, "u", &u->service.main_pid },
83 { "org.freedesktop.systemd1.Service", "ControlPID", bus_property_append_pid, "u", &u->service.control_pid },
84 { "org.freedesktop.systemd1.Service", "SysVPath", bus_property_append_string, "s", u->service.sysv_path },
85 { "org.freedesktop.systemd1.Service", "BusName", bus_property_append_string, "s", u->service.bus_name },
86 { "org.freedesktop.systemd1.Service", "StatusText", bus_property_append_string, "s", u->service.status_text },
87 { "org.freedesktop.systemd1.Service", "SysVRunLevels", bus_property_append_string, "s", u->service.sysv_runlevels },
88 { "org.freedesktop.systemd1.Service", "SysVStartPriority", bus_property_append_int, "i", &u->service.sysv_start_priority },
89 { NULL, NULL, NULL, NULL, NULL }
92 return bus_default_message_handler(u->meta.manager, connection, message, INTROSPECTION, properties);