I am writing a simple package manager and I would like to try sudo automatically if the program does not start as root. I found a function called seteuid that looks the way I need it, but I don’t have permission to run it. For now, all I can think of is a bash script to check before they get into the actual binary, but I would like to do it all like C ++, if possible.
Is there any method to change the euid process after it starts? Or a way to call sudo?
As bmargulies says in his answer , you can do this if the binary belongs to root and the setuid bit is set, but then you will need to implement the authentication part (checking that the user is really allowed to root) too.
Essentially, you are rewriting sudoin your application - the best way to handle this is to do what you have proposed and install the application using a script wrapper that uses /usr/bin/idroot to check, and if not, call sudo(or su).
sudo
/usr/bin/id
su
Here's how these features work.
setuid, . , seteuid , . Ditty setgid.
. , , . , setuid, , , , .
sudo (, , fork/exec). , sudo, setuid, , .
Source: https://habr.com/ru/post/1738426/More articles:Kernel panic when changing system_call in entry.S - linuxКакова лучшая книга XNA, которая может научить вас программированию 2d и 3d игр от базового до продвинутого? - c#MySQL: counting rows by field - sqlDistance from the marine calculator, intermediate coordinates? - pythonAutomate gdb: show backtrace every 10 ms - profilingОбъединение документов Word (Office Interop &.NET), сохранение форматирования - vb.netHow to use links, avoid heading bloat and delay initialization? - c ++Как избежать повторного рисования всех представлений в ArrayAdapter - androidTreebeard Administrator in Django - djangoGood practice writing HTML with StringBuilder in my ASP.NET Codebehind code? - stringbuilderAll Articles