Visitar URL original
Do not write bytecode when running as root or superuser · Issue #101702 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20230304214106/https://github.com/python/cpython/issues/101702
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

Do not write bytecode when running as root or superuser #101702

Closed
vishwin opened this issue Feb 8, 2023 · 1 comment
Closed

Do not write bytecode when running as root or superuser #101702

vishwin opened this issue Feb 8, 2023 · 1 comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@vishwin
Copy link

vishwin commented Feb 8, 2023 •

Bug report

Bytecode is written by default if it does not already exist, unless -B or PYTHONDONTWRITEBYTECODE is set/passed. This is not a problem in most cases, but in a operating system-level package building or system-level administrative context, filesystem pollution is not desirable, causing package and system integrity issues amongst other items.

Many operating system-level package distributions include compiled bytecode in their packages, but this is not orthogonal to what Python's own package tooling does by default, which compiles bytecode at install time. FreeBSD ports gained trigger functionality, which, amongst other things, allows the correct operation of compiling, writing and removing bytecode at install time.

It is proposed to disable writing bytecode when running as root or superuser.

Your environment

FreeBSD-CURRENT

  • CPython versions tested on: all supported
  • Operating system and architecture: at least any Unix-like system

FreeBSD-specific context

The environment is separate between different stages of package building. The user is not necessarily root during the fetch, patch, configure, build stages, but is root for all others, including an optional interactive shell stage. Environment variables, including PYTHONDONTWRITEBYTECODE, can only be passed per command invocation. While we have a Makefile variable that references the path to the correct Python interpreter where -B could theoretically be included, it does not persist during the interactive stage as it is not an environment variable.

Linked PRs

@vishwin vishwin added the type-bug An unexpected behavior, bug, or error label Feb 8, 2023
@arhadthedev arhadthedev added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Feb 8, 2023
@vishwin
Copy link
Author

vishwin commented Feb 12, 2023

No longer needed/applicable

@vishwin vishwin closed this as not planned Won't fix, can't repro, duplicate, stale Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants