broke out ssh-askpass-style prompting (to feed to gpg); implemented first pass at...
[monkeysphere.git] / src / common
index 9d7deb7c6251c7ab989f53b49e29fc6e69b6971d..6a620807c3535450d5f539c9575c52376b442efa 100644 (file)
@@ -105,6 +105,21 @@ EOF
     echo "$keyExpire"
 }
 
+passphrase_prompt() {
+    local prompt="$1"
+    local fifo="$2"
+    local PASS
+
+    if [ "$DISPLAY" ] && which "${SSH_ASKPASS:-ssh-askpass}" >/dev/null; then
+       "${SSH_ASKPASS:-ssh-askpass}" "$prompt" > "$fifo"
+    else
+       read -s -p "$prompt" PASS
+       # Uses the builtin echo, so should not put the passphrase into
+       # the process table.  I think. --dkg
+       echo "$PASS" > "$fifo"
+    fi
+}
+
 # remove all lines with specified string from specified file
 remove_line() {
     local file