0

I have an unusual request. I need to put a password on an app but I need the app to run at the user level (not Sudo or SU). Is there an easy way to do this?

Rinzwind
  • 299,756

2 Answers2

0

You could do that with a simple bash script and Zenity. As stated, this shouldn't be used unless you don't care about security.

#!/bin/sh

#Create the Zenity Window and show it
OUTPUT=$(zenity --password "Password")

#Compare the user input with your hardcoded password
if [ "$OUTPUT" = "abc1234" ]
then
    #Command to launch the application from the CLI. Replace with your own command
    /usr/bin/nautilus
else
    #Throw an error
    zenity --error --text "Password incorrect. Terminating"
fi

Save this to a .sh file, give it +x permissions and you are ready to go, just replace the command accordingly.

muru
  • 197,895
  • 55
  • 485
  • 740
  • It doesnt work for me, I keep getting an error "This option is not available. Please see --help for all possible usages." The error is referring to the --password operator for Zenity – Kyle Thompson Jan 27 '16 at 15:33
  • Hmm? Strange... what happens if you input 'zenity --password "Password"' in a Terminal Window? – Eduardo López Jan 27 '16 at 16:56
  • Same Error This option is not available. Please see --help for all possible usages And --password is not listed under the help menu for zenity either – Kyle Thompson Jan 27 '16 at 17:24
0

I figured it out, I got it to ask for the password of a user I created called "admin" which is the system administrator. I have set the "user" account to be only a desktop user and not an administrator.

1) I changed the menu entry to say gksu -w -u admin /home/admin/bin/menu.sh (Where I put the script)

2) In the menu.sh script gksu -u user /usr/bin/alacarte

3) When executed, it asks for admin's password and then from there it runs the program as user under the higher admin user.

Normally this would not be a problem, but when alacarte (Menu Editor) is run as admin or root. It edits the menu of admin or root and not the current user which is a little pointless

This sounds really convoluted for a minor problem, and I am sure there is a simpler way to do this. I am relatively new to this sort of thing. Let me know if there is an easier way to do this.

Thanks,

Kyle T.