#!/bin/rc # passmenu - a shitty password manager # usage: passmenu [-n] # requires: # - dmenu (https://shithub.us/josuah/dmenu/HEAD/info.html) # or # - fm (https://shithub.us/phil9/fm/HEAD/info.html) # - properly configured secstore(1) (http://fqa.9front.org/fqa7.html#7.4.3) # - tab-separated password file in the following format: # # dom=example.com user=yourname pass=secret # # bugs: # - now why would I do a thing like that? rfork en ramfs -p && cd /tmp cmd=(/bin/dmenu -p 'Select domain ') #cmd=(/bin/fm -p) file=pass ifs=' ' n=no s=9 t=/tmp/passmenu.$pid fn fin{ {echo buffer clears in $s^s; sleep 5} | aux/statusmsg 'password snarfed' & {sleep $s; echo -n >/dev/snarf}& exit '' } fn sighup sigint sigterm{ echo -n >/dev/snarf exit quit } fn usage{ >[1=2] echo 'usage: passmenu [-n]' exit usage } if(! test -x $cmd(1)){ >[1=2] echo this script requires dmenu or fm exit no.menu } while(~ $1 -*){ switch($1){ case -n n=yes shift case * usage } } if(~ $n yes) >[2=] auth/secstore -n -G $file >$t if not >[2=] auth/secstore -G $file >$t sel=(`{sed -e '/^#/d;/^$/d' $t |\ awk -F' ' '{ x=$0; y=$0; sub(/.*dom=/, "", x); sub(/.*user=/, "", y); sub(/ .*/, "", x); sub(/ .*/, "", y); printf "%s (%s)\n", x, y; }' | $cmd | tr -d '()'}) if(~ $sel '') exit quit grep -e $sel(1) $t |\ grep -e $sel(2) |\ awk -F' ' 'NR==1{ z=$0; sub(/.*pass=/, "", z); sub(/ .*/, "", z); printf "%s", z; }' >/dev/snarf fin