Advertisement
josephj11

bash GUI Get Password script for use with sudo -A

Aug 28th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.54 KB | None | 0 0
  1. #!/bin/bash
  2. ## getpass copyleft 08/21/2018 Joseph Pollock - JPmicrosystems
  3. ## Last modified 08/21/2018
  4. ## Used with sudo -A
  5. ## Usage:
  6. ##  export SUDO_ASKPASS=/usr/local/bin/getpass
  7. ##  export SUDO_ASKPASS_TITLE="Dialog Title" ## optional
  8. ##  export SUDO_ASKPASS_PROMPT="Prompt Phrase" ## optional
  9. ##  sudo -A foo
  10.  
  11. prompt=""
  12. [[ -n "$SUDO_ASKPASS_PROMPT" ]] && prompt="$SUDO_ASKPASS_PROMPT"
  13. [[ -n "$SUDO_ASKPASS_TITLE" ]] && kdialog --title "$SUDO_ASKPASS_TITLE" --password "$prompt"
  14. [[ -z "$SUDO_ASKPASS_TITLE" ]] && kdialog --password "$prompt"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement