12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!/bin/sh
- #Barry Kauler 2011, GPL3 (/usr/share/doc/legal)
- #specified in /etc/sudoers or /etc/sudo.conf, gui-helper for sudo. (path compiled-in to my sudo PET)
- #110513 display name of app that is requesting to run.
- #120201 rodin.s: internationalized.
- export TEXTDOMAIN=askpass
- export OUTPUT_CHARSET=UTF-8
- PSALL="`ps`"
- CALLEDAPP="`echo "$PSALL" | grep -o ' sudo \-A .*' | tr -s ' ' | cut -f 4 -d ' '`"
- if [ "$CALLEDAPP" ];then
- INSERTMSG=" <text><label>$(gettext 'This application wants to run:')</label></text>
- <text><label>${CALLEDAPP}</label></text>
- <text><label>$(gettext 'The administrator password is required:')</label></text>
- "
- else
- INSERTMSG="<text><label>$(gettext 'Please enter the administrator password required to run this application:')</label></text>"
- fi
- if [ $DISPLAY ];then
- export ASKDIALOG="
- <window title=\"AskPass\" decorated=\"false\" window_position=\"1\" skip_taskbar_hint=\"true\">
- <vbox>
- <frame>
- ${INSERTMSG}
- <entry visible_char=\"x\" visibility=\"false\" width_chars=\"25\" activates_default=\"true\">
- <variable>ADMINPASSWORD</variable>
- </entry>
- <hbox>
- <button use-stock=\"true\" label=\"gtk-ok\" can-default=\"true\" has-default=\"true\"></button>
- </hbox>
- </frame>
- </vbox>
- </window>
- "
- RETVAL="`gtkdialog --program=ASKDIALOG 2>/dev/null | grep '^ADMINPASSWORD='`"
- #eval "$RETVAL"
- ADMINPASSWORD="`echo "$RETVAL" | cut -f2- -d '"' | rev | cut -f2- -d '"' | rev`"
- else
- echo >/dev/console
- echo -n "$(gettext 'Type admin password required to run this app:') " >/dev/console
- read -t 30 ADMINPASSWORD
- [ "$ADMINPASSWORD" = "" ] && echo '...failed' >/dev/console
- fi
- #echo "$RETVAL"
- echo "$ADMINPASSWORD" #return password to sudo.
- ###END###
|