From f800ad9d37ad3173466e83f5c8756c361d086662 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 13 Mar 2024 17:30:34 +0000 Subject: [PATCH] Restore all of a user's groups when running sync Shared development hardware often has storage partitioned up by project groups, with the root of the shared storage owned by root:project. Since this group isn't the primary group of the user using setgroups and restoring groups to just the user's primary gid will mean that it does not have this project group gid and so won't be able to see the contents of this shared directory. Using getgrouplist to get all of the groups from the user database allows these additional groups to be set. --- mkosi/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index b754bd7da..471bc5649 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -4023,7 +4023,7 @@ def sync_repository_metadata(context: Context) -> None: def run_sync(args: Args, config: Config, *, resources: Path) -> None: if os.getuid() == 0: - os.setgroups([INVOKING_USER.gid]) + os.setgroups(os.getgrouplist(INVOKING_USER.name(), INVOKING_USER.gid)) os.setgid(INVOKING_USER.gid) os.setuid(INVOKING_USER.uid) -- 2.47.2