-
Notifications
You must be signed in to change notification settings - Fork 97
Preserve file permissions in fakefs after add_real_file #1119
Copy link
Copy link
Closed
Description
Describe the bug
Suppose I have a real file /usr/bin/env, owned by root:root, with permissions 0755.
If I copy this file into a fake filesystem the user and group are preserved, but the permissions are changed to 0444.
How To Reproduce
Note: This assumes you are on a *nix system with an executable file /usr/bin/env on your real filesystem.
If not, substitute any other file owned by root with permissions 0755.
import os
from pyfakefs.fake_filesystem import FakeFilesystem
from pyfakefs.fake_os import FakeOsModule
file = '/usr/bin/env'
fs = FakeFilesystem()
fs.add_real_file(file)
real_permissions = oct(os.stat(file).st_mode)
print(f"{real_permissions=}")
fake_os = FakeOsModule(fs)
fake_permissions = oct(fake_os.stat(file).st_mode)
print(f"{fake_permissions=}")
# output
# real_permissions='0o100755'
# fake_permissions='0o100444'Your environment
Please run the following in the environment where the problem happened and
paste the output.
Linux-6.8.0-53-generic-x86_64-with-glibc2.39
Python 3.12.3 (main, Jan 17 2025, 18:03:48) [GCC 13.3.0]
pyfakefs 5.7.4
pytest 8.3.4Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels