LCOV - code coverage report
Current view: top level - core - dbus-socket.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 0 235 0.0 %
Date: 2019-08-23 13:36:53 Functions: 0 17 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 307 0.0 %

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

Generated by: LCOV version 1.14