man(1)

πŸ¦‹ execute-json-from-fifo β€” the man page, but make it cute

okay bestie, so this is from the execute-json-from-fifo manual, section man(1). it's short, it's sweet, and it's lowkey one of the most powerful little scripts you'll ever meet. let's get into it πŸ’–


✨ NAME ✨

execute-json-from-fifo β€” reads a fifo stream of POSIX commands that have been serialized as JSON, and runs them. that's it. that's the whole job. and she does it flawlessly. πŸ’…


🌸 SYNOPSIS 🌸

execute-json-from-fifo FIFO

one argument, one pipe, infinite main character energy. periodt. πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

so this is a very simple script β€” and when i say simple, i mean she's not doing anything fancy, she's just doing exactly one thing extremely well. she takes commands that arrive as JSON on a given named pipe and executes them. iconic behavior, honestly.

and why would you even want that?? okay so listen:

  • it's useful when you need to create a super-privileged container that's able to run commands on the host system. like, container says jump, host says how high. 🫢
  • it's also useful when you need to give a container the ability to launch commands as a non-privileged user on the host. very demure, very mindful, very least-privilege of it. πŸ’–

to launch this script, you run:

$ execute-json-from-fifo PATH_TO_NAMED_PIPE

and then boom, you can start sending commands to the pipe. the protocol goes like this:

{"command":["echo", "some", "command"], "stdin":"path", "stdout":"path", "stderr":"path", "cwd":"path", "env":{"ENVVAR":"value"}}
⚠️ note: the protocol is newline delimited. so never include new-lines in the command objects. not even one. not even a little one. i am begging you. 😭 one sneaky \n in there and the whole vibe check fails.

and for the optional lil' extras β€” stdin, stdout, stderr, cwd and env are all optional. leave 'em out if you don't need 'em, no pressure, no judgment, she's chill like that. 🌈

last thing bestie, and this one matters: passing ["exit"] to command stops the script. that's the off switch. the girl is done, she's clocking out, she's going home. πŸšͺ✨


πŸ’œ AUTHOR πŸ’œ

Timothy Hobbs (timothy.hobbs.cz) β€” the genius behind the fifo. we stan. πŸŽ€


and that's a wrap on this execute-json-from-fifo man page, dated 09 April 2016 β€” so yeah, she's been serving since 2016 and she's still eating. ngl, timeless. mwah, bye bestie πŸ’‹πŸŒΈπŸ¦‹