core: Add RootDirectoryFileDescriptor=
RootDirectory= but via a open_tree() file descriptor. This allows setting up the execution environment for a service by the client in a mount namespace and then starting a transient unit in that execution environment using the new property. We also add --root-directory= and --same-root-dir= to systemd-run to have it run services within the given root directory. As systemd-run might be invoked from a different mount namespace than what systemd is running in, systemd-run opens the given path with open_tree() and then sends it to systemd using the new RootDirectoryFileDescriptor= property.
This commit is contained in:
@@ -218,6 +218,7 @@ typedef struct ExecContext {
|
||||
/* At least one of stdin/stdout/stderr was initialized from an fd passed in. This boolean survives
|
||||
* the fds being closed. This only makes sense for transient units. */
|
||||
bool stdio_as_fds;
|
||||
bool root_directory_as_fd;
|
||||
|
||||
char *stdio_fdname[3];
|
||||
char *stdio_file[3];
|
||||
@@ -418,6 +419,7 @@ typedef struct ExecParameters {
|
||||
int stdin_fd;
|
||||
int stdout_fd;
|
||||
int stderr_fd;
|
||||
int root_directory_fd;
|
||||
|
||||
/* An fd that is closed by the execve(), and thus will result in EOF when the execve() is done. */
|
||||
int exec_fd;
|
||||
@@ -449,6 +451,7 @@ typedef struct ExecParameters {
|
||||
.stdin_fd = -EBADF, \
|
||||
.stdout_fd = -EBADF, \
|
||||
.stderr_fd = -EBADF, \
|
||||
.root_directory_fd = -EBADF, \
|
||||
.exec_fd = -EBADF, \
|
||||
.bpf_restrict_fs_map_fd = -EBADF, \
|
||||
.user_lookup_fd = -EBADF, \
|
||||
|
||||
Reference in New Issue
Block a user