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

Add FileAttributes.Executable as a possible FileAttribute #925

Closed
kblok opened this issue Jul 17, 2018 · 12 comments
Closed

Add FileAttributes.Executable as a possible FileAttribute #925

kblok opened this issue Jul 17, 2018 · 12 comments
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.IO os-linux Linux OS (any supported distro)

Comments

@kblok
Copy link

kblok commented Jul 17, 2018

Introduction

With File.SetAttributes we can modify some file permissions, such as ReadOnly or ReadWrite, but we can't set Executable (a.k.a. 7) permission. I think we have everything we need on FileStatus.Unix.cs so we can do something like:

File.SetAttributes(path, FileAttributes.Executable);

It should call chmod setting a 7.

Usage

Some possible usage is when you need to download a zip file. You know that you have an app inside, but you need to change the mode to 7 to be able to execute it.

@danmoseley
Copy link
Member

What should it do on Windows?

@kblok
Copy link
Author

kblok commented Jul 17, 2018

As FileStatus.Unix.cs ignores Windows attributes (e.g. Hidden, Directory and many others), Windows code should ignore FileAttributes.Executable.

@danmoseley
Copy link
Member

Makes sense. Would this be for file owner only (S_IXUSR)

@kblok
Copy link
Author

kblok commented Jul 17, 2018

Makes sense. Would this be for file owner only (S_IXUSR)

Yes

@danmoseley
Copy link
Member

Thanks, I think this is ready for review, they meet once a week so it may be a little bit.

@stephentoub
Copy link
Member

As FileStatus.Unix.cs ignores Windows attributes (e.g. Hidden, Directory and many others), Windows code should ignore FileAttributes.Executable.

This was about making existing APIs work as best as possible. There's a higher bar for new APIs.

but we can't set Executable (a.k.a. 7) permission

Just as a point of order, executable is 1. 7 is Read (4) | Write (2) | Execute (1).

@kblok
Copy link
Author

kblok commented Jul 17, 2018

This was about making existing APIs work as best as possible. There's a higher bar for new APIs.

I don’t know if there is a concept of “Execute” permission on Windows, it’s about file extensions. What would you do in that case?

@stephentoub
Copy link
Member

stephentoub commented Jul 17, 2018

Why does it need to be on FileAttributes? Can you use the Mono.Posix nuget package and just call its Chmod (or P/Invoke to chmod directly)?

@kblok
Copy link
Author

kblok commented Jul 18, 2018

Why does it need to be on FileAttributes? Can you use the Mono.Posix nuget package and just call its Chmod (or P/Invoke to chmod directly)?

Yes, I could use Mono.Posix.NetStandard or P/Invoke.

When I was looking for "chmod" on this project, looking for a way to chmod 7 a file, I found that SetAttributes looked like a chmod wrapper: It validates the argument, checks if the argument is different from the current mode and then calls chmod.

On the other hand, I see that SetAttributes covers everything you need on windows, but it doesn't cover everything you need on Linux. So yeah, I could P/Invoke, but I think that a dev coding a linux app should have the same tools and level of abstraction than a guy coding a windows app. If one can set a file hidden the other should be able to make it executable.

@maryamariyan maryamariyan transferred this issue from dotnet/corefx Dec 16, 2019
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.IO untriaged New issue has not been triaged by the area owner labels Dec 16, 2019
@maryamariyan maryamariyan added api-needs-work API needs work before it is approved, it is NOT ready for implementation os-linux Linux OS (any supported distro) labels Dec 16, 2019
@maryamariyan maryamariyan added this to the 5.0 milestone Dec 16, 2019
@JeremyKuhne JeremyKuhne removed the untriaged New issue has not been triaged by the area owner label Mar 3, 2020
@k15tfu
Copy link
Contributor

k15tfu commented May 26, 2020

Interesting. Is there any progress on this issue?

Copy link
Contributor

Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

This process is part of our issue cleanup automation.

@dotnet-policy-service dotnet-policy-service bot added backlog-cleanup-candidate An inactive issue that has been marked for automated closure. no-recent-activity labels Dec 19, 2024
Copy link
Contributor

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

@dotnet-policy-service dotnet-policy-service bot removed this from the Future milestone Jan 2, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2025
@dotnet-policy-service dotnet-policy-service bot removed no-recent-activity backlog-cleanup-candidate An inactive issue that has been marked for automated closure. labels Feb 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.IO os-linux Linux OS (any supported distro)
Projects
None yet
Development

No branches or pull requests

8 participants