| File: | build-scan/../src/core/dbus-socket.c |
| Warning: | line 368, column 40 Potential leak of memory pointed to by 'p' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ | |||
| 2 | ||||
| 3 | #include "alloc-util.h" | |||
| 4 | #include "bus-util.h" | |||
| 5 | #include "dbus-cgroup.h" | |||
| 6 | #include "dbus-execute.h" | |||
| 7 | #include "dbus-kill.h" | |||
| 8 | #include "dbus-socket.h" | |||
| 9 | #include "dbus-util.h" | |||
| 10 | #include "fd-util.h" | |||
| 11 | #include "parse-util.h" | |||
| 12 | #include "path-util.h" | |||
| 13 | #include "socket.h" | |||
| 14 | #include "socket-protocol-list.h" | |||
| 15 | #include "socket-util.h" | |||
| 16 | #include "string-util.h" | |||
| 17 | #include "unit.h" | |||
| 18 | ||||
| 19 | static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, socket_result, SocketResult)int property_get_result(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { SocketResult *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-socket.c", 19, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(reply)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-socket.c", 19, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/dbus-socket.c", 19 , __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append (reply, "s", socket_result_to_string((*(data)))); }; | |||
| 20 | static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only)int property_get_bind_ipv6_only(sd_bus *bus, const char *path , const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { SocketAddressBindIPv6Only *data = userdata; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-socket.c" , 20, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(reply)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-socket.c", 20, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/dbus-socket.c", 20 , __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append (reply, "s", socket_address_bind_ipv6_only_to_string((*(data) ))); }; | |||
| 21 | static BUS_DEFINE_PROPERTY_GET(property_get_fdname, "s", Socket, socket_fdname)int property_get_fdname(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { Socket *data = userdata; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-socket.c", 21, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(reply)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-socket.c", 21, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/dbus-socket.c", 21 , __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append (reply, "s", (socket_fdname(data))); }; | |||
| 22 | ||||
| 23 | static int property_get_listen( | |||
| 24 | sd_bus *bus, | |||
| 25 | const char *path, | |||
| 26 | const char *interface, | |||
| 27 | const char *property, | |||
| 28 | sd_bus_message *reply, | |||
| 29 | void *userdata, | |||
| 30 | sd_bus_error *error) { | |||
| 31 | ||||
| 32 | Socket *s = SOCKET(userdata); | |||
| 33 | SocketPort *p; | |||
| 34 | int r; | |||
| 35 | ||||
| 36 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-socket.c", 36, __PRETTY_FUNCTION__); } while (0); | |||
| 37 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-socket.c", 37 , __PRETTY_FUNCTION__); } while (0); | |||
| 38 | assert(s)do { if ((__builtin_expect(!!(!(s)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("s"), "../src/core/dbus-socket.c", 38, __PRETTY_FUNCTION__ ); } while (0); | |||
| 39 | ||||
| 40 | r = sd_bus_message_open_container(reply, 'a', "(ss)"); | |||
| 41 | if (r < 0) | |||
| 42 | return r; | |||
| 43 | ||||
| 44 | LIST_FOREACH(port, p, s->ports)for ((p) = (s->ports); (p); (p) = (p)->port_next) { | |||
| 45 | _cleanup_free___attribute__((cleanup(freep))) char *address = NULL((void*)0); | |||
| 46 | const char *a; | |||
| 47 | ||||
| 48 | switch (p->type) { | |||
| 49 | case SOCKET_SOCKET: { | |||
| 50 | r = socket_address_print(&p->address, &address); | |||
| 51 | if (r) | |||
| 52 | return r; | |||
| 53 | ||||
| 54 | a = address; | |||
| 55 | break; | |||
| 56 | } | |||
| 57 | ||||
| 58 | case SOCKET_SPECIAL: | |||
| 59 | case SOCKET_MQUEUE: | |||
| 60 | case SOCKET_FIFO: | |||
| 61 | case SOCKET_USB_FUNCTION: | |||
| 62 | a = p->path; | |||
| 63 | break; | |||
| 64 | ||||
| 65 | default: | |||
| 66 | assert_not_reached("Unknown socket type")do { log_assert_failed_unreachable_realm(LOG_REALM_SYSTEMD, ( "Unknown socket type"), "../src/core/dbus-socket.c", 66, __PRETTY_FUNCTION__ ); } while (0); | |||
| 67 | } | |||
| 68 | ||||
| 69 | r = sd_bus_message_append(reply, "(ss)", socket_port_type_to_string(p), a); | |||
| 70 | if (r < 0) | |||
| 71 | return r; | |||
| 72 | } | |||
| 73 | ||||
| 74 | return sd_bus_message_close_container(reply); | |||
| 75 | } | |||
| 76 | ||||
| 77 | const sd_bus_vtable bus_socket_vtable[] = { | |||
| 78 | SD_BUS_VTABLE_START(0){ .type = _SD_BUS_VTABLE_START, .flags = 0, .x = { .start = { .element_size = sizeof(sd_bus_vtable) }, }, }, | |||
| 79 | SD_BUS_PROPERTY("BindIPv6Only", "s", property_get_bind_ipv6_only, offsetof(Socket, bind_ipv6_only), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "BindIPv6Only", .signature = "s", .get = property_get_bind_ipv6_only, .set = ((void*)0), . offset = __builtin_offsetof(Socket, bind_ipv6_only), }, }, }, | |||
| 80 | SD_BUS_PROPERTY("Backlog", "u", bus_property_get_unsigned, offsetof(Socket, backlog), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Backlog", .signature = "u", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*) 0), .offset = __builtin_offsetof(Socket, backlog), }, }, }, | |||
| 81 | SD_BUS_PROPERTY("TimeoutUSec", "t", bus_property_get_usec, offsetof(Socket, timeout_usec), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "TimeoutUSec", .signature = "t" , .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void* )0), .offset = __builtin_offsetof(Socket, timeout_usec), }, } , }, | |||
| 82 | SD_BUS_PROPERTY("BindToDevice", "s", NULL, offsetof(Socket, bind_to_device), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "BindToDevice", .signature = "s", .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Socket, bind_to_device), }, }, }, | |||
| 83 | SD_BUS_PROPERTY("SocketUser", "s", NULL, offsetof(Socket, user), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "SocketUser", .signature = "s" , .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Socket, user), }, }, }, | |||
| 84 | SD_BUS_PROPERTY("SocketGroup", "s", NULL, offsetof(Socket, group), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "SocketGroup", .signature = "s" , .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Socket, group), }, }, }, | |||
| 85 | SD_BUS_PROPERTY("SocketMode", "u", bus_property_get_mode, offsetof(Socket, socket_mode), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "SocketMode", .signature = "u" , .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void* )0), .offset = __builtin_offsetof(Socket, socket_mode), }, }, }, | |||
| 86 | SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Socket, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "DirectoryMode", .signature = "u", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void *)0), .offset = __builtin_offsetof(Socket, directory_mode), } , }, }, | |||
| 87 | SD_BUS_PROPERTY("Accept", "b", bus_property_get_bool, offsetof(Socket, accept), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Accept", .signature = "b", . get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof (Socket, accept), }, }, }, | |||
| 88 | SD_BUS_PROPERTY("FlushPending", "b", bus_property_get_bool, offsetof(Socket, flush_pending), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "FlushPending", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Socket, flush_pending), }, }, }, | |||
| 89 | SD_BUS_PROPERTY("Writable", "b", bus_property_get_bool, offsetof(Socket, writable), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Writable", .signature = "b" , .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof (Socket, writable), }, }, }, | |||
| 90 | SD_BUS_PROPERTY("KeepAlive", "b", bus_property_get_bool, offsetof(Socket, keep_alive), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "KeepAlive", .signature = "b" , .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof (Socket, keep_alive), }, }, }, | |||
| 91 | SD_BUS_PROPERTY("KeepAliveTimeUSec", "t", bus_property_get_usec, offsetof(Socket, keep_alive_time), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "KeepAliveTimeUSec", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Socket, keep_alive_time ), }, }, }, | |||
| 92 | SD_BUS_PROPERTY("KeepAliveIntervalUSec", "t", bus_property_get_usec, offsetof(Socket, keep_alive_interval), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "KeepAliveIntervalUSec", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Socket, keep_alive_interval ), }, }, }, | |||
| 93 | SD_BUS_PROPERTY("KeepAliveProbes", "u", bus_property_get_unsigned, offsetof(Socket, keep_alive_cnt), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "KeepAliveProbes", .signature = "u", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Socket, keep_alive_cnt ), }, }, }, | |||
| 94 | SD_BUS_PROPERTY("DeferAcceptUSec" , "t", bus_property_get_usec, offsetof(Socket, defer_accept), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "DeferAcceptUSec", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Socket, defer_accept) , }, }, }, | |||
| 95 | SD_BUS_PROPERTY("NoDelay", "b", bus_property_get_bool, offsetof(Socket, no_delay), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "NoDelay", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof (Socket, no_delay), }, }, }, | |||
| 96 | SD_BUS_PROPERTY("Priority", "i", bus_property_get_int, offsetof(Socket, priority), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Priority", .signature = "i" , .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void* )0), .offset = __builtin_offsetof(Socket, priority), }, }, }, | |||
| 97 | SD_BUS_PROPERTY("ReceiveBuffer", "t", bus_property_get_size, offsetof(Socket, receive_buffer), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "ReceiveBuffer", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void *)0), .offset = __builtin_offsetof(Socket, receive_buffer), } , }, }, | |||
| 98 | SD_BUS_PROPERTY("SendBuffer", "t", bus_property_get_size, offsetof(Socket, send_buffer), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "SendBuffer", .signature = "t" , .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void* )0), .offset = __builtin_offsetof(Socket, send_buffer), }, }, }, | |||
| 99 | SD_BUS_PROPERTY("IPTOS", "i", bus_property_get_int, offsetof(Socket, ip_tos), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "IPTOS", .signature = "i", . get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*)0) , .offset = __builtin_offsetof(Socket, ip_tos), }, }, }, | |||
| 100 | SD_BUS_PROPERTY("IPTTL", "i", bus_property_get_int, offsetof(Socket, ip_ttl), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "IPTTL", .signature = "i", . get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*)0) , .offset = __builtin_offsetof(Socket, ip_ttl), }, }, }, | |||
| 101 | SD_BUS_PROPERTY("PipeSize", "t", bus_property_get_size, offsetof(Socket, pipe_size), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "PipeSize", .signature = "t" , .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void* )0), .offset = __builtin_offsetof(Socket, pipe_size), }, }, }, | |||
| 102 | SD_BUS_PROPERTY("FreeBind", "b", bus_property_get_bool, offsetof(Socket, free_bind), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "FreeBind", .signature = "b" , .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof (Socket, free_bind), }, }, }, | |||
| 103 | SD_BUS_PROPERTY("Transparent", "b", bus_property_get_bool, offsetof(Socket, transparent), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Transparent", .signature = "b" , .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof (Socket, transparent), }, }, }, | |||
| 104 | SD_BUS_PROPERTY("Broadcast", "b", bus_property_get_bool, offsetof(Socket, broadcast), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Broadcast", .signature = "b" , .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof (Socket, broadcast), }, }, }, | |||
| 105 | SD_BUS_PROPERTY("PassCredentials", "b", bus_property_get_bool, offsetof(Socket, pass_cred), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "PassCredentials", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Socket, pass_cred), }, }, }, | |||
| 106 | SD_BUS_PROPERTY("PassSecurity", "b", bus_property_get_bool, offsetof(Socket, pass_sec), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "PassSecurity", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Socket, pass_sec), }, }, }, | |||
| 107 | SD_BUS_PROPERTY("PassPacketInfo", "b", bus_property_get_bool, offsetof(Socket, pass_pktinfo), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "PassPacketInfo", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Socket, pass_pktinfo), }, }, }, | |||
| 108 | SD_BUS_PROPERTY("RemoveOnStop", "b", bus_property_get_bool, offsetof(Socket, remove_on_stop), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "RemoveOnStop", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Socket, remove_on_stop), }, }, }, | |||
| 109 | SD_BUS_PROPERTY("Listen", "a(ss)", property_get_listen, 0, SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Listen", .signature = "a(ss)" , .get = property_get_listen, .set = ((void*)0), .offset = 0, }, }, }, | |||
| 110 | SD_BUS_PROPERTY("Symlinks", "as", NULL, offsetof(Socket, symlinks), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Symlinks", .signature = "as" , .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Socket, symlinks), }, }, }, | |||
| 111 | SD_BUS_PROPERTY("Mark", "i", bus_property_get_int, offsetof(Socket, mark), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Mark", .signature = "i", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*)0), . offset = __builtin_offsetof(Socket, mark), }, }, }, | |||
| 112 | SD_BUS_PROPERTY("MaxConnections", "u", bus_property_get_unsigned, offsetof(Socket, max_connections), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "MaxConnections", .signature = "u", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Socket, max_connections ), }, }, }, | |||
| 113 | SD_BUS_PROPERTY("MaxConnectionsPerSource", "u", bus_property_get_unsigned, offsetof(Socket, max_connections_per_source), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "MaxConnectionsPerSource", . signature = "u", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*)0), .offset = __builtin_offsetof(Socket, max_connections_per_source ), }, }, }, | |||
| 114 | SD_BUS_PROPERTY("MessageQueueMaxMessages", "x", bus_property_get_long, offsetof(Socket, mq_maxmsg), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "MessageQueueMaxMessages", . signature = "x", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*)0), .offset = __builtin_offsetof(Socket, mq_maxmsg ), }, }, }, | |||
| 115 | SD_BUS_PROPERTY("MessageQueueMessageSize", "x", bus_property_get_long, offsetof(Socket, mq_msgsize), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "MessageQueueMessageSize", . signature = "x", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*)0), .offset = __builtin_offsetof(Socket, mq_msgsize ), }, }, }, | |||
| 116 | SD_BUS_PROPERTY("TCPCongestion", "s", NULL, offsetof(Socket, tcp_congestion), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "TCPCongestion", .signature = "s", .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Socket, tcp_congestion), }, }, }, | |||
| 117 | SD_BUS_PROPERTY("ReusePort", "b", bus_property_get_bool, offsetof(Socket, reuse_port), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "ReusePort", .signature = "b" , .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof (Socket, reuse_port), }, }, }, | |||
| 118 | SD_BUS_PROPERTY("SmackLabel", "s", NULL, offsetof(Socket, smack), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "SmackLabel", .signature = "s" , .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Socket, smack), }, }, }, | |||
| 119 | SD_BUS_PROPERTY("SmackLabelIPIn", "s", NULL, offsetof(Socket, smack_ip_in), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "SmackLabelIPIn", .signature = "s", .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Socket, smack_ip_in), }, }, }, | |||
| 120 | SD_BUS_PROPERTY("SmackLabelIPOut", "s", NULL, offsetof(Socket, smack_ip_out), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "SmackLabelIPOut", .signature = "s", .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Socket, smack_ip_out), }, }, }, | |||
| 121 | SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Socket, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE , .x = { .property = { .member = "ControlPID", .signature = "u" , .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void* )0), .offset = __builtin_offsetof(Socket, control_pid), }, }, }, | |||
| 122 | SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Socket, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE , .x = { .property = { .member = "Result", .signature = "s", . get = property_get_result, .set = ((void*)0), .offset = __builtin_offsetof (Socket, result), }, }, }, | |||
| 123 | SD_BUS_PROPERTY("NConnections", "u", bus_property_get_unsigned, offsetof(Socket, n_connections), 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "NConnections", .signature = "u", .get = ((sd_bus_property_get_t ) ((void*)0)), .set = ((void*)0), .offset = __builtin_offsetof (Socket, n_connections), }, }, }, | |||
| 124 | SD_BUS_PROPERTY("NAccepted", "u", bus_property_get_unsigned, offsetof(Socket, n_accepted), 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "NAccepted", .signature = "u", .get = ((sd_bus_property_get_t ) ((void*)0)), .set = ((void*)0), .offset = __builtin_offsetof (Socket, n_accepted), }, }, }, | |||
| 125 | SD_BUS_PROPERTY("NRefused", "u", bus_property_get_unsigned, offsetof(Socket, n_refused), 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "NRefused", .signature = "u", .get = ((sd_bus_property_get_t ) ((void*)0)), .set = ((void*)0), .offset = __builtin_offsetof (Socket, n_refused), }, }, }, | |||
| 126 | SD_BUS_PROPERTY("FileDescriptorName", "s", property_get_fdname, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "FileDescriptorName", .signature = "s", .get = property_get_fdname, .set = ((void*)0), .offset = 0, }, }, }, | |||
| 127 | SD_BUS_PROPERTY("SocketProtocol", "i", bus_property_get_int, offsetof(Socket, socket_protocol), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "SocketProtocol", .signature = "i", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Socket, socket_protocol ), }, }, }, | |||
| 128 | SD_BUS_PROPERTY("TriggerLimitIntervalUSec", "t", bus_property_get_usec, offsetof(Socket, trigger_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "TriggerLimitIntervalUSec", . signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*)0), .offset = __builtin_offsetof(Socket, trigger_limit .interval), }, }, }, | |||
| 129 | SD_BUS_PROPERTY("TriggerLimitBurst", "u", bus_property_get_unsigned, offsetof(Socket, trigger_limit.burst), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "TriggerLimitBurst", .signature = "u", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Socket, trigger_limit .burst), }, }, }, | |||
| 130 | SD_BUS_PROPERTY("UID", "u", bus_property_get_uid, offsetof(Unit, ref_uid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE , .x = { .property = { .member = "UID", .signature = "u", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*)0), . offset = __builtin_offsetof(Unit, ref_uid), }, }, }, | |||
| 131 | SD_BUS_PROPERTY("GID", "u", bus_property_get_gid, offsetof(Unit, ref_gid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE , .x = { .property = { .member = "GID", .signature = "u", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*)0), . offset = __builtin_offsetof(Unit, ref_gid), }, }, }, | |||
| 132 | BUS_EXEC_COMMAND_LIST_VTABLE("ExecStartPre", offsetof(Socket, exec_command[SOCKET_EXEC_START_PRE]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION , .x = { .property = { .member = "ExecStartPre", .signature = "a(sasbttttuii)", .get = bus_property_get_exec_command_list, .set = ((void*)0), .offset = __builtin_offsetof(Socket, exec_command [SOCKET_EXEC_START_PRE]), }, }, }, | |||
| 133 | BUS_EXEC_COMMAND_LIST_VTABLE("ExecStartPost", offsetof(Socket, exec_command[SOCKET_EXEC_START_POST]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION , .x = { .property = { .member = "ExecStartPost", .signature = "a(sasbttttuii)", .get = bus_property_get_exec_command_list, .set = ((void*)0), .offset = __builtin_offsetof(Socket, exec_command [SOCKET_EXEC_START_POST]), }, }, }, | |||
| 134 | BUS_EXEC_COMMAND_LIST_VTABLE("ExecStopPre", offsetof(Socket, exec_command[SOCKET_EXEC_STOP_PRE]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION , .x = { .property = { .member = "ExecStopPre", .signature = "a(sasbttttuii)" , .get = bus_property_get_exec_command_list, .set = ((void*)0 ), .offset = __builtin_offsetof(Socket, exec_command[SOCKET_EXEC_STOP_PRE ]), }, }, }, | |||
| 135 | BUS_EXEC_COMMAND_LIST_VTABLE("ExecStopPost", offsetof(Socket, exec_command[SOCKET_EXEC_STOP_POST]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION , .x = { .property = { .member = "ExecStopPost", .signature = "a(sasbttttuii)", .get = bus_property_get_exec_command_list, .set = ((void*)0), .offset = __builtin_offsetof(Socket, exec_command [SOCKET_EXEC_STOP_POST]), }, }, }, | |||
| 136 | SD_BUS_VTABLE_END{ .type = _SD_BUS_VTABLE_END, .flags = 0, .x = { { 0 } }, } | |||
| 137 | }; | |||
| 138 | ||||
| 139 | static inline bool_Bool check_size_t_truncation(uint64_t t) { | |||
| 140 | return (size_t) t == t; | |||
| 141 | } | |||
| 142 | ||||
| 143 | static inline const char* supported_socket_protocol_to_string(int32_t i) { | |||
| 144 | if (i == IPPROTO_IPIPPROTO_IP) | |||
| 145 | return ""; | |||
| 146 | ||||
| 147 | if (!IN_SET(i, IPPROTO_UDPLITE, IPPROTO_SCTP)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){IPPROTO_UDPLITE, IPPROTO_SCTP})/sizeof(int )]; switch(i) { case IPPROTO_UDPLITE: case IPPROTO_SCTP: _found = 1; break; default: break; } _found; })) | |||
| 148 | return NULL((void*)0); | |||
| 149 | ||||
| 150 | return socket_protocol_to_name(i); | |||
| 151 | } | |||
| 152 | ||||
| 153 | static BUS_DEFINE_SET_TRANSIENT(int, "i", int32_t, int, "%" PRIi32)int bus_set_transient_int( Unit *u, const char *name, int *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error * error) { int32_t v; int r; do { if ((__builtin_expect(!!(!(p) ),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("p"), "../src/core/dbus-socket.c" , 153, __PRETTY_FUNCTION__); } while (0); r = sd_bus_message_read (message, "i", &v); if (r < 0) return r; if (!(((flags ) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { *p = (int) v ; unit_write_settingf(u, flags, name, "%s=" "%" "i", name, v) ; } return 1; }; | |||
| 154 | static BUS_DEFINE_SET_TRANSIENT(message_queue, "x", int64_t, long, "%" PRIi64)int bus_set_transient_message_queue( Unit *u, const char *name , long *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { int64_t v; int r; do { if ((__builtin_expect(!!(!( p)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("p"), "../src/core/dbus-socket.c" , 154, __PRETTY_FUNCTION__); } while (0); r = sd_bus_message_read (message, "x", &v); if (r < 0) return r; if (!(((flags ) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { *p = (long) v ; unit_write_settingf(u, flags, name, "%s=" "%" "l" "i", name , v); } return 1; }; | |||
| 155 | static BUS_DEFINE_SET_TRANSIENT_IS_VALID(size_t_check_truncation, "t", uint64_t, size_t, "%" PRIu64, check_size_t_truncation)int bus_set_transient_size_t_check_truncation( Unit *u, const char *name, size_t *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { uint64_t v; int r; do { if ((__builtin_expect (!!(!(p)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("p" ), "../src/core/dbus-socket.c", 155, __PRETTY_FUNCTION__); } while (0); r = sd_bus_message_read(message, "t", &v); if (r < 0) return r; if (!check_size_t_truncation(v)) return sd_bus_error_setf (error, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid %s setting: " "%" "l" "u", name, v); if (!(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT )) == 0)) { *p = (size_t) v; unit_write_settingf(u, flags, name , "%s=" "%" "l" "u", name, v); } return 1; }; | |||
| 156 | static BUS_DEFINE_SET_TRANSIENT_PARSE(bind_ipv6_only, SocketAddressBindIPv6Only, socket_address_bind_ipv6_only_or_bool_from_string)int bus_set_transient_bind_ipv6_only( Unit *u, const char *name , SocketAddressBindIPv6Only *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { const char *s; SocketAddressBindIPv6Only v; int r; do { if ((__builtin_expect(!!(!(p)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("p"), "../src/core/dbus-socket.c", 156, __PRETTY_FUNCTION__ ); } while (0); r = sd_bus_message_read(message, "s", &s) ; if (r < 0) return r; v = socket_address_bind_ipv6_only_or_bool_from_string (s); if (v < 0) return sd_bus_error_setf(error, "org.freedesktop.DBus.Error.InvalidArgs" , "Invalid %s setting: %s", name, s); if (!(((flags) & (UNIT_RUNTIME |UNIT_PERSISTENT)) == 0)) { *p = v; unit_write_settingf(u, flags , name, "%s=%s", name, s); } return 1; }; | |||
| 157 | static BUS_DEFINE_SET_TRANSIENT_STRING_WITH_CHECK(fdname, fdname_is_valid)int bus_set_transient_fdname( Unit *u, const char *name, char **p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { const char *v; int r; do { if ((__builtin_expect(! !(!(p)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("p") , "../src/core/dbus-socket.c", 157, __PRETTY_FUNCTION__); } while (0); r = sd_bus_message_read(message, "s", &v); if (r < 0) return r; if (!isempty(v) && !fdname_is_valid(v)) return sd_bus_error_setf(error, "org.freedesktop.DBus.Error.InvalidArgs" , "Invalid %s setting: %s", name, v); if (!(((flags) & (UNIT_RUNTIME |UNIT_PERSISTENT)) == 0)) { r = free_and_strdup(p, empty_to_null (v)); if (r < 0) return r; unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS , name, "%s=%s", name, strempty(v)); } return 1; }; | |||
| 158 | static BUS_DEFINE_SET_TRANSIENT_STRING_WITH_CHECK(ifname, ifname_valid)int bus_set_transient_ifname( Unit *u, const char *name, char **p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { const char *v; int r; do { if ((__builtin_expect(! !(!(p)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("p") , "../src/core/dbus-socket.c", 158, __PRETTY_FUNCTION__); } while (0); r = sd_bus_message_read(message, "s", &v); if (r < 0) return r; if (!isempty(v) && !ifname_valid(v)) return sd_bus_error_setf(error, "org.freedesktop.DBus.Error.InvalidArgs" , "Invalid %s setting: %s", name, v); if (!(((flags) & (UNIT_RUNTIME |UNIT_PERSISTENT)) == 0)) { r = free_and_strdup(p, empty_to_null (v)); if (r < 0) return r; unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS , name, "%s=%s", name, strempty(v)); } return 1; }; | |||
| 159 | static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(ip_tos, "i", int32_t, int, "%" PRIi32, ip_tos_to_string_alloc)int bus_set_transient_ip_tos( Unit *u, const char *name, int * p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { __attribute__((cleanup(freep))) char *s = ((void*) 0); int32_t v; int r; do { if ((__builtin_expect(!!(!(p)),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("p"), "../src/core/dbus-socket.c" , 159, __PRETTY_FUNCTION__); } while (0); r = sd_bus_message_read (message, "i", &v); if (r < 0) return r; r = ip_tos_to_string_alloc (v, &s); if (r == -22) return sd_bus_error_setf(error, "org.freedesktop.DBus.Error.InvalidArgs" , "Invalid %s setting: " "%" "i", name, v); if (r < 0) return r; if (!(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0 )) { *p = (int) v; unit_write_settingf(u, flags, name, "%s=%s" , name, s); } return 1; }; | |||
| 160 | static BUS_DEFINE_SET_TRANSIENT_TO_STRING(socket_protocol, "i", int32_t, int, "%" PRIi32, supported_socket_protocol_to_string)int bus_set_transient_socket_protocol( Unit *u, const char *name , int *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { const char *s; int32_t v; int r; do { if ((__builtin_expect (!!(!(p)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("p" ), "../src/core/dbus-socket.c", 160, __PRETTY_FUNCTION__); } while (0); r = sd_bus_message_read(message, "i", &v); if (r < 0) return r; s = supported_socket_protocol_to_string(v); if ( !s) return sd_bus_error_setf(error, "org.freedesktop.DBus.Error.InvalidArgs" , "Invalid %s setting: " "%" "i", name, v); if (!(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { *p = (int) v; unit_write_settingf (u, flags, name, "%s=%s", name, s); } return 1; }; | |||
| 161 | ||||
| 162 | static int bus_socket_set_transient_property( | |||
| 163 | Socket *s, | |||
| 164 | const char *name, | |||
| 165 | sd_bus_message *message, | |||
| 166 | UnitWriteFlags flags, | |||
| 167 | sd_bus_error *error) { | |||
| 168 | ||||
| 169 | SocketExecCommand ci; | |||
| 170 | Unit *u = UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }); | |||
| ||||
| 171 | int r; | |||
| 172 | ||||
| 173 | assert(s)do { if ((__builtin_expect(!!(!(s)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("s"), "../src/core/dbus-socket.c", 173, __PRETTY_FUNCTION__ ); } while (0); | |||
| 174 | assert(name)do { if ((__builtin_expect(!!(!(name)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("name"), "../src/core/dbus-socket.c", 174 , __PRETTY_FUNCTION__); } while (0); | |||
| 175 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-socket.c", 175, __PRETTY_FUNCTION__); } while (0); | |||
| 176 | ||||
| 177 | flags |= UNIT_PRIVATE; | |||
| 178 | ||||
| 179 | if (streq(name, "Accept")(strcmp((name),("Accept")) == 0)) | |||
| 180 | return bus_set_transient_bool(u, name, &s->accept, message, flags, error); | |||
| 181 | ||||
| 182 | if (streq(name, "FlushPending")(strcmp((name),("FlushPending")) == 0)) | |||
| 183 | return bus_set_transient_bool(u, name, &s->flush_pending, message, flags, error); | |||
| 184 | ||||
| 185 | if (streq(name, "Writable")(strcmp((name),("Writable")) == 0)) | |||
| 186 | return bus_set_transient_bool(u, name, &s->writable, message, flags, error); | |||
| 187 | ||||
| 188 | if (streq(name, "KeepAlive")(strcmp((name),("KeepAlive")) == 0)) | |||
| 189 | return bus_set_transient_bool(u, name, &s->keep_alive, message, flags, error); | |||
| 190 | ||||
| 191 | if (streq(name, "NoDelay")(strcmp((name),("NoDelay")) == 0)) | |||
| 192 | return bus_set_transient_bool(u, name, &s->no_delay, message, flags, error); | |||
| 193 | ||||
| 194 | if (streq(name, "FreeBind")(strcmp((name),("FreeBind")) == 0)) | |||
| 195 | return bus_set_transient_bool(u, name, &s->free_bind, message, flags, error); | |||
| 196 | ||||
| 197 | if (streq(name, "Transparent")(strcmp((name),("Transparent")) == 0)) | |||
| 198 | return bus_set_transient_bool(u, name, &s->transparent, message, flags, error); | |||
| 199 | ||||
| 200 | if (streq(name, "Broadcast")(strcmp((name),("Broadcast")) == 0)) | |||
| 201 | return bus_set_transient_bool(u, name, &s->broadcast, message, flags, error); | |||
| 202 | ||||
| 203 | if (streq(name, "PassCredentials")(strcmp((name),("PassCredentials")) == 0)) | |||
| 204 | return bus_set_transient_bool(u, name, &s->pass_cred, message, flags, error); | |||
| 205 | ||||
| 206 | if (streq(name, "PassSecurity")(strcmp((name),("PassSecurity")) == 0)) | |||
| 207 | return bus_set_transient_bool(u, name, &s->pass_sec, message, flags, error); | |||
| 208 | ||||
| 209 | if (streq(name, "PassPacketInfo")(strcmp((name),("PassPacketInfo")) == 0)) | |||
| 210 | return bus_set_transient_bool(u, name, &s->pass_pktinfo, message, flags, error); | |||
| 211 | ||||
| 212 | if (streq(name, "ReusePort")(strcmp((name),("ReusePort")) == 0)) | |||
| 213 | return bus_set_transient_bool(u, name, &s->reuse_port, message, flags, error); | |||
| 214 | ||||
| 215 | if (streq(name, "RemoveOnStop")(strcmp((name),("RemoveOnStop")) == 0)) | |||
| 216 | return bus_set_transient_bool(u, name, &s->remove_on_stop, message, flags, error); | |||
| 217 | ||||
| 218 | if (streq(name, "SELinuxContextFromNet")(strcmp((name),("SELinuxContextFromNet")) == 0)) | |||
| 219 | return bus_set_transient_bool(u, name, &s->selinux_context_from_net, message, flags, error); | |||
| 220 | ||||
| 221 | if (streq(name, "Priority")(strcmp((name),("Priority")) == 0)) | |||
| 222 | return bus_set_transient_int(u, name, &s->priority, message, flags, error); | |||
| 223 | ||||
| 224 | if (streq(name, "IPTTL")(strcmp((name),("IPTTL")) == 0)) | |||
| 225 | return bus_set_transient_int(u, name, &s->ip_ttl, message, flags, error); | |||
| 226 | ||||
| 227 | if (streq(name, "Mark")(strcmp((name),("Mark")) == 0)) | |||
| 228 | return bus_set_transient_int(u, name, &s->mark, message, flags, error); | |||
| 229 | ||||
| 230 | if (streq(name, "Backlog")(strcmp((name),("Backlog")) == 0)) | |||
| 231 | return bus_set_transient_unsigned(u, name, &s->backlog, message, flags, error); | |||
| 232 | ||||
| 233 | if (streq(name, "MaxConnections")(strcmp((name),("MaxConnections")) == 0)) | |||
| 234 | return bus_set_transient_unsigned(u, name, &s->max_connections, message, flags, error); | |||
| 235 | ||||
| 236 | if (streq(name, "MaxConnectionsPerSource")(strcmp((name),("MaxConnectionsPerSource")) == 0)) | |||
| 237 | return bus_set_transient_unsigned(u, name, &s->max_connections_per_source, message, flags, error); | |||
| 238 | ||||
| 239 | if (streq(name, "KeepAliveProbes")(strcmp((name),("KeepAliveProbes")) == 0)) | |||
| 240 | return bus_set_transient_unsigned(u, name, &s->keep_alive_cnt, message, flags, error); | |||
| 241 | ||||
| 242 | if (streq(name, "TriggerLimitBurst")(strcmp((name),("TriggerLimitBurst")) == 0)) | |||
| 243 | return bus_set_transient_unsigned(u, name, &s->trigger_limit.burst, message, flags, error); | |||
| 244 | ||||
| 245 | if (streq(name, "SocketMode")(strcmp((name),("SocketMode")) == 0)) | |||
| 246 | return bus_set_transient_mode_t(u, name, &s->socket_mode, message, flags, error); | |||
| 247 | ||||
| 248 | if (streq(name, "DirectoryMode")(strcmp((name),("DirectoryMode")) == 0)) | |||
| 249 | return bus_set_transient_mode_t(u, name, &s->directory_mode, message, flags, error); | |||
| 250 | ||||
| 251 | if (streq(name, "MessageQueueMaxMessages")(strcmp((name),("MessageQueueMaxMessages")) == 0)) | |||
| 252 | return bus_set_transient_message_queue(u, name, &s->mq_maxmsg, message, flags, error); | |||
| 253 | ||||
| 254 | if (streq(name, "MessageQueueMessageSize")(strcmp((name),("MessageQueueMessageSize")) == 0)) | |||
| 255 | return bus_set_transient_message_queue(u, name, &s->mq_msgsize, message, flags, error); | |||
| 256 | ||||
| 257 | if (streq(name, "TimeoutUSec")(strcmp((name),("TimeoutUSec")) == 0)) | |||
| 258 | return bus_set_transient_usec_fix_0(u, name, &s->timeout_usec, message, flags, error); | |||
| 259 | ||||
| 260 | if (streq(name, "KeepAliveTimeUSec")(strcmp((name),("KeepAliveTimeUSec")) == 0)) | |||
| 261 | return bus_set_transient_usec(u, name, &s->keep_alive_time, message, flags, error); | |||
| 262 | ||||
| 263 | if (streq(name, "KeepAliveIntervalUSec")(strcmp((name),("KeepAliveIntervalUSec")) == 0)) | |||
| 264 | return bus_set_transient_usec(u, name, &s->keep_alive_interval, message, flags, error); | |||
| 265 | ||||
| 266 | if (streq(name, "DeferAcceptUSec")(strcmp((name),("DeferAcceptUSec")) == 0)) | |||
| 267 | return bus_set_transient_usec(u, name, &s->defer_accept, message, flags, error); | |||
| 268 | ||||
| 269 | if (streq(name, "TriggerLimitIntervalUSec")(strcmp((name),("TriggerLimitIntervalUSec")) == 0)) | |||
| 270 | return bus_set_transient_usec(u, name, &s->trigger_limit.interval, message, flags, error); | |||
| 271 | ||||
| 272 | if (streq(name, "SmackLabel")(strcmp((name),("SmackLabel")) == 0)) | |||
| 273 | return bus_set_transient_string(u, name, &s->smack, message, flags, error); | |||
| 274 | ||||
| 275 | if (streq(name, "SmackLabelIPin")(strcmp((name),("SmackLabelIPin")) == 0)) | |||
| 276 | return bus_set_transient_string(u, name, &s->smack_ip_in, message, flags, error); | |||
| 277 | ||||
| 278 | if (streq(name, "SmackLabelIPOut")(strcmp((name),("SmackLabelIPOut")) == 0)) | |||
| 279 | return bus_set_transient_string(u, name, &s->smack_ip_out, message, flags, error); | |||
| 280 | ||||
| 281 | if (streq(name, "TCPCongestion")(strcmp((name),("TCPCongestion")) == 0)) | |||
| 282 | return bus_set_transient_string(u, name, &s->tcp_congestion, message, flags, error); | |||
| 283 | ||||
| 284 | if (streq(name, "FileDescriptorName")(strcmp((name),("FileDescriptorName")) == 0)) | |||
| 285 | return bus_set_transient_fdname(u, name, &s->fdname, message, flags, error); | |||
| 286 | ||||
| 287 | if (streq(name, "SocketUser")(strcmp((name),("SocketUser")) == 0)) | |||
| 288 | return bus_set_transient_user_relaxed(u, name, &s->user, message, flags, error); | |||
| 289 | ||||
| 290 | if (streq(name, "SocketGroup")(strcmp((name),("SocketGroup")) == 0)) | |||
| 291 | return bus_set_transient_user_relaxed(u, name, &s->group, message, flags, error); | |||
| 292 | ||||
| 293 | if (streq(name, "BindIPv6Only")(strcmp((name),("BindIPv6Only")) == 0)) | |||
| 294 | return bus_set_transient_bind_ipv6_only(u, name, &s->bind_ipv6_only, message, flags, error); | |||
| 295 | ||||
| 296 | if (streq(name, "ReceiveBuffer")(strcmp((name),("ReceiveBuffer")) == 0)) | |||
| 297 | return bus_set_transient_size_t_check_truncation(u, name, &s->receive_buffer, message, flags, error); | |||
| 298 | ||||
| 299 | if (streq(name, "SendBuffer")(strcmp((name),("SendBuffer")) == 0)) | |||
| 300 | return bus_set_transient_size_t_check_truncation(u, name, &s->send_buffer, message, flags, error); | |||
| 301 | ||||
| 302 | if (streq(name, "PipeSize")(strcmp((name),("PipeSize")) == 0)) | |||
| 303 | return bus_set_transient_size_t_check_truncation(u, name, &s->pipe_size, message, flags, error); | |||
| 304 | ||||
| 305 | if (streq(name, "BindToDevice")(strcmp((name),("BindToDevice")) == 0)) | |||
| 306 | return bus_set_transient_ifname(u, name, &s->bind_to_device, message, flags, error); | |||
| 307 | ||||
| 308 | if (streq(name, "IPTOS")(strcmp((name),("IPTOS")) == 0)) | |||
| 309 | return bus_set_transient_ip_tos(u, name, &s->ip_tos, message, flags, error); | |||
| 310 | ||||
| 311 | if (streq(name, "SocketProtocol")(strcmp((name),("SocketProtocol")) == 0)) | |||
| 312 | return bus_set_transient_socket_protocol(u, name, &s->socket_protocol, message, flags, error); | |||
| 313 | ||||
| 314 | if ((ci = socket_exec_command_from_string(name)) >= 0) | |||
| 315 | return bus_set_transient_exec_command(u, name, &s->exec_command[ci], message, flags, error); | |||
| 316 | ||||
| 317 | if (streq(name, "Symlinks")(strcmp((name),("Symlinks")) == 0)) { | |||
| 318 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **l = NULL((void*)0); | |||
| 319 | char **p; | |||
| 320 | ||||
| 321 | r = sd_bus_message_read_strv(message, &l); | |||
| 322 | if (r < 0) | |||
| 323 | return r; | |||
| 324 | ||||
| 325 | STRV_FOREACH(p, l)for ((p) = (l); (p) && *(p); (p)++) { | |||
| 326 | if (!path_is_absolute(*p)) | |||
| 327 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Symlink path is not absolute: %s", *p); | |||
| 328 | } | |||
| 329 | ||||
| 330 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { | |||
| 331 | if (strv_isempty(l)) { | |||
| 332 | s->symlinks = strv_free(s->symlinks); | |||
| 333 | unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS, name, "%s=", name); | |||
| 334 | } else { | |||
| 335 | _cleanup_free___attribute__((cleanup(freep))) char *joined = NULL((void*)0); | |||
| 336 | ||||
| 337 | r = strv_extend_strv(&s->symlinks, l, true1); | |||
| 338 | if (r < 0) | |||
| 339 | return -ENOMEM12; | |||
| 340 | ||||
| 341 | joined = strv_join(l, " "); | |||
| 342 | if (!joined) | |||
| 343 | return -ENOMEM12; | |||
| 344 | ||||
| 345 | unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS, name, "%s=%s", name, joined); | |||
| 346 | } | |||
| 347 | } | |||
| 348 | ||||
| 349 | return 1; | |||
| 350 | ||||
| 351 | } else if (streq(name, "Listen")(strcmp((name),("Listen")) == 0)) { | |||
| 352 | const char *t, *a; | |||
| 353 | bool_Bool empty = true1; | |||
| 354 | ||||
| 355 | r = sd_bus_message_enter_container(message, 'a', "(ss)"); | |||
| 356 | if (r < 0) | |||
| 357 | return r; | |||
| 358 | ||||
| 359 | while ((r = sd_bus_message_read(message, "(ss)", &t, &a)) > 0) { | |||
| 360 | _cleanup_free___attribute__((cleanup(freep))) SocketPort *p = NULL((void*)0); | |||
| 361 | ||||
| 362 | p = new0(SocketPort, 1)((SocketPort*) calloc((1), sizeof(SocketPort))); | |||
| 363 | if (!p) | |||
| 364 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/dbus-socket.c" , 364, __func__); | |||
| 365 | ||||
| 366 | p->type = socket_port_type_from_string(t); | |||
| 367 | if (p->type < 0) | |||
| 368 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Unknown Socket type: %s", t); | |||
| ||||
| 369 | ||||
| 370 | if (p->type != SOCKET_SOCKET) { | |||
| 371 | p->path = strdup(a); | |||
| 372 | path_simplify(p->path, false0); | |||
| 373 | ||||
| 374 | } else if (streq(t, "Netlink")(strcmp((t),("Netlink")) == 0)) { | |||
| 375 | r = socket_address_parse_netlink(&p->address, a); | |||
| 376 | if (r < 0) | |||
| 377 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Invalid netlink address: %s", a); | |||
| 378 | ||||
| 379 | } else { | |||
| 380 | r = socket_address_parse(&p->address, a); | |||
| 381 | if (r < 0) | |||
| 382 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Invalid address: %s", a); | |||
| 383 | ||||
| 384 | p->address.type = socket_address_type_from_string(t); | |||
| 385 | if (p->address.type < 0) | |||
| 386 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Invalid address type: %s", t); | |||
| 387 | ||||
| 388 | if (socket_address_family(&p->address)((&p->address)->sockaddr.sa.sa_family) != AF_LOCAL1 && p->address.type == SOCK_SEQPACKETSOCK_SEQPACKET) | |||
| 389 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Address family not supported: %s", a); | |||
| 390 | } | |||
| 391 | ||||
| 392 | p->fd = -1; | |||
| 393 | p->auxiliary_fds = NULL((void*)0); | |||
| 394 | p->n_auxiliary_fds = 0; | |||
| 395 | p->socket = s; | |||
| 396 | ||||
| 397 | empty = false0; | |||
| 398 | ||||
| 399 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { | |||
| 400 | SocketPort *tail; | |||
| 401 | ||||
| 402 | LIST_FIND_TAIL(port, s->ports, tail)do { typeof(*(s->ports)) *_item = (s->ports); if (!_item ) (tail) = ((void*)0); else { while (_item->port_next) _item = _item->port_next; (tail) = _item; } } while (0); | |||
| 403 | LIST_INSERT_AFTER(port, s->ports, tail, p)do { typeof(*(s->ports)) **_head = &(s->ports), *_a = (tail), *_b = (p); do { if ((__builtin_expect(!!(!(_b)),0) )) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("_b"), "../src/core/dbus-socket.c" , 403, __PRETTY_FUNCTION__); } while (0); if (!_a) { if ((_b-> port_next = *_head)) _b->port_next->port_prev = _b; _b-> port_prev = ((void*)0); *_head = _b; } else { if ((_b->port_next = _a->port_next)) _b->port_next->port_prev = _b; _b ->port_prev = _a; _a->port_next = _b; } } while (0); | |||
| 404 | ||||
| 405 | p = NULL((void*)0); | |||
| 406 | ||||
| 407 | unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS, name, "Listen%s=%s", t, a); | |||
| 408 | } | |||
| 409 | } | |||
| 410 | if (r < 0) | |||
| 411 | return r; | |||
| 412 | ||||
| 413 | r = sd_bus_message_exit_container(message); | |||
| 414 | if (r < 0) | |||
| 415 | return r; | |||
| 416 | ||||
| 417 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0) && empty) { | |||
| 418 | socket_free_ports(s); | |||
| 419 | unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS, name, "ListenStream="); | |||
| 420 | } | |||
| 421 | ||||
| 422 | return 1; | |||
| 423 | } | |||
| 424 | ||||
| 425 | return 0; | |||
| 426 | } | |||
| 427 | ||||
| 428 | int bus_socket_set_property( | |||
| 429 | Unit *u, | |||
| 430 | const char *name, | |||
| 431 | sd_bus_message *message, | |||
| 432 | UnitWriteFlags flags, | |||
| 433 | sd_bus_error *error) { | |||
| 434 | ||||
| 435 | Socket *s = SOCKET(u); | |||
| 436 | int r; | |||
| 437 | ||||
| 438 | assert(s)do { if ((__builtin_expect(!!(!(s)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("s"), "../src/core/dbus-socket.c", 438, __PRETTY_FUNCTION__ ); } while (0); | |||
| 439 | assert(name)do { if ((__builtin_expect(!!(!(name)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("name"), "../src/core/dbus-socket.c", 439 , __PRETTY_FUNCTION__); } while (0); | |||
| 440 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-socket.c", 440, __PRETTY_FUNCTION__); } while (0); | |||
| 441 | ||||
| 442 | assert(s)do { if ((__builtin_expect(!!(!(s)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("s"), "../src/core/dbus-socket.c", 442, __PRETTY_FUNCTION__ ); } while (0); | |||
| 443 | assert(name)do { if ((__builtin_expect(!!(!(name)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("name"), "../src/core/dbus-socket.c", 443 , __PRETTY_FUNCTION__); } while (0); | |||
| 444 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-socket.c", 444, __PRETTY_FUNCTION__); } while (0); | |||
| 445 | ||||
| 446 | r = bus_cgroup_set_property(u, &s->cgroup_context, name, message, flags, error); | |||
| 447 | if (r != 0) | |||
| 448 | return r; | |||
| 449 | ||||
| 450 | if (u->transient && u->load_state == UNIT_STUB) { | |||
| 451 | /* This is a transient unit, let's load a little more */ | |||
| 452 | ||||
| 453 | r = bus_socket_set_transient_property(s, name, message, flags, error); | |||
| 454 | if (r != 0) | |||
| 455 | return r; | |||
| 456 | ||||
| 457 | r = bus_exec_context_set_transient_property(u, &s->exec_context, name, message, flags, error); | |||
| 458 | if (r != 0) | |||
| 459 | return r; | |||
| 460 | ||||
| 461 | r = bus_kill_context_set_transient_property(u, &s->kill_context, name, message, flags, error); | |||
| 462 | if (r != 0) | |||
| 463 | return r; | |||
| 464 | } | |||
| 465 | ||||
| 466 | return 0; | |||
| 467 | } | |||
| 468 | ||||
| 469 | int bus_socket_commit_properties(Unit *u) { | |||
| 470 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-socket.c", 470, __PRETTY_FUNCTION__ ); } while (0); | |||
| 471 | ||||
| 472 | unit_update_cgroup_members_masks(u); | |||
| 473 | unit_realize_cgroup(u); | |||
| 474 | ||||
| 475 | return 0; | |||
| 476 | } |