Hi,
I created the crate rookie and recently I needed to use include_bytes!
inside the crate to include .exe
file (I write it to temp file at runtime and execute it)
I know, it's anti pattern. I wouldn't do that in most cases but that's the easiest way currently.
The binary files weight only ~300KB.
However, cargo package
or cargo publish
refuse to include the .exe
files in the package, hence include_bytes!
failed when users install the library.
I tried to allow the include of .exe
files inside Cargo.toml
but it still missing. I even tried to rename the exe files to .rs
but it still doesn't included.
Is there a way to still include them? It would be best if I can embed it and not use some workaround such as download it with build.rs as it's only 300KB.
Thanks
There are the package.include
and package.exclude
fields of your manifest file you can use to tell Cargo what files and directories to include in cargo package
:
https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields
You can run cargo package -l
to list all the files that are included in the tarball.
Oof, that looks like something that malware would do:
I tried to include "*.exe" but it doesn't include them...
I didn't about cargo package -l
. very useful thanks
I agree
There's much more elegant ways to gain system permissions. I intend to improve it.
It would be nice if you could build these tools from source (e.g. with the cc
crate), to make your package possible to review and reproduce.
Otherwise you're asking users to run an unknown binary blob, with administrator privileges, and probably also disable antivirus while doing so. This is super scary.
I'm gonna remove that part completely. What I needed there is to gain system privileges.
I can do that with Windows API directly when I have admin rights.
I'll replicate main.go in Rust, though it probably will be much more verbose in Rust comparing to Go
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.