Results 1 to 14 of 14

Thread: QProcess Shell Command (Linux) Elevate Privileges?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QProcess Shell Command (Linux) Elevate Privileges?

    Quote Originally Posted by anda_skoa View Post
    If an installer checks for root priviledges I take this as a sign that its author has very little clue about file system permissions and therefore it should defnitely not be allowed to execute with elevated permissions.
    Maybe I was not clear enough -- what I meant was that if the installer can't work without additional privileges, then run it with sudo (it doesn't even have to be sudo root). If I ever suggested that the installer should force to be run with superuser privileges then that's not what I really meant -- it can check and warn the user but if he knows better, the installer can continue.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Dec 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    14

    Default Re: QProcess Shell Command (Linux) Elevate Privileges?

    Wysota and Anda,

    I actually missed that line of anda_skoa. But I also seem to miss his point, so maybe this will clear it a bit more: Linux has become more "user" friendly, and more people tend to give it a try. Them users are no wiz-people, and many come from a Windows, or Mac environment - which basically means that they will spend a lot of money for guys like us to fix things that happen under the 'hood' - cuz they have no clue, and they don't want to know. I have seen folks return to WIndows because they feel that tagging .debs into executables, or using any package manager, or apt-get install commands is just a little too much for them.

    Clicking on setup from their GUI is what they recognize, and they expect a certain behavior from the setup.
    I intend to satisfy most of those expectations, but cannot set symlinks in $HOME/Desktop/ pointing to /usr/share/icons/<icon-size>/apps directory without elevating permissions. I can also not save a desktop.entry file in /usr/shar/applications/ without ditto elevation. Once files have been installed as superuser, I reset file permissions to local user with standard priviliges (don't forget my target audience is not Linux savvy - and doesn't know that files saved as superuser will have READ/WRITE/EXEC as superuser - which basically renders my program useless because they can't exec it with their credentials. I think that and 26 years of IT experience counts for knowing about file system permissions.

    I agree - until I have found a better way, with Wysota: there is no alternative available (covering most Distro's) without creating a security hole and a lot of programming overhead. So asking my target audience (non-linux-geeks) to elevate their privileges and protecting that user from installing files in places other than to which he himself has READ/WRITE permission is momentarily the best I can do. Unless you can suggest a better way...?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QProcess Shell Command (Linux) Elevate Privileges?

    Have a script that will call kdesudo, gtksudo or whateverelsesudo and tell it to launch your new installer. If your user is experienced, he can launch the installer directly using options of his own choosing. Other lusers can just doubleclick the script icon, type in the password and sit back while the installer does the rest.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Dec 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    14

    Default Re: QProcess Shell Command (Linux) Elevate Privileges?

    Hmmm I thought of that too, the main problem with this approach is that Fedora and CentOs have no sudo installed (OpenSuse, Ubuntu and (K)Ubuntu do) as a standard so I need to use su - in general. For Debian alike only KDE/Gnome support kdesudo and gksudo, but not all of them. On Ubuntu for example su - won't work at all, since that needs the root password and root is a disabled account. So I'd need to use sudo su- or the GUI gksudo/kdesudo. Either way I must see into preventing the Home directory from being set to root (with su- or sudo) and I need to copy the .Xauthority to a temporary place else the work environment becomes root (as it does now). I am running out of scope with making a Linux/Win Installer and was wondering if there are any alternatives? As for now it looks like making an RPM/DEB file is the only way or suffer a blow when using QProcess.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QProcess Shell Command (Linux) Elevate Privileges?

    but cannot set symlinks in $HOME/Desktop/ pointing to /usr/share/icons/<icon-size>/apps directory without elevating permissions
    If the user's home directory is not writeable to the user then it seems you have larger problems to deal with.

    Is the point of this entire exercise to allow random user A to install the software on the system for use by all users or just themselves?

    If this is meant to be a user-only install then there should be no need for elevated privileges. Install in a user-writeable area, put a *.desktop file into .local/share/applications and you should be done.

    If the software is to be installed system wide then (IMHO) far and away the best packaging option is the native one for the relevant system. Then the user, who is familiar with their own system, can use the system's familiar tools to install and uninstall your software. Of course, this imposes a work load on you if you want to do this for half a dozen different packaging schemes. There's no way around requiring elevated rights to install system-wide and no way to accommodate every variation on a theme.

  6. The following user says thank you to ChrisW67 for this useful post:

    m3rlin (7th April 2013)

  7. #6
    Join Date
    Dec 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    14

    Default Re: QProcess Shell Command (Linux) Elevate Privileges?

    @ChrisW67, no the problem is with the system wide install, by random user X, installing my program for anyone.

    I am considering (I might not have a choice) not installing my program as a system wide application, to avoid all the mess as you mentioned. What remains on the table is the HOW TO elevate user privileges on Linux Distro's in a proper manner using a GUI with QProcess. It has degraded from must implement to the "I MUST KNOW HOW" feeling. So I cross-posted my question on a Linux Forum where they suggested I'd write a make script to handle elevations for the worker process (B) - leaving the GUI out of it. But that defies the purpose of my installer. I will find out how to do this eventually. In the mean time I thank you all for supporting this topic.

  8. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: QProcess Shell Command (Linux) Elevate Privileges?

    Quote Originally Posted by m3rlin View Post
    Clicking on setup from their GUI is what they recognize, and they expect a certain behavior from the setup.
    Sure, nothing wrong with that. However, most installers on Windows do not elevate their priviledges themselves either, they usually also require that the user has permissions to install to a certain directory.

    Quote Originally Posted by m3rlin View Post
    I intend to satisfy most of those expectations, but cannot set symlinks in $HOME/Desktop/ pointing to /usr/share/icons/<icon-size>/apps directory without elevating permissions.
    As ChrisW67 said, if you can't write into the user's home directory then there is something seriously screwed with the user's system setup.

    Quote Originally Posted by m3rlin View Post
    I can also not save a desktop.entry file in /usr/shar/applications/ without ditto elevation.
    Of course, I would even consider that path "off-limits" to any 3rd party software installer. /usr is the path managed by the system itself. Like C:\Windows (or whatever it is on current versions).

    For that reason I actually prefer 3rd party software to come with an installer (instead of trying to have a package), because it not only allows users to install non-system wide, it allows users who are trusted by the sysadmin to install system wide in a way (e.g. /opt, /usr/local) that does not interfere with the system itself.

    Quote Originally Posted by m3rlin View Post
    Once files have been installed as superuser, I reset file permissions to local user with standard priviliges (don't forget my target audience is not Linux savvy - and doesn't know that files saved as superuser will have READ/WRITE/EXEC as superuser - which basically renders my program useless because they can't exec it with their credentials.
    Are you sure? Usually executables installed by root are owned by user root, group root (unless the mount settings override that) but are executable for all.

    Quote Originally Posted by m3rlin View Post
    So asking my target audience (non-linux-geeks) to elevate their privileges and protecting that user from installing files in places other than to which he himself has READ/WRITE permission is momentarily the best I can do. Unless you can suggest a better way...?
    Which is the same as on Windows, no? You have to right-click and "run as administrator" to be able to install into a global locations.

    Cheers,
    _

  9. The following user says thank you to anda_skoa for this useful post:

    m3rlin (7th April 2013)

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QProcess Shell Command (Linux) Elevate Privileges?

    Quote Originally Posted by anda_skoa View Post
    Are you sure? Usually executables installed by root are owned by user root, group root (unless the mount settings override that) but are executable for all.
    Yeah, executables are executed with permissions of the user executing it, not the one owning the executable unless the executable has the setuid bit set.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. The following user says thank you to wysota for this useful post:

    m3rlin (7th April 2013)

Similar Threads

  1. How to run shell command after compile finished in pro file?
    By hashb in forum Installation and Deployment
    Replies: 1
    Last Post: 11th May 2011, 15:10
  2. Replies: 2
    Last Post: 14th March 2011, 20:55
  3. Shell command from Qt 4.5.2 by QProcess
    By Rajeshsan in forum Newbie
    Replies: 5
    Last Post: 21st December 2009, 16:03
  4. QProcess & linux shell characters
    By Ti_Thom in forum Qt Programming
    Replies: 4
    Last Post: 21st December 2009, 10:01
  5. running shell command from C++ code problem
    By alex chpenst in forum Qt Programming
    Replies: 4
    Last Post: 31st July 2008, 10:41

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
  •  
Qt is a trademark of The Qt Company.