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:
@@ -3912,7 +3912,7 @@ static int exec_context_named_iofds(
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
stdio_fdname[i] = exec_context_fdname(c, i);
|
||||
|
||||
n_fds = p->n_storage_fds + p->n_socket_fds;
|
||||
n_fds = p->n_storage_fds + p->n_socket_fds + p->n_extra_fds;
|
||||
|
||||
for (size_t i = 0; i < n_fds && targets > 0; i++)
|
||||
if (named_iofds[STDIN_FILENO] < 0 &&
|
||||
@@ -4096,7 +4096,7 @@ int exec_invoke(
|
||||
int ngids_after_pam = 0;
|
||||
|
||||
int socket_fd = -EBADF, named_iofds[3] = EBADF_TRIPLET;
|
||||
size_t n_storage_fds, n_socket_fds;
|
||||
size_t n_storage_fds, n_socket_fds, n_extra_fds;
|
||||
|
||||
assert(command);
|
||||
assert(context);
|
||||
@@ -4133,12 +4133,13 @@ int exec_invoke(
|
||||
return log_exec_error_errno(context, params, SYNTHETIC_ERRNO(EINVAL), "Got no socket.");
|
||||
|
||||
socket_fd = params->fds[0];
|
||||
n_storage_fds = n_socket_fds = 0;
|
||||
n_storage_fds = n_socket_fds = n_extra_fds = 0;
|
||||
} else {
|
||||
n_socket_fds = params->n_socket_fds;
|
||||
n_storage_fds = params->n_storage_fds;
|
||||
n_extra_fds = params->n_extra_fds;
|
||||
}
|
||||
n_fds = n_socket_fds + n_storage_fds;
|
||||
n_fds = n_socket_fds + n_storage_fds + n_extra_fds;
|
||||
|
||||
r = exec_context_named_iofds(context, params, named_iofds);
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user