Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group ownership and process ownership defaults to mock #1306

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mock/py/mockbuild/buildroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ def _init(self, prebuild):

# Change owner of homdir tree if the root of it not owned
# by the current user
self.chown_home_dir()
if prebuild:
self.chown_home_dir()

# mark the buildroot as initialized
file_util.touch(self.make_chroot_path('.initialized'))
Expand Down
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
Loading