1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
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"
27 #include "dbus-common.h"
29 #ifdef HAVE_SYSV_COMPAT
30 #define BUS_SERVICE_SYSV_INTERFACE_FRAGMENT \
31 " <property name=\"SysVStartPriority\" type=\"i\" access=\"read\"/>\n" \
32 " <property name=\"SysVRunLevels\" type=\"s\" access=\"read\"/>\n" \
33 " <property name=\"SysVPath\" type=\"s\" access=\"read\"/>\n"
35 #define BUS_SERVICE_SYSV_INTERFACE_FRAGMENT ""
38 #define BUS_SERVICE_INTERFACE \
39 " <interface name=\"org.freedesktop.systemd1.Service\">\n" \
40 " <property name=\"Type\" type=\"s\" access=\"read\"/>\n" \
41 " <property name=\"Restart\" type=\"s\" access=\"read\"/>\n" \
42 " <property name=\"PIDFile\" type=\"s\" access=\"read\"/>\n" \
43 " <property name=\"NotifyAccess\" type=\"s\" access=\"read\"/>\n" \
44 " <property name=\"RestartUSec\" type=\"t\" access=\"read\"/>\n" \
45 " <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
46 BUS_EXEC_COMMAND_INTERFACE("ExecStartPre") \
47 BUS_EXEC_COMMAND_INTERFACE("ExecStart") \
48 BUS_EXEC_COMMAND_INTERFACE("ExecStartPost") \
49 BUS_EXEC_COMMAND_INTERFACE("ExecReload") \
50 BUS_EXEC_COMMAND_INTERFACE("ExecStop") \
51 BUS_EXEC_COMMAND_INTERFACE("ExecStopPost") \
52 BUS_EXEC_CONTEXT_INTERFACE \
53 " <property name=\"PermissionsStartOnly\" type=\"b\" access=\"read\"/>\n" \
54 " <property name=\"RootDirectoryStartOnly\" type=\"b\" access=\"read\"/>\n" \
55 " <property name=\"RemainAfterExit\" type=\"b\" access=\"read\"/>\n" \
56 BUS_EXEC_STATUS_INTERFACE("ExecMain") \
57 " <property name=\"MainPID\" type=\"u\" access=\"read\"/>\n" \
58 " <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
59 " <property name=\"BusName\" type=\"s\" access=\"read\"/>\n" \
60 " <property name=\"StatusText\" type=\"s\" access=\"read\"/>\n" \
61 " <property name=\"FsckPassNo\" type=\"i\" access=\"read\"/>\n" \
62 " <property name=\"Sockets\" type=\"as\" access=\"read\"/>\n" \
63 BUS_SERVICE_SYSV_INTERFACE_FRAGMENT \
66 #define INTROSPECTION \
67 DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
70 BUS_SERVICE_INTERFACE \
71 BUS_PROPERTIES_INTERFACE \
73 BUS_INTROSPECTABLE_INTERFACE \
76 #define INTERFACES_LIST \
77 BUS_UNIT_INTERFACES_LIST \
78 "org.freedesktop.systemd1.Service\0"
80 const char bus_service_interface[] _introspect_("Service") = BUS_SERVICE_INTERFACE;
82 const char bus_service_invalidating_properties[] =
94 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_type, service_type, ServiceType);
95 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_restart, service_restart, ServiceRestart);
96 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_notify_access, notify_access, NotifyAccess);
98 DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connection, DBusMessage *message) {
99 const BusProperty properties[] = {
101 { "org.freedesktop.systemd1.Service", "Type", bus_service_append_type, "s", &u->service.type },
102 { "org.freedesktop.systemd1.Service", "Restart", bus_service_append_restart, "s", &u->service.restart },
103 { "org.freedesktop.systemd1.Service", "PIDFile", bus_property_append_string, "s", u->service.pid_file },
104 { "org.freedesktop.systemd1.Service", "NotifyAccess", bus_service_append_notify_access, "s", &u->service.notify_access },
105 { "org.freedesktop.systemd1.Service", "RestartUSec", bus_property_append_usec, "t", &u->service.restart_usec },
106 { "org.freedesktop.systemd1.Service", "TimeoutUSec", bus_property_append_usec, "t", &u->service.timeout_usec },
107 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_START_PRE], "ExecStartPre"),
108 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_START], "ExecStart"),
109 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_START_POST], "ExecStartPost"),
110 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_RELOAD], "ExecReload"),
111 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_STOP], "ExecStop"),
112 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_STOP_POST], "ExecStopPost"),
113 BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Service", u->service.exec_context),
114 { "org.freedesktop.systemd1.Service", "PermissionsStartOnly", bus_property_append_bool, "b", &u->service.permissions_start_only },
115 { "org.freedesktop.systemd1.Service", "RootDirectoryStartOnly", bus_property_append_bool, "b", &u->service.root_directory_start_only },
116 { "org.freedesktop.systemd1.Service", "RemainAfterExit", bus_property_append_bool, "b", &u->service.remain_after_exit },
117 { "org.freedesktop.systemd1.Service", "GuessMainPID", bus_property_append_bool, "b", &u->service.guess_main_pid },
118 BUS_EXEC_STATUS_PROPERTIES("org.freedesktop.systemd1.Service", u->service.main_exec_status, "ExecMain"),
119 { "org.freedesktop.systemd1.Service", "MainPID", bus_property_append_pid, "u", &u->service.main_pid },
120 { "org.freedesktop.systemd1.Service", "ControlPID", bus_property_append_pid, "u", &u->service.control_pid },
121 { "org.freedesktop.systemd1.Service", "BusName", bus_property_append_string, "s", u->service.bus_name },
122 { "org.freedesktop.systemd1.Service", "StatusText", bus_property_append_string, "s", u->service.status_text },
123 { "org.freedesktop.systemd1.Service", "Sockets", bus_unit_append_dependencies, "as", u->service.configured_sockets },
124 #ifdef HAVE_SYSV_COMPAT
125 { "org.freedesktop.systemd1.Service", "SysVRunLevels", bus_property_append_string, "s", u->service.sysv_runlevels },
126 { "org.freedesktop.systemd1.Service", "SysVStartPriority", bus_property_append_int, "i", &u->service.sysv_start_priority },
127 { "org.freedesktop.systemd1.Service", "SysVPath", bus_property_append_string, "s", u->service.sysv_path },
129 { "org.freedesktop.systemd1.Service", "FsckPassNo", bus_property_append_int, "i", &u->service.fsck_passno },
130 { NULL, NULL, NULL, NULL, NULL }
133 return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties);