Crate replicate

source ·
Expand description

Copies the currently running program into a temporary location

This crate copies the currently running executable into a temporary location and returns the path to that executable. This allows you to (for example):

  • Compile a program statically using something like musl
  • Create a copy of that program while it’s running
  • Run Docker from your original program, mounting the copy as a Docker volume mount
  • Run the copied program from within the Dockerized environment.

Because this library uses NamedTempFile via Builder to generate a temporary location, the following security restrictions apply to Replicate:

  1. The copy has a short lifetime and your temporary file cleaner is sane (doesn’t delete recently accessed files).
  2. You trust every user on your system (i.e. you are the only user).
  3. You have disabled your system’s temporary file cleaner or verified that your system doesn’t have a temporary file cleaner.

Structs

A temporary copy of the running executable.