Results 1 to 6 of 6

Thread: Running an application with root privileges at Linux

  1. #1
    Join Date
    Jan 2009
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11

    Arrow Running an application with root privileges at Linux

    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.

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Running an application with root privileges at Linux

    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.

  3. #3
    Join Date
    Jan 2009
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Running an application with root privileges at Linux

    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.
    Last edited by prykHetQuo; 25th January 2009 at 02:38.

  4. #4
    Join Date
    Nov 2008
    Posts
    142
    Thanks
    3
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Running an application with root privileges at Linux

    Try "sudo" then.

  5. #5
    Join Date
    Jan 2009
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Running an application with root privileges at Linux

    sudo does not work by default, in some Linux distributions too, like Fedora 10, where su works.

  6. #6
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Running an application with root privileges at Linux

    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!

Similar Threads

  1. Installing and running Qt4 without root privileges
    By sunil.thaha in forum Installation and Deployment
    Replies: 1
    Last Post: 10th October 2007, 15:04
  2. Using exec in the qt/embedded application.
    By sar_van81 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 23rd August 2007, 13:52
  3. Qt 4.2.2 and SuSE Linux 9.3
    By Teuniz in forum Installation and Deployment
    Replies: 15
    Last Post: 26th February 2007, 13:21

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.