Add ExtraFileDescriptor property to StartTransientUnit dbus API
This adds the ExtraFileDescriptor property to StartTransient dbus API with format "a(hs)" - array of (file descriptor, name) pairs. The FD will be passed to the unit via sd_notify like Socket and OpenFile. systemctl show also shows ExtraFileDescriptorName for these transient units. We only show the name passed to dbus as the FD numbers will change once passed over the unix socket and are duplicated, so its confusing to display the numbers. We do not add this functionality for systemd-run or general systemd service units as it is not useful for general systemd services. Arguably, it could be useful for systemd-run in bash scripts but we prefer to be cautious and not expose the API yet. Fixes: #34396
This commit is contained in:
@@ -2017,6 +2017,21 @@ 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 (streq(name, "ExtraFileDescriptorNames")) {
|
||||
_cleanup_strv_free_ char **extra_fd_names = NULL;
|
||||
_cleanup_free_ char *joined = NULL;
|
||||
|
||||
r = sd_bus_message_read_strv(m, &extra_fd_names);
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
joined = strv_join(extra_fd_names, " ");
|
||||
if (!joined)
|
||||
return log_oom();
|
||||
|
||||
bus_print_property_value(name, expected_value, flags, joined);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user