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

set_file_perms: if the file is already executable, keep it executable #1141

Merged
merged 1 commit into from
Jun 8, 2017

Conversation

RalfJung
Copy link
Member

This was the smallest change I could come up with to fix rust-lang/rust#36488: Maintain the X bit when fixing up permissions.

However, the code is still somewhat inconsistent in that it does apply different rules when applied to a file vs. when applied to a directory -- the code recursively walking the directory still removes the X bits from all files, just like it previously ignored the "bin" directory. If you want, I can refactor this some more to be consistent here.

Fixes: #1140

@RalfJung
Copy link
Member Author

Not sure what these traivs failures are, the logs are empty...

@Diggsey
Copy link
Contributor

Diggsey commented Jun 3, 2017

Thanks for the PR!

Is there a reason we can't just preserve the permissions exactly as they are in the source package? Did previous packages have incorrect permissions, and we want to retain backwards compatibility?

I think it would be helpful to have tests covering the specific cases we want to support.

@RalfJung
Copy link
Member Author

RalfJung commented Jun 3, 2017

Is there a reason we can't just preserve the permissions exactly as they are in the source package? Did previous packages have incorrect permissions, and we want to retain backwards compatibility?

They definitely used to have incorrect permissions: rust-lang/rust#25479
It looks to me like this is no longer the case (i.e., when I checked briefly, the permissions looked all right), but I am not sure and I don't want to break everything, so this change is as conservative as I could make it.

I think it would be helpful to have tests covering the specific cases we want to support.

How would these tests look like? Are tests allowed to access the internet, so that they could download the latest stable, beta, nightly and check the permissions of some files?

@Diggsey
Copy link
Contributor

Diggsey commented Jun 4, 2017

We have code in src\rustup-mock\src\dist.rs to generate mock tarballs. It should be possible to generate tarballs with both legacy and new-style permissions, and verify that the permissions are correct after installation.

I also think we should try to avoid messing with the permissions as much as possible, given that they are now correct. For example, instead of overwriting all permissions, we could preserve them, but specifically add the "execute" permission to all files from the bin directory, where it's not already present.

@Diggsey
Copy link
Contributor

Diggsey commented Jun 5, 2017

Hm, apparantly there is precedent for only preserving the execute bit, in eg. git. - #313 (comment)

@vi
Copy link

vi commented Jun 5, 2017

Yes. Although Git tree format supports all permission bits, only one bit is actually used.

@RalfJung
Copy link
Member Author

RalfJung commented Jun 6, 2017

We have code in src\rustup-mock\src\dist.rs to generate mock tarballs. It should be possible to generate tarballs with both legacy and new-style permissions, and verify that the permissions are correct after installation.

Is there any testcase already using that? I couldn't find any, and that makes it kind of hard to figure out how the API is supposed to be used...

EDIT: Ah, I found rustup-dist/tests/install.rs. That looks good. There even is a unix_permissions test in there. I could extend that.
However, it seems to me that this involves extending MockComponent (the one in rustup-mock/src/lib.rs, not the one in dist.rs) to also specify permissions for the file -- or, at the very least, the X bit. Would that be all right?

@RalfJung
Copy link
Member Author

RalfJung commented Jun 7, 2017

All right I (a) did some refactoring in set_file_perms such that it also preserves X bits when it copies entire directories, and (b) extended the test suite to test this preservation. cargo test -p rustup-dist shows up all green.

@RalfJung
Copy link
Member Author

RalfJung commented Jun 7, 2017

I can of course change this to just bit-OR 0o111 to the existing permissions for everything inside a bin directory, and otherwise leave everything untouched. For now, I just figured I'd change as little as possible because things mostly work the way they are right now.

@Diggsey
Copy link
Contributor

Diggsey commented Jun 7, 2017

@RalfJung this looks great to me! Thanks for taking the time to add tests, it's much appreciated.

@bors r+

@bors
Copy link
Contributor

bors commented Jun 7, 2017

📌 Commit d1d694b has been approved by Diggsey

@bors
Copy link
Contributor

bors commented Jun 7, 2017

⌛ Testing commit d1d694b with merge 6cac413...

bors added a commit that referenced this pull request Jun 7, 2017
set_file_perms: if the file is already executable, keep it executable

This was the smallest change I could come up with to fix <rust-lang/rust#36488>: Maintain the X bit when fixing up permissions.

However, the code is still somewhat inconsistent in that it does apply different rules when applied to a file vs. when applied to a directory -- the code recursively walking the directory still removes the X bits from all files, just like it previously ignored the "bin" directory. If you want, I can refactor this some more to be consistent here.

Fixes: #1140
@bors
Copy link
Contributor

bors commented Jun 8, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: Diggsey
Pushing 6cac413 to master...

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