Skip to content

gh-152936: Make privileged functions available on Android#152977

Open
sabamdarif wants to merge 1 commit into
python:mainfrom
sabamdarif:main
Open

gh-152936: Make privileged functions available on Android#152977
sabamdarif wants to merge 1 commit into
python:mainfrom
sabamdarif:main

Conversation

@sabamdarif

@sabamdarif sabamdarif commented Jul 3, 2026

Copy link
Copy Markdown

os.chroot,initgroups,setegid,seteuid,setgid.... are currently blocked on Android.
Because the underlying C functions crash the process when called by a non-root user on android, rather than returning an error.
So i added getuid() != 0 check (under #ifdef ANDROID) before each call, so it will return PermissionError for non-root just like normal Unix

@bedevere-app

bedevere-app Bot commented Jul 3, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot

python-cla-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@sabamdarif

Copy link
Copy Markdown
Author

it's my first pr here so i don't know much about the NEWS entry, if it's not a problem can anyone tell me if i do need to add any NEWS entry ?

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33432191 | 📁 Comparing 8b77d9d against main (423ae0f)

  🔍 Preview build  

2 files changed
± library/os.html
± library/socket.html

@Aniketsy

Aniketsy commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

it's my first pr here so i don't know much about the NEWS entry, if it's not a problem can anyone tell me if i do need to add any NEWS entry ?

thanks for the PR, as per my thought yes, this will need NEWS entry but you can wait for the review and then you can add NEWS entry ( to get 100 % sure 😀)

@mhsmith mhsmith self-requested a review July 4, 2026 01:26
@sabamdarif

Copy link
Copy Markdown
Author

i have another question for the Android test failure should i update the test_posix.py ? to do something like if support.is_android and os.getuid() != 0: so it will not failed on PermissionError ? or should i need to update something on my patch so the existing test pass

@sabamdarif

Copy link
Copy Markdown
Author

why did the Tests / Sanitizers / TSan (free-threading) (pull_request) failed i don't get it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make privileged functions available on Android

2 participants