View Full Version : Running an application with root privileges at Linux
prykHetQuo
24th January 2009, 19:35
Is there any standard way (that applies to all Linux distributions), a GUI application (X.Org/Gnome/KDE) to ask for the root password so as to execute with root privileges?
Software examples that do this:
Synaptic at Ubuntu.
Yumex at Fedora.
I am writing a free and open source program (http://www.cpp-software.net/software.html), and I call Ubuntu's "gksudo" from within the program, but I prefer a portable way, that applies to all Linux with X.Org distributions.
Thanks.
boudie
24th January 2009, 20:52
As far as I know, on KDE you have kdesu and under Gnome you have gksudo.
At program start you could check which one is available.
To be 100% portable you have to implement it yourself.
I think you could do that by asking in a form for the root password. After that you start your own subprocess using QProcess and do something like:
su <process_needing_root_access>
Read the QProcess docs to learn how to cummunicate with the subprocess so you can enter the root password to satisfy the su-command.
prykHetQuo
24th January 2009, 23:22
Thanks for your reply.
However "su" does not work in Ubuntu.
Edit: And gksudo does not exist in Fedora 10, with GNOME installed as the default window manager.
rexi
24th January 2009, 23:35
Try "sudo" then.
prykHetQuo
25th January 2009, 01:36
sudo does not work by default, in some Linux distributions too, like Fedora 10, where su works.
boudie
25th January 2009, 12:35
sudo is a more or less standard Linux tool, so it should be configurable on every Linux-box. When it isn't, then maybe the environment is not worth writing software for at all...?;)
Anyway, your problem has been reduced to something that is not a Qt-problem.
Maybe you should try distro-specific forums?
But be sure to post your solution here, too! :D
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.