Results 1 to 5 of 5

Thread: how to run QT application with root permission

  1. #1
    Join Date
    Dec 2010
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question how to run QT application with root permission

    Hi

    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
    w.show();
    return a.exec();

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to run QT application with root permission

    go to terminal and type
    sudo ./MyApp

  3. #3
    Join Date
    Dec 2010
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to run QT application with root permission

    thanks , i thought maybe to gain the permissions programaticaly.. but maybe the simplest way will be enough to my needs..

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to run QT application with root permission

    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.

  5. #5
    Join Date
    Dec 2010
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to run QT application with root permission

    looks as the simple way is enough for my needs - thanks :-)

Similar Threads

  1. Problem to run a Qt Gui application as root
    By holmfred in forum Newbie
    Replies: 3
    Last Post: 23rd October 2010, 14:07
  2. Permission denied
    By lixo1 in forum Qt Tools
    Replies: 4
    Last Post: 27th March 2009, 09:01
  3. Running an application with root privileges at Linux
    By prykHetQuo in forum Qt Programming
    Replies: 5
    Last Post: 25th January 2009, 12:35
  4. exe permission denied
    By phillip_Qt in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2007, 07:47
  5. root-priviliges in application
    By bkv in forum KDE Forum
    Replies: 2
    Last Post: 29th October 2006, 18:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.