[Lazarus] root privileg

Michael Van Canneyt michael at freepascal.org
Wed Jun 4 16:54:06 CEST 2014



On Wed, 4 Jun 2014, A. Fortuny wrote:

> Hi Folks.
>
> How to gain temporarily root privileges in a pascal program ?
> I need to 'ping' an IP address and for ping to work (Indy 10) I need to be 
> root.
> Usage of another TCP component is not an option.
> Another way is to execute a shell and intertpret the results but I'd to avoid 
> it if possible.
> It is on Linux system.

You can't do this. Strictly forbidden.

The usual way to do this is to make the program setuid root, do the ping, and then setuid() to some normal user ASAP.

If you need to do it at regular intervals, then you must execute a separate program.

Michael.




More information about the Lazarus mailing list