Created
April 30, 2014 02:08
-
-
Save jordanwade90/26e97edaf40c85c5869a to your computer and use it in GitHub Desktop.
Gets a username and password from factotum and prints it to the terminal. I use this to grab website passwords since Chromium doesn’t talk to factotum.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/lib/plan9/bin/rc | |
if(! ~ $#* 1){ | |
echo usage: $0 domain >/dev/stderr | |
echo Gets a username and password from factotum. $0 prints '''ok username password''' if a key matching '''role=client proto=pass dom=DOMAIN user? !password?''' is known to factotum or if factotum can prompt for a key. | fmt >/dev/stderr | |
exit usage | |
} | |
tmp=`{mktemp -d --tmpdir getpw.XXXXXXXXXX} | |
f=$tmp/fifo | |
mkfifo -m 600 $f | |
{{echo start 'role=client' 'proto=pass' 'dom='^$1 'user?' '!password?'; awk -F ' ' '/done/{exit} /ok/{print "read"; fflush(); if(length($2) > 0) print $0 >"/dev/stderr"} /needkey/{print $0 >"/dev/stderr"; exit $0}' <$f} | 9p rdwr factotum/rpc >[2]/dev/null >$f} >[2=1] | |
rm $f | |
rmdir $tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment