diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-01-28 15:12:08 +0100 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-01-29 08:59:19 +0100 |
commit | 0a67965fa225b0360a3f5de594d0f22490d3eacc (patch) | |
tree | c718241ddfe240e09b401c73cb0f332a3af00ec6 /src/nspawn/nspawn-mount.c | |
parent | 2312fd17cc225a1bc52d469f21a4479b96f87d8f (diff) | |
download | systemd-0a67965fa225b0360a3f5de594d0f22490d3eacc.tar.gz |
nspawn: Make sure we create bind mount points as the correct UID/GID
When using --private-users, we have to create bind mount points as
the user that will become root in the user namespace, so let's take
that into account.
Diffstat (limited to 'src/nspawn/nspawn-mount.c')
-rw-r--r-- | src/nspawn/nspawn-mount.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index 9de20126f4..ee00362b54 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -794,7 +794,7 @@ static int mount_bind(const char *dest, CustomMount *m, uid_t uid_shift, uid_t u m->source, where); } else { /* Path doesn't exist yet? */ - r = mkdir_parents_label(where, 0755); + r = mkdir_parents_safe_label(dest, where, 0755, uid_shift, uid_shift, MKDIR_IGNORE_EXISTING); if (r < 0) return log_error_errno(r, "Failed to make parents of %s: %m", where); @@ -808,6 +808,9 @@ static int mount_bind(const char *dest, CustomMount *m, uid_t uid_shift, uid_t u r = touch(where); if (r < 0) return log_error_errno(r, "Failed to create mount point %s: %m", where); + + if (chown(where, uid_shift, uid_shift) < 0) + return log_error_errno(errno, "Failed to chown %s: %m", where); } r = mount_nofollow_verbose(LOG_ERR, m->source, where, NULL, mount_flags, mount_opts); |