LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-05-2013, 02:49 PM   #1
m3rl1n
LQ Newbie
 
Registered: Aug 2011
Posts: 7
Blog Entries: 9

Rep: Reputation: Disabled
Linux Dev Issue with Qt and Sudo to elevate privileges to superuser.


Hi,

I am running into a weird problem with Qt QProcess and I would like your advice on how to solve this. I have build a linux program installer. ( for several reasons I do not want to distribute my program using a package manager)

The installer needs to save icon files(.png) in the /usr/share/icons/hicolor/<icon-size>/apps/ folder and a desktop-entry file in /usr/share/applications. (for both folders, superuser privileges are mandatory on the main distro's)

I am developing the installer with QT 4.8 on (K)Ubuntu KDE-Desktop with kdesudo installed. I am not using kdesudo/gksudo, and neighter (ssh-)askpass function since Fedora, OpenSuse, and CentOS don't support these functions as a standard. I therefore choose to use Qt QProcess and the sudo command (re: security holes I am using QCA Libs and AES-128 for encryption/decryption of the superuser password). -- just in case you wanna slaughter me over this.

On execution in a linux terminal I am asked for the sudo password (my test account is in the sudoers file. The result is very disappointing: a KDESUDO related bug telling me that the Gui is owned by User 1000 (me) and not by Usr 0 (superuser). I found out that this has been a reported bug and it was somewhere confirmed -- not sure about this.

I am now looking into an alternative to elevate privileges using a shell and Qt Process and the sudo command. The net hasn't been very helpful. So if you have successfully elevated permissions using sudo and Qt Process, I'd love to hear about how you did this?

Thanks.

Last edited by m3rl1n; 04-05-2013 at 02:50 PM. Reason: Linux with double 'n' - just looks weird
 
Old 04-06-2013, 08:54 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Most likely the bug is that the script (being owned by someone other than root) is attempting to be run by the root (thus opening a vulnerability - specifically, a trojan attack).
 
Old 04-06-2013, 09:13 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
fedora ,CentOS/RHEL/SL use the root id of 500
with the first non root user as 501
opensuse uses 1000


fedora and cent also do not have sudo turned on by default .Opensuse dose


i would just use " su - "

but fro fedora,cent,and opensuse why not just make a rpm
 
Old 04-06-2013, 11:30 PM   #4
m3rl1n
LQ Newbie
 
Registered: Aug 2011
Posts: 7

Original Poster
Blog Entries: 9

Rep: Reputation: Disabled
different approach for launching elevation of privileges

Quote:
Originally Posted by John VV View Post
i would just use " su - "... why not just make a rpm
I need to look into a different approach for launching elevation of privileges. su - would be an option on Fedora and CentOS, but not on Ubuntu (sudo su -). And the main reason for explicitely not making an RPM/DEB/TAR is that my target audience is not Linux Savvy at all. They expect a setup with a next and a back button

The architecture of the installer is the following: Process A (pId A) collects information. pId A launches another process pId B (inheriting from pId A) to do all the work. pId B needs privileges to save icons and a desktop.entry file in the appropriate files (folders). So I am looking at elevating pId B and trying to avoid to set HOME= to ~root, and asking myself how to copy .Xauthority to a different directory, etc... it might be easier to start the whole setup as superuser with a crowd unaware of what the security issues are, and how Linux works under the hood, but that kinda defies security policies and proper programming standards.

Last edited by m3rl1n; 04-06-2013 at 11:31 PM.
 
Old 04-07-2013, 12:46 AM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
rewrite a Makefile to do the installing
make is very versatile , i even use it in image processing to run the commands in a rather long and complex process

or just create a install.sh file
have the person run it as root on their system

Last edited by John VV; 04-07-2013 at 12:47 AM.
 
Old 04-07-2013, 02:09 AM   #6
m3rl1n
LQ Newbie
 
Registered: Aug 2011
Posts: 7

Original Poster
Blog Entries: 9

Rep: Reputation: Disabled
Quote:
Originally Posted by John VV View Post
rewrite a Makefile to do the installing
make is very versatile
That would be a nice solution indeed. I am under some time pressure to perform, so I have come to the conclusion that I will not let user X install a system-wide application for anyone, but rather have that person install an application for him/herself only, therefore I don't need to elevate privileges. I will try a make script and see how QProcess responds to it -- to satisfy the "I must know how this works" feeling.

Thannk you (all) for support.
 
Old 04-07-2013, 05:56 AM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by m3rl1n View Post
I need to look into a different approach for launching elevation of privileges. su - would be an option on Fedora and CentOS, but not on Ubuntu (sudo su -). And the main reason for explicitely not making an RPM/DEB/TAR is that my target audience is not Linux Savvy at all. They expect a setup with a next and a back button

The architecture of the installer is the following: Process A (pId A) collects information. pId A launches another process pId B (inheriting from pId A) to do all the work. pId B needs privileges to save icons and a desktop.entry file in the appropriate files (folders). So I am looking at elevating pId B and trying to avoid to set HOME= to ~root, and asking myself how to copy .Xauthority to a different directory, etc... it might be easier to start the whole setup as superuser with a crowd unaware of what the security issues are, and how Linux works under the hood, but that kinda defies security policies and proper programming standards.
Unfortunately, such an installer opens a trojan attack via a race condition between the "collects information", and process B. If the data collection is subverted, then the privileged process will do things you don't want.

And you can't just copy the .Xauthority (well, you can, but where it exists varies from system to system, and you can't always just copy it. MAC labeling can prevent it).

Next, you can't avoid the HOME issue - unless you fully elevate priviges to root (su -), you don't necessarily get the privileges needed to install.

Fedora 17/18/19 do use 1000 for the base UID/GID by default now, though like all the other distributions, this is up to the administrator to set the default to local conditions. And all RH/Fedora uses mandatory security labels unless the administrator has disabled them.

There is no easy way around having a repository for the various systems. Even then, setting up a repository for use is not simple for the naive user. They STILL have to be an administrator.

Last edited by jpollard; 04-07-2013 at 05:58 AM.
 
Old 04-07-2013, 07:33 AM   #8
m3rl1n
LQ Newbie
 
Registered: Aug 2011
Posts: 7

Original Poster
Blog Entries: 9

Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
There is no easy way around having a repository for the various systems....They STILL have to be an administrator.
Indeed. I therefore decided to not allow user X, to install an application - as a system wide program. That solved everything in 1 shot. No elevation necessary. Still remains that awkward feeling that I want to make it happen, as a try-out that is.
 
Old 04-07-2013, 07:43 AM   #9
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
Quote:
Originally Posted by m3rl1n View Post
The installer needs to save icon files(.png) in the /usr/share/icons/hicolor/<icon-size>/apps/ folder and a desktop-entry file in /usr/share/applications. (for both folders, superuser privileges are mandatory on the main distro's)
Use $HOME/.local/share/icons/hicolor/<icon-size>/apps/ and $HOME/.local/share/applications/ and then you do not need escalation (though you will only have a single user install).

Read these:
http://standards.freedesktop.org/bas...ec-latest.html
http://lists.freedesktop.org/archive...er/010025.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Always give root (sudo) privileges in Ubuntu 11.10? mkirsch72 Linux - General 11 02-16-2012 10:19 PM
Make SuperUser/Root Privileges Default for Nautilus Zaileion Linux - General 13 01-25-2012 03:19 PM
Linux user privileges issue zaeem Linux - Security 13 11-02-2010 06:26 AM
Ubuntu 8.04 Superuser Privileges Tom56 Ubuntu 3 03-22-2010 04:19 AM
You must have superuser privileges Markit0s Linux - Newbie 7 07-28-2006 02:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration