8000 test_pathlib assumes underlying filesystem permits creation with world-write permissions · Issue #85633 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

test_pathlib assumes underlying filesystem permits creation with world-write permissions #85633

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

Closed
aixtools opened this issue Aug 3, 2020 · 3 comments
Labels
3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes tests Tests in the Lib/test dir topic-pathlib type-bug An unexpected behavior, bug, or error

Comments

@aixtools
Copy link
Contributor
aixtools commented Aug 3, 2020
BPO 41461
Nosy @serhiy-storchaka, @aixtools

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-08-03.07:06:46.172>
labels = ['3.8', 'type-bug', 'tests', '3.9', '3.10']
title = 'test_pathlib assumes underlying filesystem permits creation with world-write permissions'
updated_at = <Date 2021-03-30.21:42:43.099>
user = 'https://github.com/aixtools'

bugs.python.org fields:

activity = <Date 2021-03-30.21:42:43.099>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Tests']
creation = <Date 2020-08-03.07:06:46.172>
creator = 'Michael.Felt'
dependencies = []
files = []
hgrepos = []
issue_num = 41461
keywords = []
message_count = 2.0
messages = ['374725', '389860']
nosy_count = 2.0
nosy_names = ['serhiy.storchaka', 'Michael.Felt']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue41461'
versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

Linked PRs

@aixtools
Copy link
Contributor Author
aixtools commented Aug 3, 2020

Two tests in test_pathlib test that the files created have mode o666 (rw-rw-rw).

However, on a filesystem (in my case NFS) configured to never permit global write - the test will always fail.

Is this something to be concerned about?

I can think of a few possible ways to react to an exception such as this, e.g., rather than 'FAIL' outright, try umask(2).

++++++++
======================================================================
FAIL: test_open_mode (test.test_pathlib.PosixPathTest)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/data/prj/python/src/py38-3.8.5/Lib/test/test_pathlib.py", line 2210, in test_open_mode
    self.assertEqual(stat.S_IMODE(st.st_mode), 0o666)
AssertionError: 436 != 438

======================================================================
FAIL: test_touch_mode (test.test_pathlib.PosixPathTest)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/data/prj/python/src/py38-3.8.5/Lib/test/test_pathlib.py", line 2223, in test_touch_mode
    self.assertEqual(stat.S_IMODE(st.st_mode), 0o666)
AssertionError: 436 != 438

++++++++

Just to verify it does work when on a 'local' filesystem.

cp -rp build /tmp/build
mv build build.nfs
ln -s /tmp/build build

== Tests result: SUCCESS ==

1 test OK.

Total duration: 7.8 sec
Tests result: SUCCESS

@aixtools aixtools added 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Aug 3, 2020
@serhiy-storchaka
Copy link
Member

umask(0o002) looks good idea (and perhaps umask(0o026) instead of umask(0o022)). Please add also a short explanation comment.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
barneygale added a commit to barneygale/cpython that referenced this issue Aug 10, 2024
…d-write.

Replace `umask(0)` with `umask(2)`, and `umask(0o022)` with `umask(0o026)`,
so the created files are not world-writable. In the latter case, we remove
read permission to check that permissions for 'others' can still be set.
barneygale added a commit to barneygale/cpython that referenced this issue Aug 10, 2024
…d-write.

Replace `umask(0)` with `umask(2)` so the created files are not
world-writable, and replace `umask(0o022)` with `umask(0o026)` to check
that permissions for 'others' can still be set.
barneygale added a commit that referenced this issue Aug 13, 2024
…e. (#122883)

Replace `umask(0)` with `umask(0o002)` so the created files are not
world-writable, and replace `umask(0o022)` with `umask(0o026)` to check
that permissions for 'others' can still be set.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 13, 2024
…d-write. (pythonGH-122883)

Replace `umask(0)` with `umask(0o002)` so the created files are not
world-writable, and replace `umask(0o022)` with `umask(0o026)` to check
that permissions for 'others' can still be set.
(cherry picked from commit 5f68511)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
barneygale added a commit that referenced this issue Aug 13, 2024
…ld-write. (GH-122883) (#122979)

GH-85633: Fix pathlib test failures on filesystems without world-write. (GH-122883)

Replace `umask(0)` with `umask(0o002)` so the created files are not
world-writable, and replace `umask(0o022)` with `umask(0o026)` to check
that permissions for 'others' can still be set.
(cherry picked from commit 5f68511)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
@barneygale
Copy link
Contributor

Sorted. Thanks Serhiy for the suggestion and review.

blhsing pushed a commit to blhsing/cpython that referenced this issue Aug 22, 2024
…d-write. (python#122883)

Replace `umask(0)` with `umask(0o002)` so the created files are not
world-writable, and replace `umask(0o022)` with `umask(0o026)` to check
that permissions for 'others' can still be set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes tests Tests in the Lib/test dir topic-pathlib type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants
0