Skip to content

Commit

Permalink
Non-privileged actions performed with GID=135 (mock)
Browse files Browse the repository at this point in the history
Hopefully, we do not open a can of worms.., but using GID=135 for
non-privileged operations seems like the most expected Mock behavior.
This way, we automatically maintain the ownership-bridge between the
on-host user and the in-chroot user (both present in the 'mock' group).

Mock started to map the unprivGid to the default GID of the on-host user
in the commit 5cce73a, which is very
old and rather seems like a mistake rather than intention.

Fixes: #1257
  • Loading branch information
praiskup committed Feb 5, 2024
1 parent a447d89 commit 2707f4d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions mock/py/mockbuild/uid.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,19 @@
def setup_uid_manager():
mockgid = grp.getgrnam('mock').gr_gid
unprivUid = os.getuid()
unprivGid = os.getgid()
unprivGid = mockgid

# sudo
if os.environ.get("SUDO_UID") is not None:
unprivUid = int(os.environ['SUDO_UID'])
os.setgroups((mockgid,))
unprivGid = int(os.environ['SUDO_GID'])

# consolehelper
if os.environ.get("USERHELPER_UID") is not None:
unprivUid = int(os.environ['USERHELPER_UID'])
unprivName = pwd.getpwuid(unprivUid).pw_name
secondary_groups = [g.gr_gid for g in grp.getgrall() if unprivName in g.gr_mem]
os.setgroups([mockgid] + secondary_groups)
unprivGid = pwd.getpwuid(unprivUid)[3]

uidManager = UidManager(unprivUid, unprivGid)
return uidManager
Expand Down

0 comments on commit 2707f4d

Please sign in to comment.