Skip to content

gh-114435: Add test skip when running as admin. #114571

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

Merged
merged 3 commits into from
Jan 26, 2024
Merged

Conversation

zooba
Copy link
Member

@zooba zooba commented Jan 25, 2024

Also makes _winapi.CreateFile unconditionally use Unicode.

Also makes _winapi.CreateFile unconditionally use Unicode.
# We should now not be able to open the file.
# If we can, the test isn't going to be useful.
try:
_winapi.CloseHandle(_winapi.CreateFile(
Copy link
Member

Choose a reason for hiding this comment

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

Is it different from using open() or os.open()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, admin may have additional privileges that make FILE_FLAG_BACKUP_SEMANTICS able to access files that are supposed to be locked away. (One earlier issue with this test is that CreateJunction was enabling the privilege but not disabling it.)

The flags passed here match what stat uses, so we should get equivalent behaviour. Though there's a new quirk that I'm looking into, so we may end up having to just remove the checks in the test that make sure ino/dev are zero, since in some cases they may legitimately get the real value.

@zooba
Copy link
Member Author

zooba commented Jan 26, 2024

@serhiy-storchaka Sorry to make changes just after you approved, but I think we need to remove the skip and instead allow dev/ino to be correctly read. I'm confirming, but I think the new stat API we use on newer Windows is able to read them even in this case, so we don't really have a choice but to allow both values.

The test will still catch wildly invalid results, like the ones that triggered the original issue.

@zooba zooba enabled auto-merge (squash) January 26, 2024 16:47
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Please don't forget to change the commit message.

@zooba zooba merged commit d91ddff into python:main Jan 26, 2024
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Ubuntu NoGIL 3.x has failed when building commit d91ddff.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1225/builds/1270) and take a look at the build logs.
  4. Check if the failure is related to this commit (d91ddff) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/1225/builds/1270

Failed tests:

  • test_capi
  • test_eintr
  • test_tokenize

Failed subtests:

  • test_all - test.test_eintr.EINTRTests.test_all
  • test_flock - main.FNTLEINTRTest.test_flock

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.nogil/build/Lib/test/_test_eintr.py", line 535, in test_flock
    self._lock(fcntl.flock, "flock")
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.nogil/build/Lib/test/_test_eintr.py", line 517, in _lock
    raise Exception("failed to sync child in %.1f sec" % dt)
Exception: failed to sync child in 300.2 sec


Traceback (most recent call last):
  File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.nogil/build/Lib/test/test_eintr.py", line 17, in test_all
    script_helper.run_test_script(script)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.nogil/build/Lib/test/support/script_helper.py", line 316, in run_test_script
    raise AssertionError(f"{name} failed")
AssertionError: script _test_eintr.py failed

@zooba zooba deleted the gh-114435 branch January 29, 2024 13:12
@zooba
Copy link
Member Author

zooba commented Jan 29, 2024

This PR didn't touch the above listed tests, and it's a nogil buildbot, so someone working on that stuff can look into it.

aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
… ino/dev (pythonGH-114571)

This may occur if Windows allows reading stat information from a file even if the current user does not have access.
@zooba zooba added the needs backport to 3.12 only security fixes label Feb 23, 2024
@miss-islington-app
Copy link

Thanks @zooba for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 23, 2024
… ino/dev (pythonGH-114571)

This may occur if Windows allows reading stat information from a file even if the current user does not have access.
(cherry picked from commit d91ddff)

Co-authored-by: Steve Dower <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Feb 23, 2024

GH-115851 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Feb 23, 2024
zooba added a commit that referenced this pull request Feb 23, 2024
…ev (GH-114571)

This may occur if Windows allows reading stat information from a file even if the current user does not have access.
(cherry picked from commit d91ddff)

Co-authored-by: Steve Dower <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
… ino/dev (pythonGH-114571)

This may occur if Windows allows reading stat information from a file even if the current user does not have access.
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