JonathonReinhart / staticx

Create static executable from dynamic executable
https://staticx.readthedocs.io/
Other
345 stars 37 forks source link

Feature: CLI options for bundle directory and program name #283

Closed andria-dev closed 3 months ago

andria-dev commented 4 months ago

WIP for #282. --bundle-dir will determine where the bootloader extracts the archive to. --prog-name will determine the name of the program within the archive. For example:

# We can specify the new options like so:
staticx --bundle-dir /tmp/ssh-6YD5uj0Xx7wI --prog-name agent.1542 myprogram ssh-agent

# And when we run the staticx program,
./ssh-agent
# it will extract to the folder /tmp/ssh-6YD5uj0Xx7wI,
# and the program will be extracted to /tmp/ssh-6YD5uj0Xx7wI/agent.1542

# The program will show up as two processes in a process listing:
# ./myprog and its child process /tmp/ssh-6YD5uj0Xx7wI/agent.1542

Checklist

Testing

Testing done in test/bundle-dir-prog-name.sh.

CLI

Documentation

Implementation

--prog-name

--bundle-dir

Unfortunately, I don't have the C skills to have it extract directly to the new bundle directory, so my solution here is to extract to the /tmp/staticx-XXXXXX and then move it to the new bundle directory, which is obviously not ideal. If anyone has any ideas about how to read the TAR archive to get the symlink before extracting please feel free to jump in.