I want to limit access to running apps with a password. Is that possible? I have an app in the tray icon and I want to close it for unauthorized access.
Greetings
I want to limit access to running apps with a password. Is that possible? I have an app in the tray icon and I want to close it for unauthorized access.
Greetings
The following setup is fit for "home, garden and kitchen" use, when no specific security is needed. I also need to say that it is still possible to open the application via the command line; it is strictly for "indoor" use, to prevent children to acces an application for example.
The trick is to redirect the command in the application's desktop file to a script that calls the application, provided that the right password is given.The setup can be undone easily.
Below are two scripts, one to call the window to enter the password (script1), and one to process the given password (script2).
Prepare the scripts:
script1, call the zenity window to enter the password:
#!/bin/sh
if zenity --entry \
--title="Restricted!" \
--text="Enter your _password:" \
--entry-text "password" \
--hide-text
then echo $?
else echo "No password entered"
fi
Copy the text above, paste it in an empty document, save it in ~/
as "passwordwindow", and make it executable.
script2 to process the given password:
#!/usr/bin/python3
import subprocess
# application_name = the command to start the application:
application_name = "application_name"
# enter the required password here:
password = "password"
# enter the path to script1 here (for example ~/passwordwindow):
path_to_script1 = "path_to_script1"
getpassword = subprocess.Popen([path_to_script1], stdout=subprocess.PIPE)
passwordinput = getpassword.communicate()[0].decode("utf-8").replace("\n0\n", "")
if passwordinput == password:
subprocess.call([application_name])
else:
pass
Copy the text above, paste it in an empty document and replace the following entries in the headsection of the script:
/usr/share/applications
, with gedit and copy what comes after "Exec=".include the quotations.
Save the file (hidden) as .myownpassword.py in ~/
Prepare the .desktop file:
To finish the setup:
/usr/share/applications to
~/.local/share/applications`python3 /path_to_script2/.myownpassword.py
(no quotation)Now, after next log out / login, if you start the application, you will be asked for your password, as defined in script2:
How to remove:
To undo the setup, just remove the local desktop file in /.local/share/applications
and the two scripts in your ~/
directory.
What kind of unauthorized persons are allowed to use your user account? I would recommend to create various user accounts for the persons with access to the computer. You can then use file permissions to restrict access to certain parts of the system, for example let only members of the group "technicians" execute the program "skype".
It is not secure to let persons you don't trust access your personal user account.