qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tests/docker: Specify --userns keep-id for Podman
@ 2024-06-26 11:09 Akihiko Odaki
  2024-06-26 16:16 ` Alex Bennée
  0 siblings, 1 reply; 2+ messages in thread
From: Akihiko Odaki @ 2024-06-26 11:09 UTC (permalink / raw)
  To: Alex Bennée, Philippe Mathieu-Daudé, Thomas Huth,
	Wainer dos Santos Moschetta, Beraldo Leal
  Cc: qemu-devel, Akihiko Odaki

Previously we are always specifying -u $(UID) to match the UID in the
container with one outside. This causes a problem with rootless Podman.

Rootless Podman remaps user IDs in the container to ones controllable
for the current user outside. The -u option instructs Podman to use
a specified UID in the container but does not affect the UID remapping.
Therefore, the UID in the container can be remapped to some other UID
outside the container. This can make the access to bind-mounted volumes
fail because the remapped UID mismatches with the owner of the
directories.

Replace -u $(UID) with --userns keep-id, which fixes the UID remapping.
This change is limited to Podman because Docker does not support
--userns keep-id.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 tests/docker/Makefile.include | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index 8df50a0ca06f..708e3a72fb8a 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -207,7 +207,12 @@ docker-run: docker-qemu-src
 	$(call quiet-command,						\
 		$(RUNC) run 						\
 			--rm						\
-			$(if $(NOUSER),,-u $(UID)) 			\
+			$(if $(NOUSER),,				\
+				$(if $(filter docker,$(RUNC)),		\
+					-u $(UID),			\
+					--userns keep-id		\
+				)					\
+			) 						\
 			--security-opt seccomp=unconfined		\
 			$(if $(DEBUG),-ti,)				\
 			$(if $(NETWORK),$(if $(subst $(NETWORK),,1),--net=$(NETWORK)),--net=none) \

---
base-commit: 74abb45dac6979e7ff76172b7f0a24e869405184
change-id: 20240620-podman-99d55d3a610b

Best regards,
-- 
Akihiko Odaki <akihiko.odaki@daynix.com>



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tests/docker: Specify --userns keep-id for Podman
  2024-06-26 11:09 [PATCH] tests/docker: Specify --userns keep-id for Podman Akihiko Odaki
@ 2024-06-26 16:16 ` Alex Bennée
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Bennée @ 2024-06-26 16:16 UTC (permalink / raw)
  To: Akihiko Odaki
  Cc: Philippe Mathieu-Daudé, Thomas Huth,
	Wainer dos Santos Moschetta, Beraldo Leal, qemu-devel

Akihiko Odaki <akihiko.odaki@daynix.com> writes:

> Previously we are always specifying -u $(UID) to match the UID in the
> container with one outside. This causes a problem with rootless Podman.
>
> Rootless Podman remaps user IDs in the container to ones controllable
> for the current user outside. The -u option instructs Podman to use
> a specified UID in the container but does not affect the UID remapping.
> Therefore, the UID in the container can be remapped to some other UID
> outside the container. This can make the access to bind-mounted volumes
> fail because the remapped UID mismatches with the owner of the
> directories.
>
> Replace -u $(UID) with --userns keep-id, which fixes the UID remapping.
> This change is limited to Podman because Docker does not support
> --userns keep-id.

Queued to testing/next, thanks.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-26 16:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-26 11:09 [PATCH] tests/docker: Specify --userns keep-id for Podman Akihiko Odaki
2024-06-26 16:16 ` Alex Bennée

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).