-
Notifications
You must be signed in to change notification settings - Fork 232
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
UnixFS default mode perm does not match current behaviour #244
Comments
My 2c would be that the original of The unlikely case you mentioned is almost certainly going to exist somewhere, but hopefully beta testing will uncover it quickly enough for us to re-assess. For the time being I vote +1 to go with |
I think what we previously decided was to only set a mode if the UnixFS entry in question had a mode set on it. If no mode is present in the UnixFS metadata, we were to continue doing what we did before. |
If we are to continue doing what we were doing when no UnixFS metadata is present, then the spec should be changed to match the actual current behaviour. https://github.com/ipfs/specs/blob/master/UNIXFS.md currently specifies that if the optional But reality is the following:
It defaults to 666 currently for non-directories, and the most common default umask turns that into 644 for most users, and that's why it works for most users as described. If the spec specifies 644 as the default, it would be reasonable to expect it to create files with mode perm 644 even if umask is set to 0000. Maybe the solution is to remove the default perms from spec, and allow |
I have the same reading of the spec as @kalmi. Additionally doing |
My understanding of the spec is that it is also intended to cater for when you're only doing manipulations within IPFS, for example your mfs so I think the defaults should stay. That said, I wouldn't be averse to changing the permissions of files written to disk by |
The current default is definitely correct for what it does: it obeys the umask. It would actually be nice to continue doing this when the mode is unspecified. However, this is tricky from a UX & deduplication perspective:
For now, I think the right solution is to set the mode to the unixfs default AND obey the umask. This should "just work" in most cases. This isn't perfect because a more restrictive umask (e.g., 0700) will zero out the group/other permissions, but if that's what the user set, that's their problem. |
Note: In the go contributor guidelines, we say "don't break the ecosystem" to try to capture some of the nuances here. Small breaking changes are fine in many cases as long as they have minimal impact and can easily be worked around. In this case, changing the default to 0644 would only affect users with modes set to 0664 or 0666 (both of which are not recommended). |
Thanks for all the discussion. I agree with the ~umask&default approach. (I decided to have a look at how tar handles it, and I was horrified at first. By default, tar applies the umask when the user is a regular user, and by default ignores it when the user is root, and there are cli options to control this behaviour. After some thought I think it's actually a good default behaviour for tar's use cases, but it's a surprising behaviour.) |
@kalmi you bet! Please close the ticket if there are no further questions on this subject for the time being. You can always reopen it later if the need arises. |
I have come across this while working on ipfs/kubo#6920.
ipfs get
currently writes files with mode perm 666, but thanks to the most common default umask, this usually results in 644, which is the default fallback specified by the UnixFS spec.Changing
ipfs get
to use 644 as specified could in theory be breaking change for some with unusual umasks.Is this something to be concerned about? Should I just use the default as specified? Or should the spec be changed? Or is there some alternative solution I am not seeing?
The text was updated successfully, but these errors were encountered: