Commit Graph

113 Commits (1350653d4497a15857d1c904df447be3766042e5)

Author SHA1 Message Date
Tobias C. Berner 2ea5feb35b Disallow ptrace on greeter and kwin_wayland process on FreeBSD [... for the future]
Summary:
Similar to[[ https://phabricator.kde.org/D1216 |  D1216 ]] add procctl call to disable ptrace on FreeBSD.

We cannot do the procfs-lookup to check whether the process is already being run inside gdb -- however, on FreeBSD, we could use the P_TRACED flag of the process to figure this out:
> sys/proc.h:#define P_TRACED        0x00800 /* Debugged process being traced. */

And the code would look something similar to

```
    pid_t pid = getpid();
    struct procstat *prstat = procstat_open_sysctl();
    struct kinfo_proc *procinfo;
    unsigned int cnt;
    procinfo = procstat_getprocs(prstat, KERN_PROC_PID, pid, &cnt);
    long p_flags = procinfo->ki_flag;
    int p_traced = p_flags & P_TRACED;
    if (p_traced != P_TRACED) {
        mode = PROC_TRACE_CTL_DISABLE;
        procctl(P_PID, getpid(), PROC_TRACE_CTL, &mode);
    }
    procstat_freeprocs(prstat,procinfo);
    procstat_close(prstat);
```

But as wayland is [far] in the future on FreeBSD, and that check above is a bit lengthy, I think it is enough if we add it once it is needed.

Reviewers: rakuco, graesslin

Reviewed By: graesslin

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1425
2016-05-10 08:50:25 +02:00
Martin Gräßlin bd8f6d78f0 Move everything KCrash related from Application to ApplicationX11
Summary:
This change ensures that kwin_wayland does not pull in KCrash. We
don't want and need KCrash in the Wayland case. If KWin crashes the
session goes down - restarting doesn't make any sense, we need to
relogin.

Similar drkonqi just doesn't work as it doesn't have a windowing
system to connect to. After all the windowing system just crashed.

Also the AlternativeWM dialog doesn't make any sense on Wayland.
Similar thought: there is no windowing system to show this nice dialog.

Overall it's better to have system default behavior
(e.g. systemd-coredump) than using KCrash in the very special case of
kwin_wayland.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1550
2016-05-09 08:08:49 +02:00
Martin Gräßlin 319869881c Connect Application::screensCreated to WaylandServer::initOutputs
Summary:
Instead of having the Application invoke initOutputs after creating
the Screens, we can just connect to the signal emitted there.

This allows to make initOutputs a private, WaylandServer internal
method.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1482
2016-05-02 15:52:07 +02:00
Martin Gräßlin e614789583 Destroy Workspace after unloading all effects
CI system shows that on tear down an effect might call into Workspace
after it's destroyed. Unloading all effects prior to deleting Workspace
should(TM) fix that. Unfortunately I'm not able to reproduce the problem
locally, so build.kde.org needs to verify.
2016-04-26 13:40:24 +02:00
Martin Gräßlin e64450c807 Merge branch 'Plasma/5.6' 2016-04-26 13:13:17 +02:00
Martin Gräßlin df2c26e3d9 Only start Xwayland server if Compositor created a Scene
So far if the Scene creation failed kwin_wayland went into a shutdown,
but didn't succeed because the thread to start Xwayland was already
running: it froze.

This change introduces a new signal in Compositor: sceneCreated. The
startup of Xwayland is bound to this signal. If it gets fired KWin can
startup Xwayland. If it does not get fired, KWin terminates correctly.
2016-04-14 08:51:16 +02:00
Martin Gräßlin d31e9e88b4 Rename abstract_backend.(h|cpp) to platform.(h|cpp)
Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1340
2016-04-07 16:18:12 +02:00
Martin Gräßlin 10632f09ca Rename AbstractBackend to Platform 2016-04-07 16:18:12 +02:00
Martin Gräßlin 146af48f22 waylandServer()->backend() replaced by kwinApp()->platform() 2016-04-07 15:00:11 +02:00
Martin Gräßlin 7996d954c5 Provide the platform() -> AbstractBackend* in KWin::Application
Summary:
This is the first change in a refactoring series. The aim is to:
* rename AbstractBackend to Platform
* move backends/ to plugins/platforms/
* don't bind platforms to Wayland only
* provide a platform plugin for "normal" X11
* share more code between X11 and Wayland

This change moves the platform/backend from waylandServer to Application.
The init of the plugin happens directly in the Application from the
KPluginMetaData. There is no need to externally init it and set the
parent.

WaylandServer::backend() currently just delegates to
kwinApp()->platform(), the idea is to drop this method completely.

The test infrastructure is also adjusted to this change.

Test Plan: kwin_wayland still works, all tests pass

Reviewers: #plasma, sebas

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1331
2016-04-07 08:00:12 +02:00
Oleg Chernovskiy 7ccca92c3e Remove crash handling in kwin_wayland
This patch introduces additional method to Application class
that has default policy of restarting the app.
This method is overridden for wayland case disabling this step.

REVIEW: 126655
2016-02-09 17:20:43 +01:00
Oleg Chernovskiy 61e1a98fb7 Maintenance - fixing naming typos
Fix typos in signal naming var
Fix typo in KWin QPA environment variable
2016-02-09 17:20:12 +01:00
Martin Gräßlin 20a9a2a247 Introduce a --no-kactivities command line option
This change enables kactivities integration by default again on both
X11 and Wayland (as kactivities no longer blocks). As we have an
infrastructure to disable kactivities we can also make use of it and
offer a command line switch to disable kactivities. This might be
useful for using KWin outside of Plasma.

REVIEW: 126153
2015-12-16 10:42:14 +01:00
Martin Gräßlin 96124c1643 Merge branch 'Plasma/5.5' 2015-12-15 13:08:16 +01:00
Martin Gräßlin 14b9046ad2 Unblock signals in child processes
We need to unblock the signals blocked with pthread_sigmask.
This caused kdeinit to block, because it relies on SIGUSR1.

BUG: 356580
FIXED-IN: 5.5.1
REVIEW: 126361
2015-12-15 13:03:30 +01:00
Martin Gräßlin 2d6fe2cb05 [wayland] Forward error channel of launched processes
This ensures that the redirection to xwayland-errors works properly
for a complete session.
2015-12-15 10:08:36 +01:00
Martin Gräßlin e5a27cffb1 [wayland] Disallow ptrace on kwin_wayland process
In order to increase the security we disable ptrace on kwin_wayland.
This makes it impossible for a another process running as the same
user to attach to kwin_wayland to install a key logger. It doesn't
protect against higher privileged users, but that's no problem: they
can just read the input device file and don't need to attach to KWin
to become a key logger.

This change is highly inspired by a similar change to kscreenlocker.
A difference is that KWin checks whether we are running under a
debugger. In such a case we still want to allow ptrace.
2015-12-08 11:42:48 +01:00
Rohan Garg 8680586dbd Add a check for waylandServer in the dtor before using it
Make sure the waylandServer ptr exists before referencing it
in the dtor.

REVIEW: 126190
2015-11-30 15:58:27 +01:00
Martin Gräßlin 56bd1e7194 [wayland] Add support for initial output count for nested compositors
Added to x11 backend which creates one window per output.

New command line option is called --output-count=<int>.
2015-11-26 08:33:07 +01:00
Martin Gräßlin 23784d2038 [wayland] Introduce an additional --exit-with-session command line arg
This is similar to the applications to start. That is the value of the
command line argument is interpreted as a command to start.
The difference is that when this application exits, KWin will also quit.
The argument is so to say interpreted as a session.

Reviewed-By: Bhushan Shah
2015-11-19 09:28:51 +01:00
Martin Gräßlin 3be016fba4 [wayland] Destroy all ClientConnections on tear down
Ensures that all Wayland objects are destroyed and the cleanup handling
is performed before tearing down the Compositor. This fixes for example
a crash if a Surface with a Shadow is still around at tear down.
2015-11-18 10:29:10 +01:00
Martin Gräßlin f6ef9e8d8c [wayland] Don't use waitForFinished on the Xwayland QProcess
WaitForFinished blocks our main thread, but Xwayland wants to talk
to Wayland and blocks as well. So let's ensure events are processed
while terminating Xwayland.
2015-11-12 15:15:44 +01:00
Martin Gräßlin 240e7ba337 [wayland] Emit signal before x11 connection gets destroyed
Used in Compositor to destroy the cm_selection. This would crash
otherwise as it calls into xcb after Xwayland is destroyed.
2015-11-12 15:13:42 +01:00
Martin Gräßlin f2bdb4818a [wayland] Disable Compositor during tear-down
Prevents rendering an incomplete state and as well prevents from
running performCompositing() which could access Workspace and crash.
2015-11-12 15:12:01 +01:00
Martin Gräßlin 238ff89edb [wayland] Don't exit due to Xwayland exiting on tear down
Our Xwayland exit error handler should not run during tearing down
Xwayland. Yes we expect Xwayland to exit as a response to KWin telling
it to exit.
2015-11-12 14:06:28 +01:00
Martin Gräßlin c1e9280efa [wayland] Unload all effects prior to destroying Xwayland connection
Some effects do X11 calls in their cleanup code through external
libraries (e.g. KSelectionOwner). As we cannot control that we need
to ensure the effects are unloaded prior to destroying the Xwayland
connection.
2015-11-12 11:33:00 +01:00
Martin Gräßlin fa6fbbdfc1 [wayland] Destroy input method connection after process finished
More cleanup.
2015-11-10 14:38:45 +01:00
Martin Gräßlin affcbac7e7 [wayland] Destroy Xwayland's ClientConnection on tear down
We need to destroy the ClientConnections we create. Also we need
to disconnect our Xwayland error handling before destroying it, otherwise
it would trigger the abort for crashing Xwayland.
2015-11-10 14:21:48 +01:00
Martin Gräßlin f75e53af60 [wayland] Ensure to not call into x11 on Compositor tear-down
During Compositor tear down Xwayland is already destroyed. Thus it
doesn't make sense to try to delete the support properties: either
it freezes in xcb or it crashes because the connection is null.

At the same time we also ensure that the connection internally is
reset to null. Note: the one in kwinglobals.h caches and could cause
use-after-free errors. Any tear-down code must be migrated to
kwinApp()->x11Connection().
2015-11-10 13:54:26 +01:00
Martin Gräßlin 1998d5ac1a [wayland] Improve tear-down to not crash if X11 applications are still around
We need to destroy the compositor after Xwayland terminated and after
the internal Wayland connection is destroyed. This means when destroying
the Workspace we may no longer destroy the Compositor at the same time.
Also we need to ensure that other tear down functionality doesn't call
into the no longer existing internal client connection.

With this change kwin doesn't crash when exiting with Wayland and/or
X11 windows still open.
2015-11-10 08:56:32 +01:00
Takahiro Hashimoto 7b9c21d63c [wayland] Use Qt::AA_DisableHighDpiScaling in Qt 5.6
Follow the change of Qt 5.6 branch, see below

https://codereview.qt-project.org/#/c/127895/

REVIEW: 126008
2015-11-10 07:47:55 +09:00
Nick Shaforostoff 3a8d7d866a optimize string operations
-use qstringliteral only when necessary (i.e. not in concat or comparison)
-use qbytearray instead of qstring when dealing with latin1 input and output (glplatform)
-use qstringref to extract numbers from strings (glplatform)
-define qt_use_qstringbuilder to optimize all string concatenations
-anidata: use ctor init lists, add windowType member initialization

REVIEW: 125933
2015-11-05 14:14:06 +00:00
Bhushan Shah bacfd876fe [wayland] Start ksldapp from the WaylandServer
This introduces --lockscreen option in kwin_wayland which when used will
lock screen immediately. Also dependency to newly created kscreenlocker
repo is introduced.

REVIEW: 125954
2015-11-05 18:39:23 +05:30
Martin Gräßlin 19602a921e [wayland] Reset QT_QPA_PLATFORM to wayland after starting Application
We only need to force QT_QPA_PLATFORM to be our own plugin when starting
the application. As KWin starts other processes (e.g. kcmshell5) we need
to ensure that the env variable has a sane value. No other process can
load our QPA plugin after all.

Reviewed-By: Bhushan Shah
2015-11-03 16:52:55 +01:00
Martin Gräßlin 7cc566681d [wayland] Drop check for QtWayland 5.4.2
We don't use QtWayland any more, so we don't need to check the version
any more.
2015-10-29 10:10:28 +01:00
Martin Gräßlin 28992c3d31 [wayland] Force Qt::AA_NoHighDpiScaling on Qt 5.6
We already unset QT_DEVICE_PIXEL_RATIO to ensure to keep out of
high dpi scaling. Now with Qt 5.6 we also need to set the attribute.
Without we crash on startup as we don't have a screen that early and
well Qt doesn't check whether it's null.
2015-10-29 10:08:23 +01:00
Martin Gräßlin eed5531b4f [wayland] Rework command line checks for platforms
The change to reflect the available plugins in the command line options
had side effects as that made it impossible to start KWin if certain
plugins are not available.

This change ensures that we only check the option value if they are set
in the first place.

In addition the multi checks to verify whether combinations are valid
is removed as that makes in reality no sense any more (only few plugins
installed by distros) and doesn't scale any more with the increasing
numbers of backends.
2015-10-03 20:14:16 +02:00
Martin Gräßlin bfa9646d1d [wayland] Add a virtual framebuffer backend
A new backend which doesn't present the rendered output. It uses a
QPainter scene, renders to a QImage but doesn't present it anywhere.
Thus a real virtual backend.

By exporting the environment variable KWIN_WAYLAND_VIRTUAL_SCREENSHOTS
the backend creates a temporary dir, prints the path to std-out and
saves each rendered frame into that directory. Of course with exit it
will be deleted again.
2015-10-02 10:58:33 +02:00
Martin Gräßlin 007a317099 [wayland] Add options depending on available backend plugins
As distributions do not ship all plugins let's try to filter the options
based on the plugins which are actually available. There is no point in
allowing e.g. framebuffer just to notice then that the plugin is not
shipped ending in confusing error for the user. So let's only add the
options which actually make sense.
2015-10-02 09:47:27 +02:00
Martin Gräßlin fc0272f3c4 [wayland] Add a --list-backends command line arg for listing available backends
Distributions do package each backend plugin in a dedicated package,
which means just because KWin got compiled with a specific backend,
doesn't mean it is also available at runtime.

In order to better support this reality this change introduces a
list-backends command line option. Each of the plugins got the json
metadata extended by the KPlugin syntax, so that we have a name and
description to print.

As we already locate all plugins anyway, the additional findPlugins for
the selected backend is changed to search the list of all plugin meta
data.
2015-10-02 09:31:47 +02:00
Martin Gräßlin abb9bf1355 [wayland] Create event dispatcher in QPA plugin
We no longer need to have the event dispatcher created before starting
the QApplication, thus we can leave it to the QPA plugin to creat it.

Also we don't need to implement our own dispatcher any more but can
use one from Qt5PlatformSupport as we link it anyways. The special
need for dispatching the WaylandServer is no longer needed as we can
explicitly dispatch it from the QPA plugin if needed.
2015-08-25 14:33:51 +02:00
Martin Gräßlin ef20f82b4d [wayland] Create waylandServer after creating QApplication
Our QPA plugin does not require a running Wayland server at startup,
so we can move the startup after creating the application.

Nice side effect: --help works now.
2015-08-25 14:33:51 +02:00
Martin Gräßlin f034537ad7 [wayland] Drop workaround on Qt window expose event
No longer needed with our own QPA plugin.
2015-08-25 14:33:51 +02:00
Martin Gräßlin 8add14fe89 [wayland] Drop hack for faking input for Qt popups
This reverts 29c2ae57.
2015-08-25 14:33:51 +02:00
Martin Gräßlin cd0e905248 [wayland] Drop QT_WAYLAND_DISABLE_WINDOWDECORATION env variable
No longer needed as we don't use the Wayland QPA.
2015-08-25 14:33:50 +02:00
Martin Gräßlin cc27042a7b [wayland] Drop threaded eglInitialize hack
The hack to perform the first eglInitialize in a thread is no longer
needed, as our internal QPA plugin is either able to share the
EGLDisplay or performs the potentially blocking eglInitialize in a
thread.
2015-08-25 14:33:50 +02:00
Martin Gräßlin e90fc1f8e1 [wayland] Drop QtWayland specific BypassWindowManagerHint workaround
No longer needed as our internal QPA is able to show windows with
BypassWindowManagerHint set.
2015-08-25 14:33:50 +02:00
Martin Gräßlin e0103b15b7 [wayland] Remove the specific socket pair for QtWayland
Our own QPA plugin shares the internal connection, so we don't need the
dedicated connection for the QPA any more.
2015-08-25 14:33:50 +02:00
Martin Gräßlin 4851470ff9 [wayland] Enforce our internal QPA plugin as QT_QPA_PLATFORM 2015-08-25 14:33:50 +02:00
Martin Gräßlin 8797f826f9 [wayland] Determine whether libinput is needed from plugin metadata
If the backend specifies
{
"input": false
}

in it's plugin metadata, it means that it does not handle input by
itself. In that case we can enforce libinput.

With this change one does no longer need to specify --libinput when
starting kwin_wayland on the drm or fbdev backend. So

kwin_wayland --xwayland

will bring up a fully functional kwin_wayland on drm platform.
2015-07-16 10:54:29 +02:00