View Full Version : how to run QT application with root permission

noa l
15th December 2010, 12:24

My QT aplication (Qt4) needs root permisions. I'm not sure if I do it right, since I'm new to Linux... and I'm getting an error

Assume my executable is called MyApp I did the following:

chown root:root MyApp
chmod ug+s MyApp

When i tried to run MyApp from my user without root permissions, Instead of being asked to enter password, i got the following:

In one machine i got this waring but the application run..:

This process is currently running setuid or setgid.
GTK+ does not allow this therefore Qt cannot use the GTK+ integration.
Try launching your app using 'gksudo', 'kdesudo' or a similar tool.

in a second machine i got this error and MyApp does not run

GLib-GIO: ERROR:/build/buildd/glib2.0-2.26.0/gio/gdbusconnection.c:2270:initable_init: assertion failed: (connection->initialization_error == NULL)

What am i doing wrong? how should i solve this? Please be noted that my trial MyApp application looks like that:

QApplication a(argc, argv);
Widget w; // inherit from QWidget -this is the basic template that QtCreator creates...with nothing additional
return a.exec();

15th December 2010, 13:18
go to terminal and type
sudo ./MyApp

noa l
15th December 2010, 13:40
thanks , i thought maybe to gain the permissions programaticaly.. but maybe the simplest way will be enough to my needs..

15th December 2010, 14:30
You can gain the permissions programatically if you want, but I'm not sure if Gnome/KDE use the same authentication methods, and if your not using either it would involve learning PAM.

Therefore, the simplest solution is usually the best.

noa l
15th December 2010, 14:32
looks as the simple way is enough for my needs - thanks :-)