Skip to content

Navigation Menu

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

Appearance settings

gh-127081: use getlogin_r if available #132751

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
Loading
from

Conversation

duaneg
Copy link
Contributor

@duaneg duaneg commented Apr 20, 2025

The getlogin function is not thread-safe: replace with getlogin_r where available.

Note that this function is untested (unit test is skipped with a note it caused CI failures as behaviour differs between NIX environments).

The getlogin function is not thread-safe: replace with getlogin_r where
available.

Note that this function is untested (unit test is skipped with a note it caused
CI failures as behaviour differs between NIX environments).
@picnixz picnixz changed the title gh-127081: use getlogin_r if available gh-127081: use getlogin_r if available Apr 20, 2025
Modules/posixmodule.c Outdated Show resolved Hide resolved
Modules/posixmodule.c Outdated Show resolved Hide resolved
duaneg added 2 commits April 22, 2025 11:39
…at order)

if available, falling back to a hard-coded maximum login name length of 255 if
neither is available.
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should get a test case.

@duaneg
Copy link
Contributor Author

duaneg commented May 18, 2025

This should get a test case.

The specific change or os.getlogin generally?

The existing (unconditionally skipped) test could be re-enabled, but it doesn't test very much at all, and presumably will still fail on some CI systems. Perhaps we could expand it to get the "correct" result to check against via a shell command? Then if/when it fails on specific platforms either skip or special-case the test for them?

Testing the specific change: I can add a multi-threaded test, but it would ideally be conditional on having getlogin_r or it would crash on platforms that don't (assuming there actually are any). Probably easiest to just selectively skip the test on any such platforms I suppose.

@colesbury colesbury self-requested a review May 19, 2025 03:27
@colesbury colesbury added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 20, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @colesbury for commit 675342c 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F132751%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 20, 2025
Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM assuming the build bots pass

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.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.