[fpc-pascal] Help getting Lazarus app in Ubuntu to elevate to root and back again

Andrew Brunner andrew.t.brunner at gmail.com
Fri Oct 8 18:27:20 CEST 2010


I'm needing help to take my Lazarus app, elevate process to root
(using GUI prompt like GKSU) and I want to drop back down to the
user's level after port binding and listening.

Ubuntu has port restrictions for low port numbers.  I'm developing a
platform that happens to use ports for HTTP, XMPP, etc.  Unfortunately
I find myself running Lazarus as root and that is messing up my units
as they are saved.

I need Lazarus to run my app with debugger, and have the desktop
system ask me for my password, attach that elevated id by way of that
security mechanism to my debugged app, so I can execute my Bind and
Listen socket calls, then detach/remove that elevated status to
normal.

Anyone with code to do this very thing?  I this to be cross-platform
so ppl with KDE instead of Gnome need to be considered.
Example Code:
procedure DebugServices;
begin
   ElevateToRootStatus; // << Gets Ubuntu to prompt for Desktop system
to elevate CurrentProcess
   StartServices;
   DropRootStatus;
end;

Under normal circumstances I could just launch gksu in front of my
app.  But I'm under Lazarus with debugger so I need this badly.

Developing ElevateToRootStatus and DropRootStatus is totally unknown
how to do this.

Any help would be greatly appreciated.



More information about the fpc-pascal mailing list