public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michael Palimaka" <kensington@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/kde:master commit in: kde-plasma/kscreenlocker/files/, kde-plasma/kscreenlocker/
Date: Sat, 17 Feb 2018 01:16:03 +0000 (UTC)	[thread overview]
Message-ID: <1518830148.50141c4028e664727b1006319ddd44b3cc50eb31.kensington@gentoo> (raw)

commit:     50141c4028e664727b1006319ddd44b3cc50eb31
Author:     Michael Palimaka <kensington <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 17 01:13:31 2018 +0000
Commit:     Michael Palimaka <kensington <AT> gentoo <DOT> org>
CommitDate: Sat Feb 17 01:15:48 2018 +0000
URL:        https://gitweb.gentoo.org/proj/kde.git/commit/?id=50141c40

kde-plasma/kscreenlocker: add support for killing the screenlocker on consolekit

Original script by Daniel Frey <djqfrey <AT> gmail.com>.
Modifications by Lars Wendler <polynomial-c <AT> gentoo.org>.

Bug: https://bugs.gentoo.org/647576
Package-Manager: Portage-2.3.19, Repoman-2.3.6

 kde-plasma/kscreenlocker/files/ck-unlock-session   | 220 +++++++++++++++++++++
 .../files/kscreenlocker-consolekit-unlock.patch    |  13 ++
 .../kscreenlocker-5.12.49.9999.ebuild              |   6 +-
 kde-plasma/kscreenlocker/kscreenlocker-9999.ebuild |   6 +-
 kde-plasma/kscreenlocker/metadata.xml              |   3 +
 5 files changed, 246 insertions(+), 2 deletions(-)

diff --git a/kde-plasma/kscreenlocker/files/ck-unlock-session b/kde-plasma/kscreenlocker/files/ck-unlock-session
new file mode 100644
index 0000000000..6ce6935b06
--- /dev/null
+++ b/kde-plasma/kscreenlocker/files/ck-unlock-session
@@ -0,0 +1,220 @@
+#!/bin/sh
+
+# This script is to make unlocking using OpenRC/Consolekit easier when the KDE Screenlocker breaks.
+#
+# Version: 0.2
+# Date written: February 2, 2018
+# Last modification: February 17, 2018
+#
+# Copyright (C) 2018 Daniel Frey
+# Copyright (C) 2018 Lars Wendler
+#
+# This script is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This script is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+#
+# Some notes:
+#   -The switch processing/argument handling is very basic.
+#   -This script assumes session names start with "Session" when listing
+#    sessions. This is settable via a variable.
+#
+# Possible actions:
+#   -h : Show help screen
+#   -l : List current consolekit sessions
+#   -u : Unlock specified session (one parameter required - the session name)
+#   -a : Attempt to unlock all sessions
+
+# Return code documentation
+#
+#  0: Script executed normally
+#  1: Root access is not present for script
+#  2: No arguments passed
+#  3: Multiple actions requested, can only do one at a time
+#  4: Argument passed was not recognized
+#  5: Multiple arguments passed for unlock single session, only one needed
+#  6: The argument required for unlocksession() is missing (internal error)
+
+SCRIPTNAME="$(basename $0)"
+
+# Return code constants
+readonly ERR_NORMAL_OPERATION=0
+readonly ERR_NO_ROOT=1
+readonly ERR_NO_ARGS=2
+readonly ERR_TOO_MANY_ACTIONS=3
+readonly ERR_INVALID_ARGUMENTS=4
+readonly ERR_TOO_MANY_ARGS=5
+readonly ERR_INTERNAL_ARG_MISSING=6
+
+# Action parameter constants
+readonly ACTION_NONE=0
+readonly ACTION_HELP=1
+readonly ACTION_LIST=2
+readonly ACTION_UNLOCKALL=3
+readonly ACTION_UNLOCK=4
+
+# This is what's used to look for a session via consolekit.
+# By default, assume it is prefixed with "Session".
+SESSION_SEARCH_PREFIX="Session"
+
+# Check to make sure script has root access, if not... abort now!
+if [ "$(id -u)" -ne 0 ]; then
+	echo "This script must be run as root."
+	exit ${ERR_NO_ROOT}
+fi
+
+showhelp() {
+	cat <<EOF
+${SCRIPTNAME}: a script that helps unlock consolekit sessions
+
+Usage: ${SCRIPTNAME} [action] [parameters]
+
+Actions:
+	-l : list current sessions available for unlocking 
+	-u : unlock session specified as a parameter
+	-a : attempt to unlock all current sessions
+	-h : this screen
+
+Parameters:
+	The -u parameter requires a session name to unlock, use -l to 
+	list sessions.
+
+Example:
+	To unlock a single session, use:
+	${SCRIPTNAME} -u Session1
+
+No arguments will show this screen.
+EOF
+}
+
+listsessions() {
+	# Get a list of all sessions, and remove the full colon from the session name
+	ALLSESSIONS=$(ck-list-sessions | grep "^${SESSION_SEARCH_PREFIX}" | awk -F : '{print $1}')
+
+	echo
+	echo "Sessions present on this machine, space-delineated:"
+	echo
+	echo ${ALLSESSIONS}
+	echo
+	echo
+	echo "Session detail (to help locate a specific session:"
+	ck-list-sessions | grep -A 2 "^${SESSION_SEARCH_PREFIX}"
+}
+
+unlocksession() {
+	# This function expects one parameter set (the session to unlock).
+	# Make sure the parameter exists before continuing.
+	if [ -z "${1}" ]; then 
+		showhelp
+		exit ${ERR_INTERNAL_ARG_MISSING}
+	fi
+
+	echo "Attempting to unlock session $1; messages from dbus are not suppressed."
+
+	# Finally, request the unlock.
+	dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/$1 org.freedesktop.ConsoleKit.Session.Unlock
+}
+
+unlockallsessions() {
+	# Get a list of all sessions, and remove the full colon from the session name
+	ALLSESSIONS=$(ck-list-sessions | grep "^${SESSION_SEARCH_PREFIX}" | awk -F : '{print $1}')
+
+	echo "Attempting to unlock all sessions. Messages from dbus are not suppressed."
+	echo
+	# Loop through results, attempt to unlock all sessions.
+	# Count them and report at the end.
+	COUNT=0
+	for i in ${ALLSESSIONS}; do
+		dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/$i org.freedesktop.ConsoleKit.Session.Unlock
+		let "COUNT+=1"
+	done
+
+	echo
+	echo "Attempted to unlock ${COUNT} session(s)."
+}
+
+check_actions() {
+	# Make sure multiple actions are not chosen.
+	if [ ${ACTION} -ne ${ACTION_NONE} ]; then
+		echo "You can only declare one action at a time!"
+		echo ""
+		showhelp
+		exit ${ERR_TOO_MANY_ACTIONS}
+	fi
+}
+
+# Start of "main" routine
+
+# Initialize variables:
+#     ACTION=default 0; used to make sure more than one action are not
+#          specified at the same time. If an invalid argument was passed
+#          (e.g. one without the hyphen prefix) it will be caught as well.
+ACTION="${ACTION_NONE}"
+
+# Show help if no arguments provided at all
+if  [ $# -eq 0 ]; then
+	showhelp
+	exit ${ERR_NO_ARGS}
+fi
+
+# Process arguments passed, setting environment appropriately.
+# During this check, ensure only one action was requested. This
+# script will not do multiple things at a time.
+while getopts “hlau:” OPTION; do
+	case ${OPTION} in
+		h)	# Help action
+			check_actions
+			ACTION=${ACTION_HELP}
+		;;
+                l)	# List action
+			check_actions
+			ACTION="${ACTION_LIST}"
+		;;
+		a)	# Enable all USB hubs/devices action
+			check_actions
+			ACTION="${ACTION_UNLOCKALL}"
+		;;
+		u)	# Enable specific hub/device via find command action
+			check_actions
+			ACTION="${ACTION_UNLOCK}"
+
+			# Save session name passed for later
+			UNLOCKSESSION="${OPTARG}"
+		;;
+		?)	# Unknown parameter
+			showhelp
+			exit ${ERR_INVALID_ARGUMENTS}
+		;;
+	esac
+done
+
+# If script reaches this point, only one action was specified, so it is safe
+# to continue processing.
+case ${ACTION} in
+	${ACTION_HELP})		# help action
+		showhelp
+	;;
+	${ACTION_LIST})		# list action
+		listsessions
+	;;
+	${ACTION_UNLOCKALL}) 	# unlock all sessions
+		unlockallsessions
+	;;
+	${ACTION_UNLOCK})	# unlock single session
+		unlocksession ${UNLOCKSESSION}
+	;;
+	*)
+		echo "Unrecognized action."
+		echo
+		showhelp
+		exit ${ERR_INVALID_ARGUMENTS}
+	;;
+esac
+
+exit ${ERR_NORMAL_OPERATION}

diff --git a/kde-plasma/kscreenlocker/files/kscreenlocker-consolekit-unlock.patch b/kde-plasma/kscreenlocker/files/kscreenlocker-consolekit-unlock.patch
new file mode 100644
index 0000000000..b0e4011d2b
--- /dev/null
+++ b/kde-plasma/kscreenlocker/files/kscreenlocker-consolekit-unlock.patch
@@ -0,0 +1,13 @@
+--- a/abstractlocker.cpp
++++ b/abstractlocker.cpp
+@@ -52,9 +52,8 @@ void BackgroundWindow::paintEvent(QPaintEvent* )
+         auto text = ki18n("The screen locker is broken and unlocking is not possible anymore.\n"
+                           "In order to unlock switch to a virtual terminal (e.g. Ctrl+Alt+F2),\n"
+                           "log in and execute the command:\n\n"
+-                          "loginctl unlock-session %1\n\n"
++                          "ck-unlock-session\n\n"
+                           "Afterwards switch back to the running session (Ctrl+Alt+F%2).");
+-        text = text.subs(QString::fromLocal8Bit(qgetenv("XDG_SESSION_ID")));
+         text = text.subs(QString::fromLocal8Bit(qgetenv("XDG_VTNR")));
+         p.setPen(Qt::white);
+         QFont f = p.font();

diff --git a/kde-plasma/kscreenlocker/kscreenlocker-5.12.49.9999.ebuild b/kde-plasma/kscreenlocker/kscreenlocker-5.12.49.9999.ebuild
index 402ee0bd5d..8c9e48f8cf 100644
--- a/kde-plasma/kscreenlocker/kscreenlocker-5.12.49.9999.ebuild
+++ b/kde-plasma/kscreenlocker/kscreenlocker-5.12.49.9999.ebuild
@@ -9,7 +9,7 @@ inherit kde5 pam
 
 DESCRIPTION="Library and components for secure lock screen architecture"
 KEYWORDS=""
-IUSE="+pam seccomp"
+IUSE="consolekit +pam seccomp"
 
 REQUIRED_USE="seccomp? ( pam )"
 
@@ -58,6 +58,8 @@ RESTRICT+=" test"
 src_prepare() {
 	kde5_src_prepare
 
+	use consolekit && eapply "${FILESDIR}"/${PN}-consolekit-unlock.patch
+
 	use test || sed -i \
 		-e "/add_subdirectory(autotests)/ s/^/#/" greeter/CMakeLists.txt || die
 }
@@ -85,6 +87,8 @@ src_install() {
 	newpamd "${FILESDIR}/kde.pam" kde
 	newpamd "${FILESDIR}/kde-np.pam" kde-np
 
+	use consolekit && dobin "${FILESDIR}"/ck-unlock-session
+
 	if ! use pam; then
 		chown root "${ED}"usr/$(get_libdir)/libexec/kcheckpass || die
 		chmod +s "${ED}"usr/$(get_libdir)/libexec/kcheckpass || die

diff --git a/kde-plasma/kscreenlocker/kscreenlocker-9999.ebuild b/kde-plasma/kscreenlocker/kscreenlocker-9999.ebuild
index 402ee0bd5d..8c9e48f8cf 100644
--- a/kde-plasma/kscreenlocker/kscreenlocker-9999.ebuild
+++ b/kde-plasma/kscreenlocker/kscreenlocker-9999.ebuild
@@ -9,7 +9,7 @@ inherit kde5 pam
 
 DESCRIPTION="Library and components for secure lock screen architecture"
 KEYWORDS=""
-IUSE="+pam seccomp"
+IUSE="consolekit +pam seccomp"
 
 REQUIRED_USE="seccomp? ( pam )"
 
@@ -58,6 +58,8 @@ RESTRICT+=" test"
 src_prepare() {
 	kde5_src_prepare
 
+	use consolekit && eapply "${FILESDIR}"/${PN}-consolekit-unlock.patch
+
 	use test || sed -i \
 		-e "/add_subdirectory(autotests)/ s/^/#/" greeter/CMakeLists.txt || die
 }
@@ -85,6 +87,8 @@ src_install() {
 	newpamd "${FILESDIR}/kde.pam" kde
 	newpamd "${FILESDIR}/kde-np.pam" kde-np
 
+	use consolekit && dobin "${FILESDIR}"/ck-unlock-session
+
 	if ! use pam; then
 		chown root "${ED}"usr/$(get_libdir)/libexec/kcheckpass || die
 		chmod +s "${ED}"usr/$(get_libdir)/libexec/kcheckpass || die

diff --git a/kde-plasma/kscreenlocker/metadata.xml b/kde-plasma/kscreenlocker/metadata.xml
index 2fdbf33d96..099a76f8dd 100644
--- a/kde-plasma/kscreenlocker/metadata.xml
+++ b/kde-plasma/kscreenlocker/metadata.xml
@@ -5,4 +5,7 @@
 		<email>kde@gentoo.org</email>
 		<name>Gentoo KDE Project</name>
 	</maintainer>
+	<use>
+		<flag name="consolekit">Add support for killing the screenlocker when <pkg>sys-auth/consolekit</pkg> is the session tracker</flag>
+	</use>
 </pkgmetadata>


             reply	other threads:[~2018-02-17  1:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-17  1:16 Michael Palimaka [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-08-01 18:44 [gentoo-commits] proj/kde:master commit in: kde-plasma/kscreenlocker/files/, kde-plasma/kscreenlocker/ Andreas Sturmlechner
2020-08-02 11:16 Andreas Sturmlechner
2023-12-20 15:47 Sam James
2023-12-20 15:49 Sam James
2023-12-20 15:55 Sam James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518830148.50141c4028e664727b1006319ddd44b3cc50eb31.kensington@gentoo \
    --to=kensington@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox