From 5b76a35541948338142b8579926b24a9ebdfa221 Mon Sep 17 00:00:00 2001 From: fsLeg Date: Sat, 30 Nov 2024 23:13:05 +0300 Subject: [PATCH] yubikey-manager-qt: applied a patch to make it work again --- yubikey-manager-qt/363.patch | 198 ++++++++++++++++++ .../yubikey-manager-qt.SlackBuild | 6 +- 2 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 yubikey-manager-qt/363.patch diff --git a/yubikey-manager-qt/363.patch b/yubikey-manager-qt/363.patch new file mode 100644 index 0000000..f872451 --- /dev/null +++ b/yubikey-manager-qt/363.patch @@ -0,0 +1,198 @@ +--- a/ykman-gui/py/yubikey.py 2024-04-04 12:19:40.000000000 +0300 ++++ b/ykman-gui/py/yubikey.py 2024-11-30 22:44:48.514171262 +0300 +@@ -50,12 +50,10 @@ + if int(ykman_v.split(".")[0] ) > 4: + from yubikit.support import get_name + from ykman.device import list_all_devices, scan_devices +- from ykman.otp import ( +- _PrepareUploadFailed as PrepareUploadFailed +- , _prepare_upload_key as prepare_upload_key, generate_static_pw) ++ from ykman.otp import generate_static_pw + else: + from ykman import connect_to_device, scan_devices, get_name +- from ykman.otp import PrepareUploadFailed, prepare_upload_key, generate_static_pw ++ from ykman.otp import generate_static_pw + + from fido2.ctap2 import Ctap2, ClientPin + +@@ -391,26 +389,12 @@ + def random_key(self, bytes): + return b2a_hex(os.urandom(int(bytes))).decode('ascii') + +- def program_otp(self, slot, public_id, private_id, key, upload=False, +- app_version='unknown'): ++ def program_otp(self, slot, public_id, private_id, key, app_version='unknown'): + key = a2b_hex(key) + public_id = modhex_decode(public_id) + private_id = a2b_hex(private_id) + +- upload_url = None +- + with self._open_device([OtpConnection]) as conn: +- if upload: +- try: +- upload_url = prepare_upload_key( +- key, public_id, private_id, +- serial=self._dev_info['serial'], +- user_agent='ykman-qt/' + app_version) +- except PrepareUploadFailed as e: +- logger.debug('YubiCloud upload failed', exc_info=e) +- return failure('upload_failed', +- {'upload_errors': [err.name +- for err in e.errors]}) + try: + session = YubiOtpSession(conn) + session.put_configuration( +@@ -422,10 +406,7 @@ + return failure("write error") + + logger.debug('YubiOTP successfully programmed.') +- if upload_url: +- logger.debug('Upload url: %s', upload_url) +- +- return success({'upload_url': upload_url}) ++ return success() + + def program_challenge_response(self, slot, key, touch): + key = a2b_hex(key) +--- a/ykman-gui/qml/ContentStack.qml 2024-04-04 12:19:40.000000000 +0300 ++++ b/ykman-gui/qml/ContentStack.qml 2024-11-30 22:45:45.688033945 +0300 +@@ -168,14 +168,6 @@ + callback) + } + +- function otpUrl(url) { +- copyableConfirmationPopup.show( +- qsTr("Upload"), qsTr( +- "Complete the upload of your credential by visiting the following URL: %1").arg( +- url), +- ) +- } +- + function otpWriteError() { + snackbarError.show( + qsTr("Failed to modify %1. Make sure the YubiKey does not have restricted access.").arg( +--- a/ykman-gui/qml/OtpYubiOtpView.qml 2024-04-04 12:19:40.000000000 +0300 ++++ b/ykman-gui/qml/OtpYubiOtpView.qml 2024-11-30 22:57:20.300342533 +0300 +@@ -5,9 +5,6 @@ + import QtQuick.Controls.Material 2.2 + + ColumnLayout { +- property bool upload +- property string url +- + function useSerial() { + if (useSerialCb.checked) { + yubiKey.serialModhex(function (res) { +@@ -39,39 +36,14 @@ + function programYubiOtp() { + yubiKey.programOtp(views.selectedSlot, publicIdInput.text, + privateIdInput.text, secretKeyInput.text, +- enableUpload.checked, function (resp) { ++ function (resp) { + if (resp.success) { +- if (resp.upload_url) { +- if (yubiKey.isWinAdmin) { +- upload = true +- url = resp.upload_url +- otpUrl(url, views.otp()) +- +- views.otp() +- } else { +- if (Qt.openUrlExternally(resp.upload_url)) { +- snackbarSuccess.show(qsTr("Configured Yubico OTP credential. Preparing upload in web browser.")) +- views.otp() +- } else { +- snackbarError.show(qsTr("Configured Yubico OTP credential. Failed to open upload in web browser!")) +- } +- } +- +- } else { + snackbarSuccess.show( + qsTr("Configured Yubico OTP credential")) + views.otp() +- } +- + } else { + if (resp.error_id === 'write error') { + views.otpWriteError() +- } else if (resp.error_id === 'upload_failed') { +- snackbarError.show( +- qsTr( +- "Upload failed: %1 Credential not configured.").arg( +- getUploadErrorMessage( +- resp.upload_errors[0]))) + } else { + views.otpFailedToConfigureErrorPopup( + resp.error_id) +@@ -80,22 +52,6 @@ + }) + } + +- function getUploadErrorMessage(uploadErrorId) { +- // Keys defined in ykman library +- switch (uploadErrorId) { +- case 'CONNECTION_FAILED': +- return qsTr('Failed to open HTTPS connection.') +- case 'NOT_FOUND': +- return qsTr('Upload request not recognized by server.') +- case 'PUBLIC_ID_NOT_VV': +- return qsTr('Public ID must begin with "vv".') +- case 'PUBLIC_ID_OCCUPIED': +- return qsTr('Public ID is already in use.') +- case 'SERVICE_UNAVAILABLE': +- return qsTr('Service temporarily unavailable, please try again later.') +- } +- } +- + CustomContentColumn { + + ViewHeader { +@@ -191,31 +147,13 @@ + flat: true + Layout.alignment: Qt.AlignLeft | Qt.AlignBottom + } +- Row { +- id: row +- spacing: 5 +- Layout.alignment: Qt.AlignRight | Qt.AlignBottom +- CheckBox { +- id: enableUpload +- text: qsTr("Upload") +- Layout.alignment: Qt.AlignRight | Qt.AlignBottom +- ToolTip.delay: 1000 +- font.pixelSize: constants.h3 +- ToolTip.visible: hovered +- ToolTip.text: qsTr("Upload credential to YubiCloud (opens a web browser)") +- Material.foreground: yubicoBlue +- } + + FinishButton { ++ Layout.fillWidth: false ++ Layout.alignment: Qt.AlignRight | Qt.AlignBottom + + onClicked: finish() + enabled: publicIdInput.acceptableInput +- && privateIdInput.acceptableInput +- && secretKeyInput.acceptableInput +- toolTipText: qsTr("Finish and write the configuration to the YubiKey") +- Layout.alignment: Qt.AlignRight | Qt.AlignBottom +- } +- + } + + } +--- a/ykman-gui/qml/YubiKey.qml 2024-04-04 12:19:40.000000000 +0300 ++++ b/ykman-gui/qml/YubiKey.qml 2024-11-30 22:57:49.899269622 +0300 +@@ -332,9 +332,9 @@ + doCall('yubikey.controller.generate_static_pw', [keyboardLayout], cb) + } + +- function programOtp(slot, publicId, privateId, key, upload, cb) { ++ function programOtp(slot, publicId, privateId, key, cb) { + doCall('yubikey.controller.program_otp', +- [slot, publicId, privateId, key, upload, appVersion], cb) ++ [slot, publicId, privateId, key, appVersion], cb) + } + + function programChallengeResponse(slot, key, touch, cb) { diff --git a/yubikey-manager-qt/yubikey-manager-qt.SlackBuild b/yubikey-manager-qt/yubikey-manager-qt.SlackBuild index 0050a97..bd9a266 100755 --- a/yubikey-manager-qt/yubikey-manager-qt.SlackBuild +++ b/yubikey-manager-qt/yubikey-manager-qt.SlackBuild @@ -26,7 +26,7 @@ cd $(dirname $0) ; CWD=$(pwd) PRGNAM=yubikey-manager-qt VERSION=${VERSION:-1.2.6} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} TAG=${TAG:-fsleg} PKGTYPE=${PKGTYPE:-txz} @@ -82,6 +82,10 @@ find -L . \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; +# Apply a patch from PR#363 to make ykman-gui work again: +# https://github.com/Yubico/yubikey-manager-qt/pull/363 +patch -p1 < $CWD/363.patch + qmake CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ -- 2.46.3