systemd/backport-nspawn-fix-UID-map-string.patch
wangyuhang a4f95d3244 sync patch from systemd community
(cherry picked from commit 88369f234ec01b60fb047caf87b90ef10a92b0db)
2023-10-10 10:04:24 +08:00

37 lines
1.3 KiB
Diff

From 20037219b702dd34b9b34050bf64030d4f93db98 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Wed, 15 Jun 2022 22:32:40 +0900
Subject: [PATCH] nspawn: fix UID map string
We send/recv the set of payload uid, host uid, payload gid, host gid.
Hence, the index must be incremented with 4, instead of 2.
Fixes #23664.
(cherry picked from commit 05ab439a62de8bb47e4137d2a8a473a307ccfb33)
Conflict:NA
Reference:https://github.com/systemd/systemd-stable/commit/20037219b702dd34b9b34050bf64030d4f93db98
---
src/nspawn/nspawn.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index c5fd978395..4ce80bba70 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -4137,8 +4137,8 @@ static int make_uid_map_string(
* quadruplet, consisting of host and container UID + GID. */
for (size_t i = 0; i < n_bind_user_uid; i++) {
- uid_t payload_uid = bind_user_uid[i*2+offset],
- host_uid = bind_user_uid[i*2+offset+1];
+ uid_t payload_uid = bind_user_uid[i*4+offset],
+ host_uid = bind_user_uid[i*4+offset+1];
assert(previous_uid <= payload_uid);
assert(payload_uid < arg_uid_range);
--
2.33.0