I have two users. admin can see everything. pi is restricted.

I have a tkinter python application. pi must be able to run the program, but it cannot read any of the files directly. There is a data.json file that the application needs, but I don't want the user cheating by peaking at the file directly.

I added the following line to visudo: pi ALL=(admin) NOPASSWD: /home/admin/myapp/main.py If I understand correctly, this will allow pi to switch to admin just when trying to run the python app.

Then I made a script runapp.sh with the line: `gksudo -u admin python3 /home/admin/myapp/main.py

I run the script as pi and nothing happens. Even when I run it from the terminal, there are no errors, but the app does not appear. Before, I tried using just sudo instead of gksudo and got the error _tkinter.TclError: couldn't connect to display ":0", so I know it is at least trying to execute the python code.

What do I need to change to get this working?

  • 2
    Linux scripts (including Python) have limited privilege escalation. What you want is not possible. This is not a Pi specific question. – Milliways Jan 24 '19 at 0:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.