#!/usr/bin/awk -f # see himitsu-prompter(5) for protocol details BEGIN { _cmd = ENVIRON["HIMENU_MENUCMD"] if (!_cmd) _cmd = "wmenu" passmenu_cmd = _cmd " -P -p" menu_cmd = _cmd " -p" notify_cmd = ENVIRON["HIMENU_NOTIFCMD"] if (!notify_cmd) notify_cmd = "notify-send -t 20000" } $1 == "version" { write("version 0.0.2") } $1 == "key" { keys[ki++] = $0 } $1 == "query" { queries[qi++] = $0 } $1 == "remember" { remember_opts[ri++] = $0 } $1 == "unlock" { prompt_unlock("enter password") } $1 == "update" { update_query = $0 } $1 == "password" { if ($2 == "incorrect") { unlock_attempts++ msg("wrong password ("unlock_attempts"/3)") prompt_unlock("try again") # try unlocking again if (unlock_attempts == 3) exit 127 } else { msg("keystore unlocked") unlock_attempts = 0 } } $1 == "prompt" { if ($2 == "disclose") { msg("disclose request", keys, ki) prompt_yesno("disclose keys to client?") } else if ($2 == "delete") { msg("delete request", keys, ki) prompt_yesno("remove keys from keystore?", key) } else if ($2 == "persist") { msg("persistence request", queries, qi) prompt_remember("remember query?") } else if ($2 == "update") { msg("update request", keys, ki) msg(update_query) prompt_yesno("update entries?") } } function cmd(c, s){ if (s) s = "himitsu: " s c " '" s "'"| getline r close(c " '" s "'") if (!r) exit 127 else return r } function write(s){ print s fflush() } function msg(title, lines, n){ title = " 'himitsu: "title"'" for (i=0; i