KDE Crashes Whenever I Edit A Text File with Sudo

Bug #378394 reported by Jeremy LaCroix on 2009-05-19
64
This bug affects 9 people
Affects Status Importance Assigned to Milestone
KDE Base
Fix Released
High
kde4libs (Ubuntu)
Medium
Unassigned

Bug Description

Binary package hint: kdm

I am using 64-bit Jaunty Kubuntu. Ever since upgrading to 4.2.3, I can predictably crash my machine by editing a single text file. I discovered this while attempting to update my sources.list file.

I ran the following command:

sudo kate /etc/apt/sources.list

Once I done that, a dialog box came up that said:

"Could not start ksmserver. Check your installation."

If I click "okay" on that dialog box, I am dumped right back to the KDM login screen. If I do not click okay, I can continue using my machine normally without problems.

I can repeat this error with 100% accuracy.

There is a forum topic linked below showing other people that are having this same issue:
http://kubuntuforums.net/forums/index.php?topic=3103693.0

Yuriy Kozlov (yuriy-kozlov) wrote :

Thank you for filing this bug report.

Have you tried using kdesudo instead?

Yes, kdesudo works fine, however this bug is in regards to plain old sudo, which I prefer to use.

vista killer (vistakiller) wrote :

Same problem here. The problem seems to appear after upgrade kde 4.2.3. Before that sudo works fine.

Jonathan Thomas (echidnaman) wrote :

You aren't supposed to use sudo to launch GUI applications, as there is a risk that it will mess things up.

Changed in kdebase-workspace (Ubuntu):
status: New → Invalid

I don't understand, whether you're supposed to do something or not doesn't matter as Linux is about choice. Besides, this is something that has always worked fine for Kubuntu's entire existence and is only broken now, so why is it "invalid"?

Since this was broken as of KDE 4.2.3, this is a regression. Regardless of politics, there is no excuse for a regression.

Terence Simpson (tsimpson) wrote :

This has nothing to do with KDE, it's to do with sudo and how it works. kdesudo makes sure it sets up the correct environment for running GUI applications. If it worked for you in 4.2.2 then that is just a coincidence and not by design.

Jonathan Thomas (echidnaman) wrote :

sudo has had a long history of causing all sorts of problems when running GUI apps with it. (Bug 53845, bug 234982, bug 234982, and bug 112781 to name a few) I've even been bitten by a permissions bug caused by running stuff with sudo. Running graphical applications with sudo has never been supported by either Ubuntu or Kubuntu; but sure, you are free to choose whether or not to use sudo unreliably with GUI apps.

With all due respect, sudo working in every version of KDE from KDE 3.5
onwards is not a coincidence. This is a regression. Whether or not I am
supposed to be doing this, if it's a good idea, or if it breaks other
things is irrelevant, something broke and all regressions may affect
other things. I highly urge you to look into this further before passing
it off.

-------- Original Message --------
Subject: [Bug 378394] Re: KDE Crashes Whenever I Edit A Text File with
Sudo
From: Terence Simpson <email address hidden>
Date: Wed, May 20, 2009 8:35 am
To: <email address hidden>

This has nothing to do with KDE, it's to do with sudo and how it works.
kdesudo makes sure it sets up the correct environment for running GUI
applications. If it worked for you in 4.2.2 then that is just a
coincidence and not by design.

--
KDE Crashes Whenever I Edit A Text File with Sudo
https://bugs.launchpad.net/bugs/378394
You received this bug notification because you are a direct subscriber
of the bug.

If it makes any difference, the issue does not seem to exist for me using KDE 4.2.85 (KDE 4.3 beta 1). I do remember having a ksmserver problem randomly appear (though I never ran sudo to cause it.. dunno why it happended for me), and it doesn't anymore.

I tested running sudo with kate, as in this bug and it works.

Now, not saying this is a fluke, or if there was a bug fix in kde or even if it will continue to work. Nor am I suggesting you upgrade to the beta, as its not ready for general consumption :)

Marian Schedenig (m-sched) wrote :

Since yesterday, I'm having the same problem in 4.2.3, except that I don't sudo/kdesu anything. The xmessage dialog just pops up after a seemingly random time - supposedly triggered by something I do in a program, since it didn't appear when KDE was running on its own over night, but I haven't been able to see a pattern so far.

As long as I ignore the dialog, everything is fine; clicking "ok" restarts my X, though curiously, at least some applications from the old session keep running in the background. For example, Amarok keeps running and playing, but stops playback after the current track. I can then launch a new Amarok and continue playing - I only discovered this when I looked at my ps output and saw that I had three Amaroks running in parallel.

Harald Sitter (apachelogger) wrote :

Technically it is indeed true that one should use kdesudo, but one can use sudo, that also worked until 4.2.3, so technically it is a regression and in fact, it really is one. So the regression outweighs the you-should-use-kdesudo-invalididation since the former is real and technical and the latter is only technical but not real.

Really, don't try to understand that :P

Anyway, I don't like this being marked invalid, since it _is_ a regression, and I am quite sure upstream would not have this invalid either. Also, this regression most likely got a much more important cause than just having sudo fight with the environment. Starting the app should not invoke startkde, that is for sure, yet it does, so something is horribly wrong.

Someone please forward this report upstream, or mark a possibly already existing one.

Changed in kdebase-workspace (Ubuntu):
importance: Undecided → Medium
status: Invalid → Confirmed
Jonathan Thomas (echidnaman) wrote :

Actually, they probably would invalidate it since X is crashing... Or they'd close it worksforme since they probably wouldn't be able to reproduce this in trunk.

Harald Sitter (apachelogger) wrote :

Or not :P

Changed in kdebase:
importance: Undecided → Unknown
status: New → Unknown
Changed in kdebase:
status: Unknown → New
Jonathan Thomas (echidnaman) wrote :

This could be related to https://bugs.kde.org/show_bug.cgi?id=194607 and fixed with: http://websvn.kde.org/?view=rev&revision=973813
Could anybody check with KDE 4.2.4?

affects: kdebase-workspace (Ubuntu) → kde4libs (Ubuntu)
mcpalls (mcpalls) wrote :

i have installed kde 4.2.4 today, but this bug it's also present

Marian Schedenig (m-sched) wrote :

Also still getting this bug in KDE 4.2.4, without any sudoing. In fact, for the last few days (i.e. already before upgrading to 4.2.4), I've been getting TWO of these xmessage dialogs as soon as KDE starts.

Hi, as a user of Jaunty 64bit / Kde 4.2.4 I am still experiencing this bug!
I researched the underlying process a little to prevent loossing all data when hitting on "OK"
BUT my patch is really DIRTY, it is producing an infinite loop.

I patched my /usr/bin/startkde to prevent sudden logout. To find the concerning part search for "Patched here"

Sorry, I accidently chose an old backup in my message before....
Of course this fix is still dirty, but it doesn't cause logout problems like the version before.

Changed in kdebase:
status: New → Confirmed

Hello again,

I think it's not a regression to know that sudo was always messing up with GUI-stuff.
But it's a regression because many Wiki and Forum entries are using the "sudo gedit" or "sudo kate" examples....
Some peolpe in the Ubuntu/Linux World became used to it - including me.

But we should think differently now...
Just a little new idea is a switcher who automatically uses kdesudo if the program is on a list of GUI-apps.

Maybe somebody knows how to distinguish all programs automatically !?

Feel free to reuse it in distribution :D

Christian González (droetker) wrote :

IMO the whole approach is wrong.
A programshould NEVER run as root, wether with sudo, su, kdesudo or whatever.
QT/GTK code is not needed to run as root, and the much better approach in general would be to tightly bind to policykit and letting just the things go as root that need to. The GUI components don't need to be root.

in the case of kate or dolphin - It would be MUCH better to have a possibility to let the user edit the file or doing some stuff in dolphin, and IF the user wants to do something that he isn't allowed to (save file in /etc/... or move some root files in dolphin THEN ask him for a password (or ask policykit) to gain the rights.

That would be a true fix of all these problems.
Everything else is frickling around, trying to make things "work somehow" - workarounds.

IIRC nautilus has this in some way, hasn't it? To ask you for the password if you want to copy a file into a folder you haven't write access?

That's exactly the point!
By the way, some of the GUI applications are really UGLY in "sudo"/"kdesudo" mode- and this problem persists since I was using Kubuntu 7.04!
Look at GParted for example...
So separating GUI stuff and real root access parts would be the perfect solution.
For our German readers, maybe somebody should mark this bug as an easy fixable Usability-Bug ?
http://www.heise.de/open/Die-Woche-Reifezeugnis-fuer-Linux--/artikel/140747

Changed in kde4libs (Ubuntu):
status: Confirmed → Triaged
Jonathan Thomas (echidnaman) wrote :

Is this still a problem in Kubuntu 9.10?

Changed in kde4libs (Ubuntu):
status: Triaged → Incomplete
FriedChicken (domlyons) wrote :

No (tested on three PCs)

spiros xeliotis (spirosxeliot) wrote :

No the problem is not exist in kubuntu 9.10

Changed in kde4libs (Ubuntu):
status: Incomplete → Fix Released
Patrick Dickey (pdickeybeta) wrote :

Will they be backporting the fix to 9.04? I have other issues that prevent me from upgrading to 9.10 on my laptop. The only time I use sudo is if I'm working with a file in a restricted folder (/etc or somewhere like that). If I'm not supposed to do this, then please explain how to edit a file in a restricted folder, when 1) I cannot log in as root (because Kubuntu/Ubuntu has the "root" account locked by default) and 2) I am not supposed to use sudo or kdesudo to open the editing file.

Personally, I hate VIM and EMACS because I've never really learned how to use them properly. It's much easier to open the file in Kate or KWrite and edit it there.

I'm running KDE 4.2.4 on Kubuntu 9.04. The computer is a Toshiba Satellite A105-S2194 laptop with 1.5 G of RAM.

Thanks, and have a great day:)
Patrick.

Etienne Perot (etienneperot) wrote :

Try using pico (or nano), it runs in the terminal but it behaves like you'd expect a text editor to actually behave ;)

Jonathan Thomas (echidnaman) wrote :

Since the fix is probably one (unidentified) change out of several thousands between KDE 4.2 and 4.3, and the behavior that triggers this is unsafe in the first place, my guess would be no update. We just don't know what fixed it, and nobody is motivated enough to sift through all the changes to find out what it was due to the rare/unsafe methods that one had to use to trigger this bug in the first place.

Changed in kdebase:
status: Confirmed → Fix Released
Gramler (maxf) wrote :

I am using 64-bit Karmic.
Since my latest apt-get dist-upgrade I get this, when I log into KDE.
So it completely locks me out of KDE.

I deleted my KDE config. No change
I un-installed the complete desktop environment and re-installed it. Still no change.

Gnome still works fine, so I am using this instead.

Changed in kde4libs (Ubuntu):
status: Fix Released → Fix Committed
Changed in kde4libs (Ubuntu):
status: Fix Committed → Fix Released
Changed in kdebase:
importance: Unknown → High
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.