]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Restore all of a user's groups when running sync 2508/head
authorRichard Maw <richard.maw@codethink.co.uk>
Wed, 13 Mar 2024 17:30:34 +0000 (17:30 +0000)
committerRichard Maw <richard.maw@codethink.co.uk>
Thu, 14 Mar 2024 16:11:59 +0000 (16:11 +0000)
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

index b754bd7dab7c38cc31f980974c47968bd7ea98a5..471bc564985a478ef680284ba0869c4c2295e87d 100644 (file)
@@ -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)