Skip to content

Instantly share code, notes, and snippets.

@zozs
Created March 7, 2020 12:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zozs/4a4ef1fc4b7e027f89daa8168c838de6 to your computer and use it in GitHub Desktop.
Save zozs/4a4ef1fc4b7e027f89daa8168c838de6 to your computer and use it in GitHub Desktop.
Simplest credential manager you can think of :)
#!/bin/sh
set -e
# path of fifo, must be unique for this instance.
# so if you want several daemons running you need to fix this.
FIFO_PATH=/tmp/credmanager.sock
# read passphrase from user and store in var
echo -n "Enter passphrase: "
read -r passphrase
echo "Passphrase stored. Daemon ready."
# repeat passphrase infinity times to named pipe
while true; do
# create fifo
rm -f "${FIFO_PATH}"
mkfifo -m 600 "${FIFO_PATH}"
# actually write passphrase to pipe
echo "${passphrase}" > "${FIFO_PATH}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment