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

os: chmod could report if mode bits that are not in use are provided #44575

Open
kevlar700 opened this issue Feb 24, 2021 · 3 comments
Open

os: chmod could report if mode bits that are not in use are provided #44575

kevlar700 opened this issue Feb 24, 2021 · 3 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@kevlar700
Copy link

kevlar700 commented Feb 24, 2021

What version of Go are you using (go version)?

go version go1.16rc1 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using linux/amd64

What did you expect to see?

A directory with drwxrwxrwt

What did you see instead?

drwxrwxrwx
Incorrect permission bit (missing t)

Proposal

Chmod could return an error, if bits are supplied that are not in use.

This could point users to the documentation that alternatively could be improved (currently an iota source copy) and also protect users to a degree, that fail to use an octal literal notation e.g. 1777 like the chmod command line binary instead of 01777

I assume to some degree that os.chmod could return an error upon use of certain or ideally, all unused bits. Those bits could be reclaimed if needed in the future and consideration of user behaviour, considered before new bit assignments?

if (mode & 0o1000) != 0 {
   return errors.New("the supplied os.FileMode contains a unix sticky bit that is not currently in use, use os.ModeSticky ")
}

//Or along the lines of the following (sticky, sgid and suid) but perhaps for all unused bits.

if (mode & 0o7000) != 0 {
   return errors.New("the supplied os.FileMode contains a bit that is not currently in use, go chmod differs from unix chmod")
}
@kevlar700
Copy link
Author

#27452
#22671
#12711

@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 24, 2021
@cagedmantis cagedmantis added this to the Backlog milestone Feb 24, 2021
@networkimprov
Copy link

cc @ianlancetaylor as this seems like a Proposal.

@ianlancetaylor
Copy link
Member

I think the main question here is how to handle the fact that different operating systems support different flags. I think it would be OK to give an error if os.Chmod is called with flags that are not supported on any operating system. I don't think we need a proposal for that, we can just do it. And maybe that is the best that we can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants