Is there something between a regular user account and a root?

I am developing an application that manages network interfaces on behalf of the user, and accesses several external programs (for example, ifconfig) that require changes to the root. (In particular, changing the IP address of the local interface, etc.). During development, I ran the IDE with root (ugh) rights and a debugger with root privileges (double-ough). Is there a good way for the end user to run them under an unauthorized account? I strongly dislike the attack surface size represented by GTK, wxPython, Python and my application when it runs as root.

I explored the possibilities, but they look half-wrapped, and I'm not sure if I can use them in Python, especially if they are streaming. The only option I have not studied is a daemon that set the setuid bit and performs all the functions of the root type on behalf of the user interface. I hesitate to introduce this complexity at an early stage of the project, since working with root privileges is not a gap for users.

+3
source share
7 answers

Your idea of ​​a demon has many virtues, despite the complexity that it introduces. Until actions require interaction with the user interface as root, the daemon allows you to control which operations are allowed and prohibited.

SUDO ROOT ... SUDO , . , "" .

+7

, ""

, , , , , , , , .

, , , , , .

( , , , su , . )

+3

selinux . Selinux . selinux, - .

+1

, setuid root setuid id, root, - sudo . , , , setuid ( ) sudo, , .

, , sudo .

, Unix, , sudo, ( API), fallback, setuid root , .

[EDIT] , sudo NOPASSWD, , , .

+1

setuid, , . , , , setuid ( , ).

( root, ), . , , IPC ( d-bus, , , ).

, , , , , . - , ( ), , , , .

+1

, "" root. root, ; . - , "" , , root, , , .

0

Python, , , , . - :

  • root sudo suid
  • .
  • , ,
  • root ( uid , ), , , -
  • , root, ( root) (root), , , ,

Most likely, it will be a little easier to write than an independent daemon, and also more convenient to run (since you do not need to worry about whether the daemon works or not), and also allows you to use the graphical interface and other things that do not need permissions root, which will run as non-root.

0
source

Source: https://habr.com/ru/post/1698903/


All Articles