Skip to content
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

Read-only attribute versus read permissions #13236

Open
HertzDevil opened this issue Mar 28, 2023 · 0 comments
Open

Read-only attribute versus read permissions #13236

HertzDevil opened this issue Mar 28, 2023 · 0 comments

Comments

@HertzDevil
Copy link
Contributor

HertzDevil commented Mar 28, 2023

On Windows, a file has read permissions if it doesn't have the read-only file attribute set:

def system_permissions : ::File::Permissions
if @file_attributes.dwFileAttributes.bits_set? LibC::FILE_ATTRIBUTE_READONLY
permissions = ::File::Permissions.new(0o444)
else
permissions = ::File::Permissions.new(0o666)
end

In fact, this attribute completely determines whether a File::Permissions has the read bits, because #13233 isn't implemented yet.

BSD-like systems, including Darwin, also have several file attributes in the LibC::Stat#st_flags that may make a file read-only. All have UF_IMMUTABLE = 0x00000002 and SF_IMMUTABLE = 0x00020000. FreeBSD additionally has UF_READONLY = 0x00001000, that maps to the Windows attribute above, but that attribute seems to have no real effect. Should those flags be reflected in File::Info#permissions? Should Windows do it in the first place?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant