Skip to content

gh-127146: Skip test_netrc.test_security on Emscripten #136227

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 1 commit into
base: main
Choose a base branch
from

Conversation

hoodmane
Copy link
Contributor

@hoodmane hoodmane commented Jul 3, 2025

Before #135816 it was skipped because pwd is missing on Emscripten. Now it isn't skipped because the test no longer requires pwd but it still doesn't work on Emscripten.

Before python#135816 it was skipped because pwd is missing on Emscripten.
Now it isn't skipped because the test no longer requires pwd but it
still doesn't work on Emscripten.
@cmaloney
Copy link
Contributor

cmaloney commented Jul 3, 2025

Is this failing because of https://github.com/python/cpython/blob/main/Lib/netrc.py#L10C5-L12 (from gh-135815)?

This test is validating the security check is working right (added in gh-59189). Worried about disabling a test for a security check rather than just disabling the module (or fixing the security check).

@freakboy3742
Copy link
Contributor

Is this failing because of https://github.com/python/cpython/blob/main/Lib/netrc.py#L10C5-L12 (from gh-135815)?

This test is validating the security check is working right (added in gh-59189). Worried about disabling a test for a security check rather than just disabling the module (or fixing the security check).

I'm not 100% sure about this. Unlike WASI, Emscripten reliably has os.getuid(); but it doesn't have pwd. So - the netrc._can_security_check() will pass (which means the test added for WASI test will fail); but the default test is failing (because the check performed by that test doesn't hold for Emscripten):

======================================================================
ERROR: test_security (test.test_netrc.NetrcTestCase.test_security)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/emscripten/buildarea/3.x.rkm-emscripten.emscripten/build/Lib/test/test_netrc.py", line 292, in test_security
    nrc = netrc.netrc()
  File "/home/emscripten/buildarea/3.x.rkm-emscripten.emscripten/build/Lib/netrc.py", line 88, in __init__
    self._parse(file, fp, default_netrc)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emscripten/buildarea/3.x.rkm-emscripten.emscripten/build/Lib/netrc.py", line 155, in _parse
    self._security_check(fp, default_netrc, self.hosts[entryname][0])
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emscripten/buildarea/3.x.rkm-emscripten.emscripten/build/Lib/netrc.py", line 164, in _security_check
    raise NetrcParseError(
        f"~/.netrc file owner ({fowner}) does not match"
        f" current user ({user})")
netrc.NetrcParseError: ~/.netrc file owner (uid 1002) does not match current user (uid 0) (None, line None)

----------------------------------------------------------------------
Ran 23 tests in 0.037s

FAILED (errors=1, skipped=1)

My immediate guess is that the _can_security_check() method should be modified to catch the Emscripten behavior (maybe by adding and os.getuid() != 0, or maybe even an explicit and sys.platform != "emscripten". @hoodmane may have another idea.

That said - it's interesting that this failure is also occurring with a file mode, which is similar to the failure reported as #135783 (although it's a very different issue). That might be complete coincidence... but it's an interesting simliarity.

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.

3 participants