Open
Conversation
Contributor
KalleOlaviNiemitalo
left a comment
There was a problem hiding this comment.
Does this support o+r-w? In chmod, that is the same as o+r,o-w.
Contributor
Author
yes it does same as POSIX/toybox implementation |
Contributor
|
Really? It seems to me there aren't enough nested loops. |
Contributor
|
It seems to execute
|
Contributor
Author
|
@KalleOlaviNiemitalo thanks! after the fix, tested with: Console.WriteLine("o+r-w -> " + ChmodHelper.Parse("o+r-w", UnixFileMode.UserWrite | UnixFileMode.GroupWrite));
Console.WriteLine("u+x,g-w -> " + ChmodHelper.Parse("u+x,g-w", UnixFileMode.UserWrite | UnixFileMode.GroupWrite));
Console.WriteLine("a=r -> " + ChmodHelper.Parse("a=r", 0));
Console.WriteLine("g=u -> " + ChmodHelper.Parse("g=u", UnixFileMode.UserRead | UnixFileMode.UserWrite));
Console.WriteLine("u+s,g+s,o+t -> " + ChmodHelper.Parse("u+s,g+s,o+t", 0));
Console.WriteLine("u+rwx,g-r,o-r -> " + ChmodHelper.Parse("u+rwx,g-r,o-r", UnixFileMode.UserWrite | UnixFileMode.GroupWrite | UnixFileMode.OtherRead));
Console.WriteLine("o+x,u-g -> " + ChmodHelper.Parse("o+x,u-g", UnixFileMode.UserRead | UnixFileMode.GroupRead)); |
c044646 to
f5b22ec
Compare
Contributor
Author
|
@tmds, @akoeplinger ptal |
Member
|
@kasperk81 I'm not sure adding all this parsing logic is a good idea. For the UnixFilePermissions.xml we can just support the numerical formats and use SetUnixFileMode, but for the templating case I'd just leave it as is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To stay compatible with the behavior described in the .NET specs:
these specs effectively define the permission string as whatever
chmodaccepts which makes the format somewhat vague and underspecified.To accommodate this, I added chmod-style permission parsing based on POSIX spec e.g. cases handled in: https://github.com/landley/toybox/blob/c9c0d42aae50b80cda27bd6131f315e57513be47/lib/lib.c#L950. This is used as a fallback when parsing user-provided
System.IO.UnixFileModeenum names fails: https://learn.microsoft.com/en-us/dotnet/api/system.io.unixfilemode#fieldsAs a result, the following formats are supported.
Existing
data/UnixFilePermissions.xml(unchanged)New (enum-based permissions)
This preserves backward compatibility while also allowing explicit permissions using the
UnixFileModeenum.