Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB Hotplug Detection and TouchID lid close fix #10092

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,12 @@ include_directories(SYSTEM ${ZLIB_INCLUDE_DIR})
if(WITH_XC_YUBIKEY)
find_package(PCSC REQUIRED)
include_directories(SYSTEM ${PCSC_INCLUDE_DIRS})

if(UNIX AND NOT APPLE)
find_library(LIBUSB_LIBRARIES NAMES usb-1.0 REQUIRED)
find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h PATH_SUFFIXES "libusb-1.0" "libusb" REQUIRED)
include_directories(SYSTEM ${LIBUSB_INCLUDE_DIR})
endif()
endif()

if(UNIX)
Expand Down
1 change: 1 addition & 0 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ Files: share/icons/application/scalable/actions/application-exit.svg
share/icons/application/scalable/actions/username-copy.svg
share/icons/application/scalable/actions/view-history.svg
share/icons/application/scalable/actions/web.svg
share/icons/application/scalable/actions/yubikey-refresh.svg
share/icons/application/scalable/apps/internet-web-browser.svg
share/icons/application/scalable/apps/keepassxc.svg
share/icons/application/scalable/apps/keepassxc-dark.svg
Expand Down
10 changes: 10 additions & 0 deletions share/icons/application/scalable/actions/yubikey-refresh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<file>application/scalable/actions/username-copy.svg</file>
<file>application/scalable/actions/view-history.svg</file>
<file>application/scalable/actions/web.svg</file>
<file>application/scalable/actions/yubikey-refresh.svg</file>
<file>application/scalable/apps/freedesktop.svg</file>
<file>application/scalable/apps/internet-web-browser.svg</file>
<file>application/scalable/apps/keepassxc.svg</file>
Expand Down
140 changes: 62 additions & 78 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1500,39 +1500,10 @@ Backup database located at %2</source>
<source>Password field</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter Additional Credentials (if any):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Key File:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;In addition to a password, you can use a secret file to enhance the security of your database. This file can be generated in your database&apos;s security settings.&lt;/p&gt;&lt;p&gt;This is &lt;strong&gt;not&lt;/strong&gt; your *.kdbx database file!&lt;br&gt;If you do not have a key file, leave this field empty.&lt;/p&gt;&lt;p&gt;Click for more information…&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Key file help</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware key slot selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware Key:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;You can use a hardware security key such as a &lt;strong&gt;YubiKey&lt;/strong&gt; or &lt;strong&gt;OnlyKey&lt;/strong&gt; with slots configured for HMAC-SHA1.&lt;/p&gt;
&lt;p&gt;Click for more information…&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware key help</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Key file to unlock the database</source>
<translation type="unfinished"></translation>
Expand All @@ -1545,14 +1516,6 @@ Backup database located at %2</source>
<source>Browse…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Refresh hardware tokens</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unlock Database</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -1639,28 +1602,59 @@ To prevent this error from appearing, you must go to &quot;Database Settings / S
<translation type="unfinished"></translation>
</message>
<message>
<source>You cannot use your database file as a key file.
If you do not have a key file, please leave the field empty.</source>
<source>authenticate to access the database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Detecting hardware keys…</source>
<source>Failed to authenticate with Quick Unlock: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No hardware keys detected</source>
<source>Select Key File:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select hardware key…</source>
<source>&lt;p&gt;In addition to a password, you can use a secret file to enhance the security of your database. This file can be generated in your database&apos;s security settings.&lt;/p&gt;&lt;p&gt;This is &lt;strong&gt;not&lt;/strong&gt; your *.kdbx database file!&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>authenticate to access the database</source>
<source>Click to add a key file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to authenticate with Quick Unlock: %1</source>
<source>&lt;a href=&quot;#&quot; style=&quot;text-decoration: underline&quot;&gt;I have a key file&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use hardware key [Serial: %1]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use hardware key</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Your database file is NOT a key file!
If you don&apos;t have a key file or don&apos;t know what that is, you don&apos;t have to select one.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>KeePassXC database file selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The file you selected looks like a database file.
A database file is NOT a key file!

Are you sure you want to continue with this file?.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No hardware keys found.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Refresh Hardware Keys</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down Expand Up @@ -9633,10 +9627,6 @@ Example: JBSWY3DPEHPK3PXP</source>
</context>
<context>
<name>YubiKey</name>
<message>
<source>%1 No interface, slot %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>General: </source>
<translation type="unfinished"></translation>
Expand All @@ -9648,14 +9638,6 @@ Example: JBSWY3DPEHPK3PXP</source>
</context>
<context>
<name>YubiKeyEditWidget</name>
<message>
<source>Refresh hardware tokens</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware key slot selection</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -9700,28 +9682,17 @@ Example: JBSWY3DPEHPK3PXP</source>
<source>&lt;p&gt;If you own a &lt;a href=&quot;https://www.yubico.com/&quot;&gt;YubiKey&lt;/a&gt; or &lt;a href=&quot;https://onlykey.io&quot;&gt;OnlyKey&lt;/a&gt;, you can use it for additional security.&lt;/p&gt;&lt;p&gt;The key requires one of its slots to be programmed as &lt;a href=&quot;https://docs.yubico.com/yesdk/users-manual/application-otp/challenge-response.html&quot;&gt;HMAC-SHA1 Challenge-Response&lt;/a&gt;.&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YubiKeyInterface</name>
<message>
<source>%1 Invalid slot specified - %2</source>
<source>Refresh hardware keys</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YubiKeyInterfacePCSC</name>
<message>
<source>(PCSC) %1 [%2] Challenge-Response - Slot %3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The YubiKey PCSC interface has not been initialized.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware key is currently in use.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Could not find or access hardware key with serial number %1. Please present it to continue. </source>
<translation type="unfinished"></translation>
Expand All @@ -9738,19 +9709,26 @@ Example: JBSWY3DPEHPK3PXP</source>
<source>Failed to complete a challenge-response, the PCSC error code was: %1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YubiKeyInterfaceUSB</name>
<message>
<source>Unknown</source>
<source>(NFC) %1 [%2] - Slot %3, %4</source>
<comment>YubiKey display fields</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Press</source>
<comment>USB Challenge-Response Key interaction request</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>(USB) %1 [%2] Configured Slot - %3</source>
<source>Passive</source>
<comment>USB Challenge-Response Key no interaction required</comment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YubiKeyInterfaceUSB</name>
<message>
<source>(USB) %1 [%2] Challenge-Response - Slot %3 - %4</source>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
Expand All @@ -9767,10 +9745,6 @@ Example: JBSWY3DPEHPK3PXP</source>
<source>The YubiKey USB interface has not been initialized.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware key is currently in use.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Could not find hardware key with serial number %1. Please plug it in to continue.</source>
<translation type="unfinished"></translation>
Expand All @@ -9787,5 +9761,15 @@ Example: JBSWY3DPEHPK3PXP</source>
<source>Failed to complete a challenge-response, the specific error was: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 [%2] - Slot %3</source>
<comment>YubiKey NEO display fields</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 [%2] - Slot %3, %4</source>
<comment>YubiKey display fields</comment>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
13 changes: 12 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,17 @@ if(WIN32)
endif()
endif()

if(WITH_XC_YUBIKEY)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/DeviceListener.cpp)
if(APPLE)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/macutils/DeviceListenerMac.cpp)
elseif(UNIX)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/nixutils/DeviceListenerLibUsb.cpp)
elseif(WIN32)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/winutils/DeviceListenerWin.cpp)
endif()
endif()

set(keepassx_SOURCES ${keepassx_SOURCES}
../share/icons/icons.qrc
../share/wizard/wizard.qrc)
Expand Down Expand Up @@ -401,7 +412,7 @@ if(HAIKU)
target_link_libraries(keepassx_core network)
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(keepassx_core Qt5::DBus)
target_link_libraries(keepassx_core Qt5::DBus ${LIBUSB_LIBRARIES})
if(WITH_XC_X11)
target_link_libraries(keepassx_core Qt5::X11Extras X11)
endif()
Expand Down
3 changes: 2 additions & 1 deletion src/cli/keepassxc-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "Utils.h"
#include "config-keepassx.h"
#include "core/Bootstrap.h"
#include "core/Config.h"
#include "core/Metadata.h"
#include "core/Tools.h"
#include "crypto/Crypto.h"
Expand Down Expand Up @@ -181,7 +182,7 @@ int main(int argc, char** argv)
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationVersion(KEEPASSXC_VERSION);

Bootstrap::bootstrap();
Bootstrap::bootstrap(config()->get(Config::GUI_Language).toString());
Utils::setDefaultTextStreams();
Commands::setupCommands(false);

Expand Down
4 changes: 2 additions & 2 deletions src/core/Bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace Bootstrap
* Perform early application bootstrapping that does not rely on a QApplication
* being present.
*/
void bootstrap()
void bootstrap(const QString& uiLanguage)
{
#ifdef QT_NO_DEBUG
disableCoreDumps();
Expand All @@ -72,7 +72,7 @@ namespace Bootstrap
setupSearchPaths();
applyEarlyQNetworkAccessManagerWorkaround();

Translator::installTranslators();
Translator::installTranslators(uiLanguage);
}

// LCOV_EXCL_START
Expand Down
4 changes: 3 additions & 1 deletion src/core/Bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
#ifndef KEEPASSXC_BOOTSTRAP_H
#define KEEPASSXC_BOOTSTRAP_H

#include <QString>

namespace Bootstrap
{
void bootstrap();
void bootstrap(const QString& uiLanguage = "system");
void disableCoreDumps();
bool createWindowsDACL();
void setupSearchPaths();
Expand Down
9 changes: 3 additions & 6 deletions src/core/Translator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,22 @@
#include <QRegularExpression>
#include <QTranslator>

#include "config-keepassx.h"
#include "core/Config.h"
#include "core/Resources.h"

/**
* Install all KeePassXC and Qt translators.
*/
void Translator::installTranslators()
void Translator::installTranslators(const QString& uiLanguage)
{
QStringList languages;
QString languageSetting = config()->get(Config::GUI_Language).toString();
if (languageSetting.isEmpty() || languageSetting == "system") {
if (uiLanguage.isEmpty() || uiLanguage == "system") {
// NOTE: this is a workaround for the terrible way Qt loads languages
// using the QLocale::uiLanguages() approach. Instead, we search each
// language and all country variants in order before moving to the next.
QLocale locale;
languages = locale.uiLanguages();
} else {
languages << languageSetting;
languages << uiLanguage;
}

// Always try to load english last
Expand Down
3 changes: 2 additions & 1 deletion src/core/Translator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
#define KEEPASSX_TRANSLATOR_H

#include <QMetaType>
#include <QString>

class Translator
{
public:
static void installTranslators();
static void installTranslators(const QString& uiLanguage = "system");
static QList<QPair<QString, QString>> availableLanguages();

private:
Expand Down
Loading
Loading