chiark / gitweb /
systemadm: don't show id in aliases field again
[elogind.git] / dbus-service.c
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2010 Lennart Poettering
7
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.
12
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.
17
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/>.
20 ***/
21
22 #include <errno.h>
23
24 #include "dbus-unit.h"
25 #include "dbus-execute.h"
26 #include "dbus-service.h"
27
28 static const char introspection[] =
29         DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
30         "<node>"
31         BUS_UNIT_INTERFACE
32         BUS_PROPERTIES_INTERFACE
33         " <interface name=\"org.freedesktop.systemd1.Service\">"
34         "  <property name=\"Type\" type=\"s\" access=\"read\"/>"
35         "  <property name=\"Restart\" type=\"s\" access=\"read\"/>"
36         "  <property name=\"PIDFile\" type=\"s\" access=\"read\"/>"
37         "  <property name=\"RestartUSec\" type=\"t\" access=\"read\"/>"
38         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>"
39         BUS_EXEC_CONTEXT_INTERFACE
40         "  <property name=\"PermissionsStartOnly\" type=\"b\" access=\"read\"/>"
41         "  <property name=\"RootDirectoryStartOnly\" type=\"b\" access=\"read\"/>"
42         "  <property name=\"ValidNoProcess\" type=\"b\" access=\"read\"/>"
43         "  <property name=\"KillMode\" type=\"s\" access=\"read\"/>"
44         "  <property name=\"MainPID\" type=\"u\" access=\"read\"/>"
45         "  <property name=\"ControlPID\" type=\"u\" access=\"read\"/>"
46         "  <property name=\"SysVPath\" type=\"s\" access=\"read\"/>"
47         "  <property name=\"BusName\" type=\"s\" access=\"read\"/>"
48         " </interface>"
49         BUS_INTROSPECTABLE_INTERFACE
50         "</node>";
51
52 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_type, service_type, ServiceType);
53 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_restart, service_restart, ServiceRestart);
54
55 DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message) {
56         const BusProperty properties[] = {
57                 BUS_UNIT_PROPERTIES,
58                 { "org.freedesktop.systemd1.Service", "Type",                   bus_service_append_type,    "s", &u->service.type },
59                 { "org.freedesktop.systemd1.Service", "Restart",                bus_service_append_restart, "s", &u->service.restart },
60                 { "org.freedesktop.systemd1.Service", "PIDFile",                bus_property_append_string, "s", u->service.pid_file },
61                 { "org.freedesktop.systemd1.Service", "RestartUSec",            bus_property_append_usec,   "t", &u->service.restart_usec },
62                 { "org.freedesktop.systemd1.Service", "TimeoutUSec",            bus_property_append_usec,   "t", &u->service.timeout_usec },
63                 /* ExecCommand */
64                 BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Service", u->service.exec_context),
65                 { "org.freedesktop.systemd1.Service", "PermissionsStartOnly",   bus_property_append_bool,   "b", &u->service.permissions_start_only },
66                 { "org.freedesktop.systemd1.Service", "RootDirectoryStartOnly", bus_property_append_bool,   "b", &u->service.root_directory_start_only },
67                 { "org.freedesktop.systemd1.Service", "ValidNoProcess",         bus_property_append_bool,   "b", &u->service.valid_no_process },
68                 { "org.freedesktop.systemd1.Service", "KillMode",               bus_unit_append_kill_mode,  "s", &u->service.kill_mode },
69                 /* MainExecStatus */
70                 { "org.freedesktop.systemd1.Service", "MainPID",                bus_property_append_pid,    "u", &u->service.main_pid },
71                 { "org.freedesktop.systemd1.Service", "ControlPID",             bus_property_append_pid,    "u", &u->service.control_pid },
72                 { "org.freedesktop.systemd1.Service", "SysVPath",               bus_property_append_string, "s", u->service.sysv_path },
73                 { "org.freedesktop.systemd1.Service", "BusName",                bus_property_append_string, "s", u->service.bus_name },
74                 { NULL, NULL, NULL, NULL, NULL }
75         };
76
77         return bus_default_message_handler(u->meta.manager, message, introspection, properties);
78 }