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"
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_COMMAND_INTERFACE("ExecStartPre") \
37 BUS_EXEC_COMMAND_INTERFACE("ExecStart") \
38 BUS_EXEC_COMMAND_INTERFACE("ExecStartPost") \
39 BUS_EXEC_COMMAND_INTERFACE("ExecReload") \
40 BUS_EXEC_COMMAND_INTERFACE("ExecStop") \
41 BUS_EXEC_COMMAND_INTERFACE("ExecStopPost") \
42 BUS_EXEC_CONTEXT_INTERFACE \
43 " <property name=\"PermissionsStartOnly\" type=\"b\" access=\"read\"/>\n" \
44 " <property name=\"RootDirectoryStartOnly\" type=\"b\" access=\"read\"/>\n" \
45 " <property name=\"ValidNoProcess\" type=\"b\" access=\"read\"/>\n" \
46 BUS_EXEC_STATUS_INTERFACE("ExecMain") \
47 " <property name=\"MainPID\" type=\"u\" access=\"read\"/>\n" \
48 " <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
49 " <property name=\"SysVStartPriority\" type=\"i\" access=\"read\"/>\n" \
50 " <property name=\"SysVRunLevels\" type=\"s\" access=\"read\"/>\n" \
51 " <property name=\"SysVPath\" type=\"s\" access=\"read\"/>\n" \
52 " <property name=\"BusName\" type=\"s\" access=\"read\"/>\n" \
53 " <property name=\"StatusText\" type=\"s\" access=\"read\"/>\n" \
56 #define INTROSPECTION \
57 DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
60 BUS_SERVICE_INTERFACE \
61 BUS_PROPERTIES_INTERFACE \
62 BUS_INTROSPECTABLE_INTERFACE \
65 const char bus_service_interface
[] = BUS_SERVICE_INTERFACE
;
67 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_type
, service_type
, ServiceType
);
68 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_restart
, service_restart
, ServiceRestart
);
69 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_notify_access
, notify_access
, NotifyAccess
);
71 DBusHandlerResult
bus_service_message_handler(Unit
*u
, DBusConnection
*connection
, DBusMessage
*message
) {
72 const BusProperty properties
[] = {
74 { "org.freedesktop.systemd1.Service", "Type", bus_service_append_type
, "s", &u
->service
.type
},
75 { "org.freedesktop.systemd1.Service", "Restart", bus_service_append_restart
, "s", &u
->service
.restart
},
76 { "org.freedesktop.systemd1.Service", "PIDFile", bus_property_append_string
, "s", u
->service
.pid_file
},
77 { "org.freedesktop.systemd1.Service", "NotifyAccess", bus_service_append_notify_access
, "s", &u
->service
.notify_access
},
78 { "org.freedesktop.systemd1.Service", "RestartUSec", bus_property_append_usec
, "t", &u
->service
.restart_usec
},
79 { "org.freedesktop.systemd1.Service", "TimeoutUSec", bus_property_append_usec
, "t", &u
->service
.timeout_usec
},
80 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u
->service
.exec_command
[SERVICE_EXEC_START_PRE
], "ExecStartPre"),
81 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u
->service
.exec_command
[SERVICE_EXEC_START
], "ExecStart"),
82 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u
->service
.exec_command
[SERVICE_EXEC_START_POST
], "ExecStartPost"),
83 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u
->service
.exec_command
[SERVICE_EXEC_RELOAD
], "ExecReload"),
84 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u
->service
.exec_command
[SERVICE_EXEC_STOP
], "ExecStop"),
85 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u
->service
.exec_command
[SERVICE_EXEC_STOP_POST
], "ExecStopPost"),
86 BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Service", u
->service
.exec_context
),
87 { "org.freedesktop.systemd1.Service", "PermissionsStartOnly", bus_property_append_bool
, "b", &u
->service
.permissions_start_only
},
88 { "org.freedesktop.systemd1.Service", "RootDirectoryStartOnly", bus_property_append_bool
, "b", &u
->service
.root_directory_start_only
},
89 { "org.freedesktop.systemd1.Service", "ValidNoProcess", bus_property_append_bool
, "b", &u
->service
.valid_no_process
},
90 BUS_EXEC_STATUS_PROPERTIES("org.freedesktop.systemd1.Service", u
->service
.main_exec_status
, "ExecMain"),
91 { "org.freedesktop.systemd1.Service", "MainPID", bus_property_append_pid
, "u", &u
->service
.main_pid
},
92 { "org.freedesktop.systemd1.Service", "ControlPID", bus_property_append_pid
, "u", &u
->service
.control_pid
},
93 { "org.freedesktop.systemd1.Service", "SysVPath", bus_property_append_string
, "s", u
->service
.sysv_path
},
94 { "org.freedesktop.systemd1.Service", "BusName", bus_property_append_string
, "s", u
->service
.bus_name
},
95 { "org.freedesktop.systemd1.Service", "StatusText", bus_property_append_string
, "s", u
->service
.status_text
},
96 { "org.freedesktop.systemd1.Service", "SysVRunLevels", bus_property_append_string
, "s", u
->service
.sysv_runlevels
},
97 { "org.freedesktop.systemd1.Service", "SysVStartPriority", bus_property_append_int
, "i", &u
->service
.sysv_start_priority
},
98 { NULL
, NULL
, NULL
, NULL
, NULL
}
101 return bus_default_message_handler(u
->meta
.manager
, connection
, message
, INTROSPECTION
, properties
);