How to programaticaly gain root privileges ?
Posted
by ereOn
on Stack Overflow
See other posts from Stack Overflow
or by ereOn
Published on 2010-03-20T16:12:07Z
Indexed on
2010/03/20
16:21 UTC
Read the original article
Hit count: 273
I am writing a software (in C++, for Linux/Mac OSX) which runs as a non-privileged user and but needs root privileges at some point (to create a new virtual device).
Running this program as root is not a option (mainly for security issues) and I need to know the identity (uid) of the "real" user.
Is there a way to mimic the "sudo" command behavior (ask for user password) to temporarily gain root privileges and perform the particular task ? If so, which functions would I use ?
Thank you very much for your help !
© Stack Overflow or respective owner