Question

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.

Était-ce utile?

La solution

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.

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top