문제

I want to create "my own" sudo command (for my file manager/commander written in C++/OpenGL). Please help provide necessary steps and things to consider. I know it has something to do with suid bit, but that's all I know so far.

도움이 되었습니까?

해결책

It's all about filesystem flags, and you only to ensure that:

  1. The executable file does belongs to root

  2. It has the suid flag in the file system (you can set it with chattr u+s).

After you'll do that, it will be executed with root permissions even when running from a regular user.

Please also note that you can get an UID which had actually ran the program by calling getuid(), while geteuid() will always evaluate to 0.

다른 팁

I suggest to you to download sudo command code and modify it based on your requirement

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top