1 |
commit: 50141c4028e664727b1006319ddd44b3cc50eb31 |
2 |
Author: Michael Palimaka <kensington <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Feb 17 01:13:31 2018 +0000 |
4 |
Commit: Michael Palimaka <kensington <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Feb 17 01:15:48 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/kde.git/commit/?id=50141c40 |
7 |
|
8 |
kde-plasma/kscreenlocker: add support for killing the screenlocker on consolekit |
9 |
|
10 |
Original script by Daniel Frey <djqfrey <AT> gmail.com>. |
11 |
Modifications by Lars Wendler <polynomial-c <AT> gentoo.org>. |
12 |
|
13 |
Bug: https://bugs.gentoo.org/647576 |
14 |
Package-Manager: Portage-2.3.19, Repoman-2.3.6 |
15 |
|
16 |
kde-plasma/kscreenlocker/files/ck-unlock-session | 220 +++++++++++++++++++++ |
17 |
.../files/kscreenlocker-consolekit-unlock.patch | 13 ++ |
18 |
.../kscreenlocker-5.12.49.9999.ebuild | 6 +- |
19 |
kde-plasma/kscreenlocker/kscreenlocker-9999.ebuild | 6 +- |
20 |
kde-plasma/kscreenlocker/metadata.xml | 3 + |
21 |
5 files changed, 246 insertions(+), 2 deletions(-) |
22 |
|
23 |
diff --git a/kde-plasma/kscreenlocker/files/ck-unlock-session b/kde-plasma/kscreenlocker/files/ck-unlock-session |
24 |
new file mode 100644 |
25 |
index 0000000000..6ce6935b06 |
26 |
--- /dev/null |
27 |
+++ b/kde-plasma/kscreenlocker/files/ck-unlock-session |
28 |
@@ -0,0 +1,220 @@ |
29 |
+#!/bin/sh |
30 |
+ |
31 |
+# This script is to make unlocking using OpenRC/Consolekit easier when the KDE Screenlocker breaks. |
32 |
+# |
33 |
+# Version: 0.2 |
34 |
+# Date written: February 2, 2018 |
35 |
+# Last modification: February 17, 2018 |
36 |
+# |
37 |
+# Copyright (C) 2018 Daniel Frey |
38 |
+# Copyright (C) 2018 Lars Wendler |
39 |
+# |
40 |
+# This script is free software; you can redistribute it and/or |
41 |
+# modify it under the terms of the GNU General Public License |
42 |
+# as published by the Free Software Foundation; either version 2 |
43 |
+# of the License, or (at your option) any later version. |
44 |
+# |
45 |
+# This script is distributed in the hope that it will be useful, |
46 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of |
47 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
48 |
+# GNU General Public License for more details. |
49 |
+# |
50 |
+# |
51 |
+# Some notes: |
52 |
+# -The switch processing/argument handling is very basic. |
53 |
+# -This script assumes session names start with "Session" when listing |
54 |
+# sessions. This is settable via a variable. |
55 |
+# |
56 |
+# Possible actions: |
57 |
+# -h : Show help screen |
58 |
+# -l : List current consolekit sessions |
59 |
+# -u : Unlock specified session (one parameter required - the session name) |
60 |
+# -a : Attempt to unlock all sessions |
61 |
+ |
62 |
+# Return code documentation |
63 |
+# |
64 |
+# 0: Script executed normally |
65 |
+# 1: Root access is not present for script |
66 |
+# 2: No arguments passed |
67 |
+# 3: Multiple actions requested, can only do one at a time |
68 |
+# 4: Argument passed was not recognized |
69 |
+# 5: Multiple arguments passed for unlock single session, only one needed |
70 |
+# 6: The argument required for unlocksession() is missing (internal error) |
71 |
+ |
72 |
+SCRIPTNAME="$(basename $0)" |
73 |
+ |
74 |
+# Return code constants |
75 |
+readonly ERR_NORMAL_OPERATION=0 |
76 |
+readonly ERR_NO_ROOT=1 |
77 |
+readonly ERR_NO_ARGS=2 |
78 |
+readonly ERR_TOO_MANY_ACTIONS=3 |
79 |
+readonly ERR_INVALID_ARGUMENTS=4 |
80 |
+readonly ERR_TOO_MANY_ARGS=5 |
81 |
+readonly ERR_INTERNAL_ARG_MISSING=6 |
82 |
+ |
83 |
+# Action parameter constants |
84 |
+readonly ACTION_NONE=0 |
85 |
+readonly ACTION_HELP=1 |
86 |
+readonly ACTION_LIST=2 |
87 |
+readonly ACTION_UNLOCKALL=3 |
88 |
+readonly ACTION_UNLOCK=4 |
89 |
+ |
90 |
+# This is what's used to look for a session via consolekit. |
91 |
+# By default, assume it is prefixed with "Session". |
92 |
+SESSION_SEARCH_PREFIX="Session" |
93 |
+ |
94 |
+# Check to make sure script has root access, if not... abort now! |
95 |
+if [ "$(id -u)" -ne 0 ]; then |
96 |
+ echo "This script must be run as root." |
97 |
+ exit ${ERR_NO_ROOT} |
98 |
+fi |
99 |
+ |
100 |
+showhelp() { |
101 |
+ cat <<EOF |
102 |
+${SCRIPTNAME}: a script that helps unlock consolekit sessions |
103 |
+ |
104 |
+Usage: ${SCRIPTNAME} [action] [parameters] |
105 |
+ |
106 |
+Actions: |
107 |
+ -l : list current sessions available for unlocking |
108 |
+ -u : unlock session specified as a parameter |
109 |
+ -a : attempt to unlock all current sessions |
110 |
+ -h : this screen |
111 |
+ |
112 |
+Parameters: |
113 |
+ The -u parameter requires a session name to unlock, use -l to |
114 |
+ list sessions. |
115 |
+ |
116 |
+Example: |
117 |
+ To unlock a single session, use: |
118 |
+ ${SCRIPTNAME} -u Session1 |
119 |
+ |
120 |
+No arguments will show this screen. |
121 |
+EOF |
122 |
+} |
123 |
+ |
124 |
+listsessions() { |
125 |
+ # Get a list of all sessions, and remove the full colon from the session name |
126 |
+ ALLSESSIONS=$(ck-list-sessions | grep "^${SESSION_SEARCH_PREFIX}" | awk -F : '{print $1}') |
127 |
+ |
128 |
+ echo |
129 |
+ echo "Sessions present on this machine, space-delineated:" |
130 |
+ echo |
131 |
+ echo ${ALLSESSIONS} |
132 |
+ echo |
133 |
+ echo |
134 |
+ echo "Session detail (to help locate a specific session:" |
135 |
+ ck-list-sessions | grep -A 2 "^${SESSION_SEARCH_PREFIX}" |
136 |
+} |
137 |
+ |
138 |
+unlocksession() { |
139 |
+ # This function expects one parameter set (the session to unlock). |
140 |
+ # Make sure the parameter exists before continuing. |
141 |
+ if [ -z "${1}" ]; then |
142 |
+ showhelp |
143 |
+ exit ${ERR_INTERNAL_ARG_MISSING} |
144 |
+ fi |
145 |
+ |
146 |
+ echo "Attempting to unlock session $1; messages from dbus are not suppressed." |
147 |
+ |
148 |
+ # Finally, request the unlock. |
149 |
+ dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/$1 org.freedesktop.ConsoleKit.Session.Unlock |
150 |
+} |
151 |
+ |
152 |
+unlockallsessions() { |
153 |
+ # Get a list of all sessions, and remove the full colon from the session name |
154 |
+ ALLSESSIONS=$(ck-list-sessions | grep "^${SESSION_SEARCH_PREFIX}" | awk -F : '{print $1}') |
155 |
+ |
156 |
+ echo "Attempting to unlock all sessions. Messages from dbus are not suppressed." |
157 |
+ echo |
158 |
+ # Loop through results, attempt to unlock all sessions. |
159 |
+ # Count them and report at the end. |
160 |
+ COUNT=0 |
161 |
+ for i in ${ALLSESSIONS}; do |
162 |
+ dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/$i org.freedesktop.ConsoleKit.Session.Unlock |
163 |
+ let "COUNT+=1" |
164 |
+ done |
165 |
+ |
166 |
+ echo |
167 |
+ echo "Attempted to unlock ${COUNT} session(s)." |
168 |
+} |
169 |
+ |
170 |
+check_actions() { |
171 |
+ # Make sure multiple actions are not chosen. |
172 |
+ if [ ${ACTION} -ne ${ACTION_NONE} ]; then |
173 |
+ echo "You can only declare one action at a time!" |
174 |
+ echo "" |
175 |
+ showhelp |
176 |
+ exit ${ERR_TOO_MANY_ACTIONS} |
177 |
+ fi |
178 |
+} |
179 |
+ |
180 |
+# Start of "main" routine |
181 |
+ |
182 |
+# Initialize variables: |
183 |
+# ACTION=default 0; used to make sure more than one action are not |
184 |
+# specified at the same time. If an invalid argument was passed |
185 |
+# (e.g. one without the hyphen prefix) it will be caught as well. |
186 |
+ACTION="${ACTION_NONE}" |
187 |
+ |
188 |
+# Show help if no arguments provided at all |
189 |
+if [ $# -eq 0 ]; then |
190 |
+ showhelp |
191 |
+ exit ${ERR_NO_ARGS} |
192 |
+fi |
193 |
+ |
194 |
+# Process arguments passed, setting environment appropriately. |
195 |
+# During this check, ensure only one action was requested. This |
196 |
+# script will not do multiple things at a time. |
197 |
+while getopts “hlau:” OPTION; do |
198 |
+ case ${OPTION} in |
199 |
+ h) # Help action |
200 |
+ check_actions |
201 |
+ ACTION=${ACTION_HELP} |
202 |
+ ;; |
203 |
+ l) # List action |
204 |
+ check_actions |
205 |
+ ACTION="${ACTION_LIST}" |
206 |
+ ;; |
207 |
+ a) # Enable all USB hubs/devices action |
208 |
+ check_actions |
209 |
+ ACTION="${ACTION_UNLOCKALL}" |
210 |
+ ;; |
211 |
+ u) # Enable specific hub/device via find command action |
212 |
+ check_actions |
213 |
+ ACTION="${ACTION_UNLOCK}" |
214 |
+ |
215 |
+ # Save session name passed for later |
216 |
+ UNLOCKSESSION="${OPTARG}" |
217 |
+ ;; |
218 |
+ ?) # Unknown parameter |
219 |
+ showhelp |
220 |
+ exit ${ERR_INVALID_ARGUMENTS} |
221 |
+ ;; |
222 |
+ esac |
223 |
+done |
224 |
+ |
225 |
+# If script reaches this point, only one action was specified, so it is safe |
226 |
+# to continue processing. |
227 |
+case ${ACTION} in |
228 |
+ ${ACTION_HELP}) # help action |
229 |
+ showhelp |
230 |
+ ;; |
231 |
+ ${ACTION_LIST}) # list action |
232 |
+ listsessions |
233 |
+ ;; |
234 |
+ ${ACTION_UNLOCKALL}) # unlock all sessions |
235 |
+ unlockallsessions |
236 |
+ ;; |
237 |
+ ${ACTION_UNLOCK}) # unlock single session |
238 |
+ unlocksession ${UNLOCKSESSION} |
239 |
+ ;; |
240 |
+ *) |
241 |
+ echo "Unrecognized action." |
242 |
+ echo |
243 |
+ showhelp |
244 |
+ exit ${ERR_INVALID_ARGUMENTS} |
245 |
+ ;; |
246 |
+esac |
247 |
+ |
248 |
+exit ${ERR_NORMAL_OPERATION} |
249 |
|
250 |
diff --git a/kde-plasma/kscreenlocker/files/kscreenlocker-consolekit-unlock.patch b/kde-plasma/kscreenlocker/files/kscreenlocker-consolekit-unlock.patch |
251 |
new file mode 100644 |
252 |
index 0000000000..b0e4011d2b |
253 |
--- /dev/null |
254 |
+++ b/kde-plasma/kscreenlocker/files/kscreenlocker-consolekit-unlock.patch |
255 |
@@ -0,0 +1,13 @@ |
256 |
+--- a/abstractlocker.cpp |
257 |
++++ b/abstractlocker.cpp |
258 |
+@@ -52,9 +52,8 @@ void BackgroundWindow::paintEvent(QPaintEvent* ) |
259 |
+ auto text = ki18n("The screen locker is broken and unlocking is not possible anymore.\n" |
260 |
+ "In order to unlock switch to a virtual terminal (e.g. Ctrl+Alt+F2),\n" |
261 |
+ "log in and execute the command:\n\n" |
262 |
+- "loginctl unlock-session %1\n\n" |
263 |
++ "ck-unlock-session\n\n" |
264 |
+ "Afterwards switch back to the running session (Ctrl+Alt+F%2)."); |
265 |
+- text = text.subs(QString::fromLocal8Bit(qgetenv("XDG_SESSION_ID"))); |
266 |
+ text = text.subs(QString::fromLocal8Bit(qgetenv("XDG_VTNR"))); |
267 |
+ p.setPen(Qt::white); |
268 |
+ QFont f = p.font(); |
269 |
|
270 |
diff --git a/kde-plasma/kscreenlocker/kscreenlocker-5.12.49.9999.ebuild b/kde-plasma/kscreenlocker/kscreenlocker-5.12.49.9999.ebuild |
271 |
index 402ee0bd5d..8c9e48f8cf 100644 |
272 |
--- a/kde-plasma/kscreenlocker/kscreenlocker-5.12.49.9999.ebuild |
273 |
+++ b/kde-plasma/kscreenlocker/kscreenlocker-5.12.49.9999.ebuild |
274 |
@@ -9,7 +9,7 @@ inherit kde5 pam |
275 |
|
276 |
DESCRIPTION="Library and components for secure lock screen architecture" |
277 |
KEYWORDS="" |
278 |
-IUSE="+pam seccomp" |
279 |
+IUSE="consolekit +pam seccomp" |
280 |
|
281 |
REQUIRED_USE="seccomp? ( pam )" |
282 |
|
283 |
@@ -58,6 +58,8 @@ RESTRICT+=" test" |
284 |
src_prepare() { |
285 |
kde5_src_prepare |
286 |
|
287 |
+ use consolekit && eapply "${FILESDIR}"/${PN}-consolekit-unlock.patch |
288 |
+ |
289 |
use test || sed -i \ |
290 |
-e "/add_subdirectory(autotests)/ s/^/#/" greeter/CMakeLists.txt || die |
291 |
} |
292 |
@@ -85,6 +87,8 @@ src_install() { |
293 |
newpamd "${FILESDIR}/kde.pam" kde |
294 |
newpamd "${FILESDIR}/kde-np.pam" kde-np |
295 |
|
296 |
+ use consolekit && dobin "${FILESDIR}"/ck-unlock-session |
297 |
+ |
298 |
if ! use pam; then |
299 |
chown root "${ED}"usr/$(get_libdir)/libexec/kcheckpass || die |
300 |
chmod +s "${ED}"usr/$(get_libdir)/libexec/kcheckpass || die |
301 |
|
302 |
diff --git a/kde-plasma/kscreenlocker/kscreenlocker-9999.ebuild b/kde-plasma/kscreenlocker/kscreenlocker-9999.ebuild |
303 |
index 402ee0bd5d..8c9e48f8cf 100644 |
304 |
--- a/kde-plasma/kscreenlocker/kscreenlocker-9999.ebuild |
305 |
+++ b/kde-plasma/kscreenlocker/kscreenlocker-9999.ebuild |
306 |
@@ -9,7 +9,7 @@ inherit kde5 pam |
307 |
|
308 |
DESCRIPTION="Library and components for secure lock screen architecture" |
309 |
KEYWORDS="" |
310 |
-IUSE="+pam seccomp" |
311 |
+IUSE="consolekit +pam seccomp" |
312 |
|
313 |
REQUIRED_USE="seccomp? ( pam )" |
314 |
|
315 |
@@ -58,6 +58,8 @@ RESTRICT+=" test" |
316 |
src_prepare() { |
317 |
kde5_src_prepare |
318 |
|
319 |
+ use consolekit && eapply "${FILESDIR}"/${PN}-consolekit-unlock.patch |
320 |
+ |
321 |
use test || sed -i \ |
322 |
-e "/add_subdirectory(autotests)/ s/^/#/" greeter/CMakeLists.txt || die |
323 |
} |
324 |
@@ -85,6 +87,8 @@ src_install() { |
325 |
newpamd "${FILESDIR}/kde.pam" kde |
326 |
newpamd "${FILESDIR}/kde-np.pam" kde-np |
327 |
|
328 |
+ use consolekit && dobin "${FILESDIR}"/ck-unlock-session |
329 |
+ |
330 |
if ! use pam; then |
331 |
chown root "${ED}"usr/$(get_libdir)/libexec/kcheckpass || die |
332 |
chmod +s "${ED}"usr/$(get_libdir)/libexec/kcheckpass || die |
333 |
|
334 |
diff --git a/kde-plasma/kscreenlocker/metadata.xml b/kde-plasma/kscreenlocker/metadata.xml |
335 |
index 2fdbf33d96..099a76f8dd 100644 |
336 |
--- a/kde-plasma/kscreenlocker/metadata.xml |
337 |
+++ b/kde-plasma/kscreenlocker/metadata.xml |
338 |
@@ -5,4 +5,7 @@ |
339 |
<email>kde@g.o</email> |
340 |
<name>Gentoo KDE Project</name> |
341 |
</maintainer> |
342 |
+ <use> |
343 |
+ <flag name="consolekit">Add support for killing the screenlocker when <pkg>sys-auth/consolekit</pkg> is the session tracker</flag> |
344 |
+ </use> |
345 |
</pkgmetadata> |