amenzhinsky/go-memexec

Clearly describe that the package is writing a binary to a temporary file in README

Helyk opened this issue · 8 comments

Helyk commented

Hello. I find the current contents of README.md somewhat misleading, in the following way.

It states:

Small library that executes code from the memory.

This creates an impression that the code (or actually binary) is being executed directly from the memory. It may be due to a specific problem that I was trying to solve when I found memexec that I made such an assumption, but I've seen some other people around trying to find a way to run an executable without writing to the filesystem, so it may be beneficial to clarify that, in fact, the executable is being written to a temporary file.

For instance, it may be written like this:

A small golang package that executes a binary file stored in memory by writing it to a temporary file, running and subsequently deleting it.

I should note that, despite not doing exactly the trick that I was searching for, this package demonstrates an implementation of a useful workaround, and I think it should stay published, but with a more accurate description.

Actually it's not misleading, the package does execute code from the memory, the way it does it not that important and can change in the future.

I've just pushed changes to linux that uses memfd instead of temp files on other platforms.

https://github.com/amenzhinsky/go-memexec/blob/master/memexec_linux.go

Helyk commented

I've just pushed changes to linux that uses memfd instead of temp files on other platforms.

Wow, that is very helpful of you and may completely satisfy my needs. I see that some checks didn't pass on it so I'll need to try it out carefully.

In the meantime, I still think it would be fair and useful to provide more information in README regarding what exactly it does and where, since some applications may be affected by specific implementation details.

I see that some checks didn't pass

Should be fine now

Helyk commented

Oh I actually can't get it through go get since there's no release.

go get -u github.com/amenzhinsky/go-memexec@master

but it makes sense to add a new tag now

Helyk commented

Thanks a lot, it works and does what I need. I will leave the issue open as I still think it would be useful to extend the description in README. Close it if you think it's not needed.

Hi @amenzhinsky

You said that "the package does execute code from the memory" but it still writes to the temp directory on Windows. Can I ask why this is necessary?

Hi @epiccucumber15

This is compatibility layer for all GOOS'es that don't have os-specific implementation in the package, like Linux, that uses memfd technique that is not available on other platforms.