nspawn: make sure idmapped logic works if DDI contains only /usr/ tree
If we have a DDI that contains only a /usr/ tree (and which is thus combined with a tmpfs for root on boot) we previously would try to apply idmapping to the tmpfs, but not the /usr/ mount. That's broken of course. Fix this by applying it to both trees.
This commit is contained in:
committed by
Luca Boccassi
parent
f456764cda
commit
dba4fa8910
@@ -828,7 +828,7 @@ static int mount_bind(const char *dest, CustomMount *m, uid_t uid_shift, uid_t u
|
||||
}
|
||||
|
||||
if (idmapping != REMOUNT_IDMAPPING_NONE) {
|
||||
r = remount_idmap(where, uid_shift, uid_range, source_st.st_uid, idmapping);
|
||||
r = remount_idmap(STRV_MAKE(where), uid_shift, uid_range, source_st.st_uid, idmapping);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to map ids for bind mount %s: %m", where);
|
||||
}
|
||||
|
||||
+16
-1
@@ -3828,8 +3828,23 @@ static int outer_child(
|
||||
if (arg_userns_mode != USER_NAMESPACE_NO &&
|
||||
IN_SET(arg_userns_ownership, USER_NAMESPACE_OWNERSHIP_MAP, USER_NAMESPACE_OWNERSHIP_AUTO) &&
|
||||
arg_uid_shift != 0) {
|
||||
_cleanup_free_ char *usr_subtree = NULL;
|
||||
char *dirs[3];
|
||||
size_t i = 0;
|
||||
|
||||
r = remount_idmap(directory, arg_uid_shift, arg_uid_range, UID_INVALID, REMOUNT_IDMAPPING_HOST_ROOT);
|
||||
dirs[i++] = (char*) directory;
|
||||
|
||||
if (dissected_image && dissected_image->partitions[PARTITION_USR].found) {
|
||||
usr_subtree = path_join(directory, "/usr");
|
||||
if (!usr_subtree)
|
||||
return log_oom();
|
||||
|
||||
dirs[i++] = usr_subtree;
|
||||
}
|
||||
|
||||
dirs[i] = NULL;
|
||||
|
||||
r = remount_idmap(dirs, arg_uid_shift, arg_uid_range, UID_INVALID, REMOUNT_IDMAPPING_HOST_ROOT);
|
||||
if (r == -EINVAL || ERRNO_IS_NEG_NOT_SUPPORTED(r)) {
|
||||
/* This might fail because the kernel or file system doesn't support idmapping. We
|
||||
* can't really distinguish this nicely, nor do we have any guarantees about the
|
||||
|
||||
Reference in New Issue
Block a user