Prompt for root password

Michael P. Soulier msoulier at
Fri Jan 6 18:09:59 PST 2006

On 1/6/06, JD Arnold <jdarnold at> wrote:
> I'm writing a program that needs to write a file and I'd like to have it
> ask for the root password and run as root, like many of the system config
> applications do.  Do I have to write something special, or is there some
> way to tell KDE (or GNOME) to prompt for the root password? Is this what
> a "setuid" program is?

If it's a graphical program, you can call the gksudo command from
gnome. Or, if you look in its sourcecode, you can find out how it
works and integrate the same into your program.

Michael P. Soulier <msoulier at>
"Any intelligent fool can make things bigger and more complex... It takes a
touch of genius - and a lot of courage to move in the opposite direction."
--Albert Einstein

More information about the freebsd-questions mailing list