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?
2 Answers
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.
- 207,228
- 1,074
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.