rust-mobile / cargo-apk

Helps cargo build APKs
Apache License 2.0
112 stars 31 forks source link

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

Open Philipp-M opened 1 year ago

Philipp-M commented 1 year ago

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).

kuviman commented 1 year ago

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.