]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/dbus-socket.c
strv: properly override settings in env_append()
[thirdparty/systemd.git] / src / dbus-socket.c
CommitLineData
d6c9574f 1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4139c1b2
LP
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
c0120d99
LP
22#include <errno.h>
23
4139c1b2
LP
24#include "dbus-unit.h"
25#include "dbus-socket.h"
26#include "dbus-execute.h"
27
4288f619
LP
28#define BUS_SOCKET_INTERFACE \
29 " <interface name=\"org.freedesktop.systemd1.Socket\">\n" \
30 " <property name=\"BindIPv6Only\" type=\"b\" access=\"read\"/>\n" \
31 " <property name=\"Backlog\" type=\"u\" access=\"read\"/>\n" \
32 " <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
fe68089d
LP
33 BUS_EXEC_COMMAND_INTERFACE("ExecStartPre") \
34 BUS_EXEC_COMMAND_INTERFACE("ExecStartPost") \
35 BUS_EXEC_COMMAND_INTERFACE("ExecStopPre") \
36 BUS_EXEC_COMMAND_INTERFACE("ExecStopPost") \
4288f619 37 BUS_EXEC_CONTEXT_INTERFACE \
4288f619
LP
38 " <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
39 " <property name=\"BindToDevice\" type=\"s\" access=\"read\"/>\n" \
40 " <property name=\"DirectoryMode\" type=\"u\" access=\"read\"/>\n" \
41 " <property name=\"SocketMode\" type=\"u\" access=\"read\"/>\n" \
42 " <property name=\"Accept\" type=\"b\" access=\"read\"/>\n" \
4fd5948e
LP
43 " <property name=\"KeepAlive\" type=\"b\" access=\"read\"/>\n" \
44 " <property name=\"Priority\" type=\"i\" access=\"read\"/>\n" \
2419cc5b
LP
45 " <property name=\"ReceiveBuffer\" type=\"t\" access=\"read\"/>\n" \
46 " <property name=\"SendBuffer\" type=\"t\" access=\"read\"/>\n" \
47 " <property name=\"IPTOS\" type=\"i\" access=\"read\"/>\n" \
48 " <property name=\"IPTTL\" type=\"i\" access=\"read\"/>\n" \
49 " <property name=\"PipeSize\" type=\"t\" access=\"read\"/>\n" \
50 " <property name=\"FreeBind\" type=\"b\" access=\"read\"/>\n" \
51 " <property name=\"Mark\" type=\"i\" access=\"read\"/>\n" \
4e1e43c8
LP
52 " <property name=\"MaxConnections\" type=\"u\" access=\"read\"/>\n" \
53 " <property name=\"NAccepted\" type=\"u\" access=\"read\"/>\n" \
54 " <property name=\"NConnections\" type=\"u\" access=\"read\"/>\n" \
4288f619
LP
55 " </interface>\n" \
56
57#define INTROSPECTION \
58 DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
59 "<node>\n" \
60 BUS_UNIT_INTERFACE \
61 BUS_SOCKET_INTERFACE \
62 BUS_PROPERTIES_INTERFACE \
c4e2ceae 63 BUS_PEER_INTERFACE \
4288f619
LP
64 BUS_INTROSPECTABLE_INTERFACE \
65 "</node>\n"
66
05feefe0
LP
67#define INTERFACES_LIST \
68 BUS_UNIT_INTERFACES_LIST \
69 "org.freedesktop.systemd1.Socket\0"
70
9a60da28 71const char bus_socket_interface[] _introspect_("Socket") = BUS_SOCKET_INTERFACE;
4139c1b2 72
c4e2ceae
LP
73const char bus_socket_invalidating_properties[] =
74 "ExecStartPre\0"
75 "ExecStartPost\0"
76 "ExecStopPre\0"
77 "ExecStopPost\0"
78 "ControlPID\0"
79 "NAccepted\0"
34df5a34 80 "NConnections\0";
c4e2ceae 81
c0120d99
LP
82static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
83
5e8d1c9a 84DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
34df5a34 85
4139c1b2
LP
86 const BusProperty properties[] = {
87 BUS_UNIT_PROPERTIES,
4e1e43c8
LP
88 { "org.freedesktop.systemd1.Socket", "BindIPv6Only", bus_socket_append_bind_ipv6_only, "s", &u->socket.bind_ipv6_only },
89 { "org.freedesktop.systemd1.Socket", "Backlog", bus_property_append_unsigned, "u", &u->socket.backlog },
90 { "org.freedesktop.systemd1.Socket", "TimeoutUSec", bus_property_append_usec, "t", &u->socket.timeout_usec },
fe68089d
LP
91 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_START_PRE], "ExecStartPre"),
92 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_START_POST], "ExecStartPost"),
93 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_STOP_PRE], "ExecStopPre"),
94 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_STOP_POST], "ExecStopPost"),
4139c1b2 95 BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Socket", u->socket.exec_context),
4e1e43c8
LP
96 { "org.freedesktop.systemd1.Socket", "ControlPID", bus_property_append_pid, "u", &u->socket.control_pid },
97 { "org.freedesktop.systemd1.Socket", "BindToDevice", bus_property_append_string, "s", u->socket.bind_to_device },
98 { "org.freedesktop.systemd1.Socket", "DirectoryMode", bus_property_append_mode, "u", &u->socket.directory_mode },
99 { "org.freedesktop.systemd1.Socket", "SocketMode", bus_property_append_mode, "u", &u->socket.socket_mode },
100 { "org.freedesktop.systemd1.Socket", "Accept", bus_property_append_bool, "b", &u->socket.accept },
101 { "org.freedesktop.systemd1.Socket", "KeepAlive", bus_property_append_bool, "b", &u->socket.keep_alive },
102 { "org.freedesktop.systemd1.Socket", "Priority", bus_property_append_int, "i", &u->socket.priority },
103 { "org.freedesktop.systemd1.Socket", "ReceiveBuffer", bus_property_append_size, "t", &u->socket.receive_buffer },
104 { "org.freedesktop.systemd1.Socket", "SendBuffer", bus_property_append_size, "t", &u->socket.send_buffer },
105 { "org.freedesktop.systemd1.Socket", "IPTOS", bus_property_append_int, "i", &u->socket.ip_tos },
106 { "org.freedesktop.systemd1.Socket", "IPTTL", bus_property_append_int, "i", &u->socket.ip_ttl },
107 { "org.freedesktop.systemd1.Socket", "PipeSize", bus_property_append_size, "t", &u->socket.pipe_size },
108 { "org.freedesktop.systemd1.Socket", "FreeBind", bus_property_append_bool, "b", &u->socket.free_bind },
109 { "org.freedesktop.systemd1.Socket", "Mark", bus_property_append_int, "i", &u->socket.mark },
110 { "org.freedesktop.systemd1.Socket", "MaxConnections", bus_property_append_unsigned, "u", &u->socket.max_connections },
111 { "org.freedesktop.systemd1.Socket", "NConnections", bus_property_append_unsigned, "u", &u->socket.n_connections },
112 { "org.freedesktop.systemd1.Socket", "NAccepted", bus_property_append_unsigned, "u", &u->socket.n_accepted },
4139c1b2
LP
113 { NULL, NULL, NULL, NULL, NULL }
114 };
115
05feefe0 116 return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, INTERFACES_LIST, properties);
4139c1b2 117}