Skip to content

Instantly share code, notes, and snippets.

@jordanwade90
Created April 30, 2014 02:08
Show Gist options
  • Save jordanwade90/26e97edaf40c85c5869a to your computer and use it in GitHub Desktop.
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.
#!/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