Experimental: pass first stage parameters in argv
Before (line continuations added manually)
The context label (alex@kintha:<pid>) and preamble length (18191) are encoded inside the base64
ssh -o LogLevel ERROR -o Compression yes -o ServerAliveInterval 15 -o ServerAliveCountMax 3 -o BatchMode yes -o StrictHostKeyChecking yes foo \
python -c \
'import sys;sys.path=[p for p in sys.path if p];import binascii,os,zlib;exec(zlib.decompress(binascii.a2b_base64("eNqVkl1PwjAUhu/5Fd61i8toh0pYXCIBFBP5yIIuBheyj04aRtt0GwN/vR0zuGGM8W5P3/ec93Q9ju7aPDUEFQRqLakXNaLxhYKYyw3UrFb5HeXChEjHCGnf7Oh1kkrFFYcJTwl06iDr4NahUFAF5szfqvgl8mwbDH1ZUAZ8FtUl01tapncLcO+opIfUIHsS5pkfJERVtfNUtgPK2uKQrTkD1pnj3GAaXfDveHVuIhOfJtgRmVLOllanrCxbWqqGsB2V6hTMXxfj2XT11H+eDsaj4eremU1WrtOfz0cO8GyAwfFvnPx95+EFKaE5euVRmMCmoDfxEsAtzfg7YZafkP3dhrJs7VtX3ZvOtQa0lupSSJoRiHUweVzMEEJvDKj0kEfqilorFuUmxBEXhKknBzJQVQP7I6GBEZGQb4UkaQpjYUjiRxB3e2bvWPb1nmcdXB0UASg3RTmq5MHv7uIv98/xcXP8016Z2icQlOoP")))'
After (line continuations added manually)
The base64 blob (first stage), context label, and preamble length are seperate argv items.
ssh -o LogLevel ERROR -o Compression yes -o ServerAliveInterval 15 -o ServerAliveCountMax 3 -o BatchMode yes -o StrictHostKeyChecking yes foo \
python -c \
'import sys;sys.path=[p for p in sys.path if p];import binascii,os,zlib;exec(zlib.decompress(binascii.a2b_base64(sys.argv[1]),-15))' \
pZJdS8MwGIXv+yu8GW/CSpd2F2KhF2ObTnAflGmRWUY/0hnckpK0q/PXm7IxW0URvcvDOXlP3nB8M/CEsnKWU4QNaVYNYtmFhkzIF4Rdoz6nZe4gYtqE4A/2zSZJrdpHTrZCUeQ3QTYhaEKl4RhY8min41ck7DbICVeuE3bVQVn0lSZlEcVb6nkwimTFuH3VK5XsxYz38kPxLDi4bWfXA8e6hF9n7KlUTPCV2w/PIQ6pR7j6AuV7JrUKi8flZD5b3w3uZ8PJeLS+9ufTdeAPFouxD6EH9j8T7T8lNv0D/+aBaKH9HUePxi1qC+anbwO0Y4XYUO52FIZOrUZys9cPx4YeUUlWUGSbML1dzgkhTxx0dCJSvRw2srpMWSpyynVrQMaAjaH3tmWxldJE7HJJlUKZJWmUIsYLdB7fD3F9/9SN9qTAhCqGunTZKX/4nbX62fp1Abu9wLmdDn4H \
alex@kintha:58688 \
18191
The old arrangemet was 798 bytes, as measured by preamble_size.py, compression tweaks and code golfing dropped that to approx 786 bytes. The new arrangement is 822 bytes, including compression tweaks and golfing.
Benefits of the new arrangement are
- static first stage
- transparency - the scary base64 blob can be reversed once, analysed once, subjected to much tighter filtering or allow listing
- less magic - no 'constants' that are actually string labels replaced at runtime
- looser coupling - between the
python -c ...stage (zeroth stage) and the first stage.
Potential benefit
- speedup - the first stage doesn't have to be regenerated for each context/connection.
refs #711
env -S ... might be of use
-S, --split-string=S
process and split S into separate arguments; used to pass multiple arguments on shebang lines
-- https://manpages.debian.org/trixie/coreutils/env.1.en.html