By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release.

Bug 853

Summary: tdebase: Using konsole as root is hard-coded to sudo
Product: TDE Reporter: Darrell <darrella>
Component: tdebaseAssignee: Timothy Pearson <kb9vqf>
Status: RESOLVED FIXED    
Severity: normal CC: alexispm_stellaluna, bugwatch, darrella, dzfixes-box1, keithwdaniels, slavek.banko
Priority: P1    
Version: R14.0.0 [Trinity]   
Hardware: Other   
OS: Other   
Compiler Version: TDE Version String:
Application Version: Application Name: konsole
Bug Depends on:    
Bug Blocks: 1700    
Attachments: Patch to fix sudo test in konsole.cpp
Patch to demonstrate problem in su.desktop and sumc.desktop
Patch to fix konsole files with sudo or su
Fix konsole files with sudo or su (1)
Fix konsole files with sudo or su: updated to include missing dash in sumc.desktop
Fix konsole files with sudo or su: updated to include new CMakeLists.txt option
Fix konsole super user sessions with sudo or su (5)

Description Darrell 2012-02-11 14:33:38 CST
The Panel Terminal applet provides two options to use Konsole as root: 1) Root Shell and 2) Root Midnight Commander. These options fail on Slackware and more than likely fail on other distros where root access is not restricted to sudo. The affected files:

konsole.cpp:3372
su.desktop:Exec
sumc.desktop:Exec

In the two desktop files, removing the sudo prefix resolves the problem. The lines in konsole.cpp should be patched to check for both "su" (original 3.5.10 code) and "sudo su" rather than only sudo.
Comment 1 Darrell 2012-02-11 15:16:02 CST
Created attachment 348 [details]
Patch to fix sudo test in konsole.cpp

Currently konsole.cpp tests only for "sudo su -c," which will fail on distros not restricted to sudo. This patch tests for "su-c" as well.
Comment 2 Darrell 2012-02-11 15:21:00 CST
Created attachment 349 [details]
Patch to demonstrate problem in su.desktop and sumc.desktop

This patch likely will be rejected because the patch will break 'buntu type distros that restrict root access through sudo. I'm submitting the patch anyway to show how the desktop files should look on non restricted distros.

I don't know how we should address this problem to work with both types of distros. Possibly the cmake process can be coded to create the correct desktop files on-the-fly?

I also changed the schema. The yellow background makes colored text difficult to read. Even if the patch is rejected, please consider retaining the schema changes. :)
Comment 3 David Hare 2012-02-24 06:35:26 CST
Noticed a long time back on my Debian systems. Here,those menu entries get removed altogether. Without them, to simply type "su" (or sudo, if used) in a user konsole does not make TDE any less functional.
Comment 4 Darrell 2012-09-19 13:44:48 CDT
*** Bug 1228 has been marked as a duplicate of this bug. ***
Comment 5 Slávek Banko 2012-09-19 13:48:03 CDT
Darrell, thank you for pointing.
Comment 6 Alexis PM 2012-09-20 13:42:47 CDT
This bug persist in 3.5.13.1 (Slavek repo: deb
http://ppa.quickbuild.pearsoncomputing.net/slavek-banko/axis/ubuntu squeeze
main)
Comment 7 Darrell 2012-09-20 15:01:18 CDT
Perhaps a solution is to create a new sudo.desktop and sudomc.desktop and modify konsole.cpp to use the correct desktop files?

if (exec.startsWith("su -c \'")) {
    exec = exec.mid(7,exec.length()-8);
else if (exec.startsWith("sudo su -c \'")) {
    exec = exec.mid(12,exec.length()-13);
}
Comment 8 Darrell 2013-11-07 17:41:00 CST
Created attachment 1602 [details]
Patch to fix konsole files with sudo or su

I am attaching a proposed patch that hopefully resolves the problem.

The patch updates konsole.cpp to check for 'su -c' as well as 'sudo su -c'.

The patch updates the su.desktop and sumc.desktop files during the cmake configuration depending upon the value of the cmake configuration variable WITH_SUDO_TDESU_BACKEND.
Comment 9 Slávek Banko 2013-11-09 10:11:02 CST
Created attachment 1614 [details]
Fix konsole files with sudo or su (1)

Modify files in place the sources should not be done. Therefore I prepared equivalent patch that makes change in the build folder.

Your idea for patch for me seems good. However, there is one key question for Ubuntu builds: Even on Ubuntu are in fact tdelibs and tdebase built with WITH_SUDO_TDESU_BACKEND="OFF" (see tde-packaging).
Comment 10 Darrell 2013-11-09 12:02:32 CST
Okay, so your patch achieves the same end result and is the preferred method. Thank you.

Regarding using WITH_SUDO_TDESU_BACKEND as the foundational test, I was unaware that Ubuntu and derivatives configured that option to OFF. Seems then we need a different test or we need to create a new configuration option?
Comment 11 Keith 2013-11-09 15:53:39 CST
I don't have any patches, but I do have a work around until someone can figure out how to fix this.  

This problem prevents using any scripts that may be located in /root/bin and prevents you from calling other programs (like konsole) while using "sudo konqueror" among other things.   A serious problem for me.

The basic problem is that you do not have the root user's paths available, especially /root/bin and $TDEHOME is not specified in the environment.

My work around is this:

In the root directory create the file .bash_aliases

In that file insert these two lines:

PATH="{INSERT THE NECESSARY ROOT AND TDE PATHS HERE}"
TDEHOME="/root/.trinity"

Then create icons in your TDE panel for the apps that you want to run with supper user permissions, and environments.

Examples of the commands you would use if you right click the icon, and select the Configure XXXX Button choice. Then click on the Application tab and add the command you want to run in the, Command: [---text box area---].
-----------------
tdesu -u root -c "kate --config /root/.trinity/share/config/katerc --caption ROOT %U"

tdesu -u root -c "konsole --config /root/.trinity/share/config/konsolerc --caption ROOT"

tdesu -u root -c "konqueror --profile filemanagement --config /root/.trinity/share/config/konquerorrc --caption ROOT"
-----------------

and everything works from startup.  Including being able to open other programs from Konsole and Konqueror and in Kate you have a "real" root terminal window available.


I like my apps to have ROOT in the title bar so that when they are minimized I can tell which app is a root app, I also us a different colored background in the program.  I don't know if the --config option is necessary, it was in there when I started experimenting, but it is probably not necessary.
 
Note: This "probably" will not work unless you at least have a root user with a Xwindows environment.

Keith
Comment 12 Darrell 2013-11-09 16:15:57 CST
Thanks for the work-around.

Slavek's updated patch should resolve this particular bug report (konsole only). The patch won't resolve problems with other apps, such as kate/kwrite, as reported in bug 1700. :-(
Comment 13 Darrell 2013-11-10 10:53:17 CST
Slavek, your updated patch works well here.

To resolve this report we need to (again) update the patch with a different test or we need to create a new configuration option other than WITH_SUDO_TDESU_BACKEND?
Comment 14 Darrell 2013-11-10 11:52:02 CST
I would like to make one change to the current patch.

In sumc.desktop.cmake:

AS IS:
Exec=@KONSOLE_SUPER_USER_COMMAND@ -c 'mc -c'

CHANGE TO:
Exec=@KONSOLE_SUPER_USER_COMMAND@ - -c 'mc -c'

Without the extra dash sumc opens to the user's $HOME rather than root's.
Comment 15 Darrell 2013-11-10 11:58:55 CST
BTW, the missing dash was inherited that way from KDE3, but resolving this bug report should agree with bug 1700 as well.
Comment 16 Darrell 2013-11-19 00:19:11 CST
Created attachment 1645 [details]
Fix konsole files with sudo or su: updated to include missing dash in sumc.desktop
Comment 17 Darrell 2013-11-20 15:33:55 CST
Created attachment 1655 [details]
Fix konsole files with sudo or su: updated to include new CMakeLists.txt option

Slavek,

I updated the patch with a new CMakeLists.txt option:

WITH_SUDO_KONSOLE_SUPER_USER_COMMAND

The default is OFF.

The patch works here with both ON and OFF.

Several non-Ubuntu users are affected by this problem. Hopefully we can push this into git soon.
Comment 18 Slávek Banko 2013-11-20 16:09:31 CST
Created attachment 1656 [details]
Fix konsole super user sessions with sudo or su (5)

Thank you for the update patch.

But I noticed one contradiction. The in konsole/konsole/konsole.cpp is tested "su -c \'" and "sudo su -c \'", but now it does not match at all.
So I modified the patch - for greater variability in comparison is used regular expression - just single line.

Please, test it.

Note: All your recent changes are also incorporated. I have slightly modified description of new build option, because this is not related to tdesu. In the last update you inadvertently changed WITH_SUDO_TDESU_BACKEND option also in tdesu.
Comment 19 Slávek Banko 2013-11-20 16:12:05 CST
I noticed a typo: luanching × launching => I have it already fixed.
Comment 20 Darrell 2013-11-20 16:13:50 CST
Okay, thanks. :-)

BTW, grep the tdebase sources and notice WITH_SUDO_TDESU_BACKEND is not used anywhere. So perhaps this latest patch was not needed? That is, we could use WITH_SUDO_TDESU_BACKEND as the criterion?
Comment 21 Slávek Banko 2013-11-20 16:18:36 CST
(Odpověď na komentář #20)
> Okay, thanks. :-)
> 
> BTW, grep the tdebase sources and notice WITH_SUDO_TDESU_BACKEND is not used
> anywhere. So perhaps this latest patch was not needed? That is, we could use
> WITH_SUDO_TDESU_BACKEND as the criterion?

WITH_SUDO_TDESU_BACKEND is used in "tdesu/CMakeLists.txt". And it's a legitimate use. Your previous patch it incorrectly replaced to WITH_SUDO_KONSOLE_SUPER_USER_COMMAND :)
Comment 22 Darrell 2013-11-20 16:21:35 CST
Sigh. :-( You're correct. I'm sorry.
Comment 23 Darrell 2013-11-20 17:38:27 CST
Slavek, the patch is functioning here. I don't use sudo and the su and sumc desktop files configured correctly. With respect to sudo, I tested as far as letting cmake complete the configuration and then I inspected the respective desktop files.

Great work! I say we can put this to rest. Push the patch. :-)
Comment 24 Slávek Banko 2013-11-20 20:59:59 CST
Pushed to GIT in hash 7d6186b5.