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

Fix permissions of add_lib, when copying readonly libraries (e.g. of nix/store) to avoid a Permissions Denied Error #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Philipp-M
Copy link

I had issues when using this with NixOS and the android-sdk in the /nix/store which is completely read-only.

It copied the file from there and kept the permissions of it, running cargo apk a second time resulted in an Permissions denied error, because the file couldn't be overwritten.

This fix just sets the permissions to standard 644 permissions, which is AFAIK recommended for files like .so.
I think this could also be fixed, by just setting the user write permission bit of the file (a matter of preference I guess).

…nix/store) to avoid a Permissions Denied Error
std::fs::copy(path, out)?;
fs::copy(path, out.clone())?;
#[cfg(target_family = "unix")]
fs::set_permissions(out, fs::Permissions::from_mode(0o644))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should at the very least have a comment documenting this workaround for Nix 😉

@kuviman
Copy link

kuviman commented Jun 28, 2023

Not sure if it matters but there is Permissions::set_readonly in std which makes it not unix-specific. There is tho a note that it is equivalent to chmod a+w, which is different from 644.

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

Successfully merging this pull request may close these issues.

3 participants