From: Richard Maw Date: Wed, 13 Mar 2024 17:30:34 +0000 (+0000) Subject: Restore all of a user's groups when running sync X-Git-Tag: v23~93^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2508%2Fhead;p=thirdparty%2Fmkosi.git 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. --- 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)