mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
nspawn: add new common make_run_host() helper
This new helper creates the /run/host/ top-level dir inside the container.
This commit is contained in:
@@ -388,9 +388,9 @@ int bind_user_setup(
|
||||
if (!c || c->n_data == 0)
|
||||
return 0;
|
||||
|
||||
r = userns_mkdir(root, "/run/host", 0755, 0, 0);
|
||||
r = make_run_host(root);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create /run/host: %m");
|
||||
return r;
|
||||
|
||||
r = userns_mkdir(root, "/run/host/home", 0755, 0, 0);
|
||||
if (r < 0)
|
||||
|
||||
@@ -2364,6 +2364,18 @@ static int setup_keyring(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int make_run_host(const char *root) {
|
||||
int r;
|
||||
|
||||
assert(root);
|
||||
|
||||
r = userns_mkdir(root, "/run/host", 0755, 0, 0);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create /run/host/: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setup_credentials(const char *root) {
|
||||
const char *q;
|
||||
int r;
|
||||
@@ -2371,9 +2383,9 @@ static int setup_credentials(const char *root) {
|
||||
if (arg_credentials.n_credentials == 0)
|
||||
return 0;
|
||||
|
||||
r = userns_mkdir(root, "/run/host", 0755, 0, 0);
|
||||
r = make_run_host(root);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create /run/host: %m");
|
||||
return r;
|
||||
|
||||
r = userns_mkdir(root, "/run/host/credentials", 0700, 0, 0);
|
||||
if (r < 0)
|
||||
@@ -2713,9 +2725,9 @@ static int mount_tunnel_dig(const char *root) {
|
||||
p = strjoina("/run/systemd/nspawn/propagate/", arg_machine);
|
||||
(void) mkdir_p(p, 0600);
|
||||
|
||||
r = userns_mkdir(root, "/run/host", 0755, 0, 0);
|
||||
r = make_run_host(root);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create /run/host: %m");
|
||||
return r;
|
||||
|
||||
r = userns_mkdir(root, NSPAWN_MOUNT_TUNNEL, 0600, 0, 0);
|
||||
if (r < 0)
|
||||
|
||||
@@ -5,3 +5,4 @@
|
||||
|
||||
int userns_lchown(const char *p, uid_t uid, gid_t gid);
|
||||
int userns_mkdir(const char *root, const char *path, mode_t mode, uid_t uid, gid_t gid);
|
||||
int make_run_host(const char *root);
|
||||
|
||||
Reference in New Issue
Block a user