]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: show SocketBind{Allow|Deny} properties
authorJulia Kartseva <hex@fb.com>
Tue, 20 Apr 2021 23:33:29 +0000 (16:33 -0700)
committerJulia Kartseva <hex@fb.com>
Mon, 26 Apr 2021 23:26:28 +0000 (16:26 -0700)
src/systemctl/systemctl-show.c

index 1a0bd35617da14f80004b7c02cb1b86fdc799dff..6d01a6be86e15a0ed1bc51fe22062444c42a3d85 100644 (file)
@@ -1710,6 +1710,34 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
                         if (r < 0)
                                 return bus_log_parse_error(r);
 
+                        return 1;
+                } else if (STR_IN_SET(name, "SocketBindAllow", "SocketBindDeny")) {
+                        uint16_t nr_ports, port_min;
+                        const char *family;
+                        int af;
+
+                        r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "(iqq)");
+                        if (r < 0)
+                                return bus_log_parse_error(r);
+                        while ((r = sd_bus_message_read(m, "(iqq)", &af, &nr_ports, &port_min)) > 0) {
+                                family = af == AF_INET ? "IPv4:" : af == AF_INET6 ? "IPv6:" : "";
+                                if (nr_ports == 0)
+                                        bus_print_property_valuef(name, expected_value, value, "%sany", family);
+                                else if (nr_ports == 1)
+                                        bus_print_property_valuef(
+                                                        name, expected_value, value, "%s%hu", family, port_min);
+                                else
+                                        bus_print_property_valuef(
+                                                        name, expected_value, value, "%s%hu-%hu", family, port_min,
+                                                        (uint16_t) (port_min + nr_ports - 1));
+                        }
+                        if (r < 0)
+                                return bus_log_parse_error(r);
+
+                        r = sd_bus_message_exit_container(m);
+                        if (r < 0)
+                                return bus_log_parse_error(r);
+
                         return 1;
                 }