Skip to content

Make privileged functions available on Android #152936

Description

@mhsmith

Proposal:

configure.ac contains a list of privileged functions which are "blocked" on Android, i.e. they simply won't exist in the stdlib. This was because when any of the underlying C functions are called by a non-root user, instead of returning a PermissionError as they would on Linux, they cause a low-level crash of the whole process.

This approach has 2 problems:

  • Users of these functions will probably be able to handle a PermissionError, but not an AttributeError.
  • It prevents using the functions on rooted devices.

Termux is working around this by making Python check the UID and raise the PermissionError itself in a non-root context. I think it would be a good idea to adopt this upstream.

  • This change should only affect Android; on other platforms, UID checks should continue to be done by the underlying C function.
  • Most of these functions are documented as "not Android"; that should also be removed.
  • Functions which are blocked in configure.ac for other reasons should continue to be blocked.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on the Termux issue tracker

Links to previous discussion of this feature:

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-androidstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions