Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-100163: allow re-assuming root privileges on subprocess invocations#134400

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
duaneg wants to merge4 commits intopython:main
base:main
Choose a base branch
Loading
fromduaneg:gh-100163

Conversation

duaneg
Copy link
Contributor

@duanegduaneg commentedMay 21, 2025
edited by bedevere-appbot
Loading

Thesubprocess.Popen class takes user/group/extra groups parameters which allow invocations to run as a different user. When dropping privileges (i.e. the main program is running as root but wants to run a subprocess as an unprivileged user) this works fine. However, it fails if a program wants to drop privileges and re-assume them to run a subprocess.

To allow this there are a couple of changes required:

  • Usesetresuid/setresgid instead ofsetreuid/setregid so the saved user/group identity can be re-assumed after it has been dropped.
  • Setting the user identity first so the group identity and extra groups calls can be made with root privilege.

Naturally we need to continue to set the user identity last when going from root to an unprivileged user, so the order of calls needs to be determined dynamically based on whether we are switching to or from root.

This is a preparatory refactoring which should have no semantic effect initself but will hopefully make the real changes coming in subsequent patcheseasier to review.
Setting the saved user/group-ID allows the code to re-assume privileges afterdropping them.
When dropping privileges we need to set the new effective UID last, so we havepermission to change the gid/groups. When re-assuming root privileges we needto do the opposite: set the UID first so we then have permission to changegid/groups.
@gpshead
Copy link
Member

status: I'm marking this as a Draft as we're deciding (see issue) on if this is the right approach. manual testing likely required due to privs. required.

duaneg and socketpair reacted with thumbs up emoji

@gpsheadgpshead marked this pull request as draftMay 21, 2025 01:39
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gpsheadgpsheadAwaiting requested review from gpsheadgpshead is a code owner

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@duaneg@gpshead

[8]ページ先頭

©2009-2025 Movatter.jp