Python Forum
running py3 scripts as root
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
running py3 scripts as root
#1
i have a few scripts, all in Python3, that i want to be able to run with root effective uid permissions.

i am still pondering how to go about doing this. my current thinking is to use a C program to verify user rights and run the actual script with root euid enabled if appropriate. of absolute importance is not to open a means for any user to be able to run unauthorized scripts/programs of their choice or their ways with any form of escalated privilege. that C program would be where root privilege is acquired. it would then consult a configuration file to verify that user is permitted to do what is requested. i am wondering if it is safe for that C program to just run a Python3 script to do the verification logic. normally, making a script euid root is unsafe since the hash-bang method with an interpreter is unsafe since it is possible to substitutes the script name an escalated interpreter gets. if a C program has a hard-coded path for the interpreter and script, then it is up to the C program to do it right. that much is simple to do. so my next question is: how safe is it to run the correct Python script via the correct interpreter, with euid root privileges?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Skaperen Wrote:that C program would be where root privilege is acquired.
How would root privilege be acquired?
Reply
#3
the C program executable would be set to run euid as the owner of the file, and be owned by root. being a binary, there is no opportunity to substitute a different script before the interpreter opens it.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
Changing file permitions, sudoers?
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
my look at this is broader that how root privileges are acquired.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Running two consecutive scripts in VSCode Larz60+ 6 3,897 Mar-11-2019, 12:20 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020