From kwin Sun Mar 06 21:11:05 2011 From: "Mikael Gerdin" Date: Sun, 06 Mar 2011 21:11:05 +0000 To: kwin Subject: Re: Review Request: Make KWin able to kill frozen clients using Message-Id: <20110306211105.23055.97009 () vidsolbach ! de> X-MARC-Message: https://marc.info/?l=kwin&m=129944590827817 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1579019527==" --===============1579019527== Content-Type: multipart/alternative; boundary="===============4921331725950460776==" --===============4921331725950460776== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable > On March 6, 2011, 6:19 p.m., Martin Gr=C3=A4=C3=9Flin wrote: > > I just tried to push the patch, but it does not apply to kwin any more.= Could you please post a new patch? Thanks in advance :-) This reviewboard won't accept the git diff i created, so I'll just post the= damned diff here... This should apply cleanly. Sorry for not keeping up with this, I've had a l= ot to do. commit 8ddcbbdcbf1a047d25d60c97926fc87796571b5e Author: Mikael Gerdin Date: Sat Feb 5 13:25:20 2011 +0100 Add KAuth support to KWin process killer diff --git a/kwin/killer/killer.cpp b/kwin/killer/killer.cpp index 581c60c..d37a654 100644 --- a/kwin/killer/killer.cpp +++ b/kwin/killer/killer.cpp @@ -26,11 +26,14 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include +#include #include #include #include #include #include +#include = int main(int argc, char* argv[]) { @@ -75,8 +78,20 @@ int main(int argc, char* argv[]) QStringList lst; lst << hostname << "kill" << QString::number(pid); QProcess::startDetached("xon", lst); - } else - ::kill(pid, SIGKILL); - XKillClient(QX11Info::display(), id); + } else { + if (::kill(pid, SIGKILL) && errno =3D=3D EPERM) { + KAuth::Action killer("org.kde.ksysguard.processlisthelper.= sendsignal"); + killer.setHelperID("org.kde.ksysguard.processlisthelper"); + killer.addArgument("pid0", pid); + killer.addArgument("pidcount", 1); + killer.addArgument("signal", SIGKILL); + if (killer.isValid()) { + kDebug(1212) << "Using KAuth to kill pid: " << pid; + killer.execute(); + } else { + kDebug(1212) << "KWin process killer action not valid"; + } + } + } } } - Mikael ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: http://svn.reviewboard.kde.org/r/4460/#review9961 ----------------------------------------------------------- On June 26, 2010, 3:05 p.m., Mikael Gerdin wrote: > = > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > http://svn.reviewboard.kde.org/r/4460/ > ----------------------------------------------------------- > = > (Updated June 26, 2010, 3:05 p.m.) > = > = > Review request for kwin. > = > = > Summary > ------- > = > Makes KWin's window killer able to kill processes running as other users. > I just re-used the code used in krunner's (and ksysguard's) process lister > to kill processes using elevated privileges. > = > As it works now it only tries to use elevated privileges if kill returns = EPERM. > = > = > This addresses bug 129476. > https://bugs.kde.org/show_bug.cgi?id=3D129476 > = > = > Diffs > ----- > = > /trunk/KDE/kdebase/workspace/kwin/killer/killer.cpp 1143106 = > = > Diff: http://svn.reviewboard.kde.org/r/4460/diff > = > = > Testing > ------- > = > Manual testing by calling the helper app manually and by making a > root-owned X window hang and click the "X" to make kwin try to kill it. > = > = > Thanks, > = > Mikael > = > --===============4921331725950460776== Content-Type: text/html; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable
This is an automatically generated e-mail. To reply, visit: http://svn.reviewb= oard.kde.org/r/4460/

On March 6th, 2011, 6:19 p.m., Martin Gr=C3= =A4=C3=9Flin wrote:

I just tr=
ied to push the patch, but it does not apply to kwin any more. Could you pl=
ease post a new patch? Thanks in advance :-)
This review=
board won't accept the git diff i created, so I'll just post the da=
mned diff here...
This should apply cleanly. Sorry for not keeping up with this, I've had=
 a lot to do.

commit 8ddcbbdcbf1a047d25d60c97926fc87796571b5e
Author: Mikael Gerdin <mikael.gerdin@gmail.com>
Date:   Sat Feb 5 13:25:20 2011 +0100

    Add KAuth support to KWin process killer

diff --git a/kwin/killer/killer.cpp b/kwin/killer/killer.cpp
index 581c60c..d37a654 100644
--- a/kwin/killer/killer.cpp
+++ b/kwin/killer/killer.cpp
@@ -26,11 +26,14 @@ DEALINGS IN THE SOFTWARE.
 #include <kapplication.h>
 #include <kmessagebox.h>
 #include <klocale.h>
+#include <kauth.h>
+#include <kdebug.h>
 #include <unistd.h>
 #include <X11/Xlib.h>
 #include <QX11Info>
 #include <QProcess>
 #include <signal.h>
+#include <errno.h>
 =

 int main(int argc, char* argv[])
 {
@@ -75,8 +78,20 @@ int main(int argc, char* argv[])
             QStringList lst;
             lst << hostname << "kill" << QStri=
ng::number(pid);
             QProcess::startDetached("xon", lst);
-        } else
-            ::kill(pid, SIGKILL);
-        XKillClient(QX11Info::display(), id);
+        } else {
+            if (::kill(pid, SIGKILL) && errno =3D=3D EPERM) {
+                KAuth::Action killer("org.kde.ksysguard.processlisthe=
lper.sendsignal");
+                killer.setHelperID("org.kde.ksysguard.processlisthelp=
er");
+                killer.addArgument("pid0", pid);
+                killer.addArgument("pidcount", 1);
+                killer.addArgument("signal", SIGKILL);
+                if (killer.isValid()) {
+                    kDebug(1212) << "Using KAuth to kill pid: &=
quot; << pid;
+                    killer.execute();
+                } else {
+                    kDebug(1212) << "KWin process killer action=
 not valid";
+                }
+            }
+        }
     }
 }

- Mikael


On June 26th, 2010, 3:05 p.m., Mikael Gerdin wrote:

Review request for kwin.
By Mikael Gerdin.

Updated June 26, 2010, 3:05 p.m.

Descripti= on

Makes KWin's window killer able to kill processes runnin=
g as other users.
I just re-used the code used in krunner's (and ksysguard's) process=
 lister
to kill processes using elevated privileges.

As it works now it only tries to use elevated privileges if kill returns EP=
ERM.

Testing <= /h1>
Manual testing by calling the helper app manually and by mak=
ing a
root-owned X window hang and click the "X" to make kwin try to ki=
ll it.
Bugs: 129476

Diffs=

  • /trunk/KDE/kdebase/workspace/kwin/killer/killer.cpp (1143106)

View Diff

--===============4921331725950460776==-- --===============1579019527== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kwin mailing list kwin@kde.org https://mail.kde.org/mailman/listinfo/kwin --===============1579019527==--