mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-14 00:39:53 -05:00
Hide UI elements when KeePassXC was compiled without -DWITH_XC_YUBIKEY
This commit is contained in:
parent
8d3e0687a0
commit
b2650c5a96
@ -195,13 +195,12 @@ if(NOT ZLIB_SUPPORTS_GZIP)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Optional
|
# Optional
|
||||||
find_package(YubiKey)
|
if(WITH_XC_YUBIKEY)
|
||||||
|
find_package(YubiKey REQUIRED)
|
||||||
|
|
||||||
if(YUBIKEY_FOUND)
|
|
||||||
include_directories(SYSTEM ${YUBIKEY_INCLUDE_DIRS})
|
include_directories(SYSTEM ${YUBIKEY_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
check_cxx_source_compiles("#include <sys/prctl.h>
|
check_cxx_source_compiles("#include <sys/prctl.h>
|
||||||
int main() { prctl(PR_SET_DUMPABLE, 0); return 0; }"
|
int main() { prctl(PR_SET_DUMPABLE, 0); return 0; }"
|
||||||
|
@ -179,7 +179,7 @@ if(MINGW)
|
|||||||
${CMAKE_SOURCE_DIR}/share/windows/icon.rc)
|
${CMAKE_SOURCE_DIR}/share/windows/icon.rc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(YUBIKEY_FOUND)
|
if(WITH_XC_YUBIKEY)
|
||||||
set(keepassx_SOURCES ${keepassx_SOURCES} keys/drivers/YubiKey.cpp)
|
set(keepassx_SOURCES ${keepassx_SOURCES} keys/drivers/YubiKey.cpp)
|
||||||
else()
|
else()
|
||||||
set(keepassx_SOURCES ${keepassx_SOURCES} keys/drivers/YubiKeyStub.cpp)
|
set(keepassx_SOURCES ${keepassx_SOURCES} keys/drivers/YubiKeyStub.cpp)
|
||||||
@ -209,7 +209,8 @@ target_link_libraries(keepassx_core
|
|||||||
Qt5::Network
|
Qt5::Network
|
||||||
${GCRYPT_LIBRARIES}
|
${GCRYPT_LIBRARIES}
|
||||||
${GPGERROR_LIBRARIES}
|
${GPGERROR_LIBRARIES}
|
||||||
${ZLIB_LIBRARIES})
|
${ZLIB_LIBRARIES}
|
||||||
|
${YUBIKEY_LIBRARIES})
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
target_link_libraries(keepassx_core Qt5::DBus)
|
target_link_libraries(keepassx_core Qt5::DBus)
|
||||||
endif()
|
endif()
|
||||||
@ -234,10 +235,6 @@ endif()
|
|||||||
add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE} ${WIN32_ProductVersionFiles})
|
add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE} ${WIN32_ProductVersionFiles})
|
||||||
target_link_libraries(${PROGNAME} keepassx_core)
|
target_link_libraries(${PROGNAME} keepassx_core)
|
||||||
|
|
||||||
if(YUBIKEY_FOUND)
|
|
||||||
target_link_libraries(keepassx_core ${YUBIKEY_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON)
|
set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include "gui/MessageBox.h"
|
#include "gui/MessageBox.h"
|
||||||
#include "crypto/Random.h"
|
#include "crypto/Random.h"
|
||||||
|
|
||||||
|
#include "config-keepassx.h"
|
||||||
|
|
||||||
ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
|
ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
|
||||||
: DialogyWidget(parent)
|
: DialogyWidget(parent)
|
||||||
, m_ui(new Ui::ChangeMasterKeyWidget())
|
, m_ui(new Ui::ChangeMasterKeyWidget())
|
||||||
@ -50,11 +52,15 @@ ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
|
|||||||
connect(m_ui->createKeyFileButton, SIGNAL(clicked()), SLOT(createKeyFile()));
|
connect(m_ui->createKeyFileButton, SIGNAL(clicked()), SLOT(createKeyFile()));
|
||||||
connect(m_ui->browseKeyFileButton, SIGNAL(clicked()), SLOT(browseKeyFile()));
|
connect(m_ui->browseKeyFileButton, SIGNAL(clicked()), SLOT(browseKeyFile()));
|
||||||
|
|
||||||
|
#ifdef WITH_XC_YUBIKEY
|
||||||
connect(m_ui->challengeResponseGroup, SIGNAL(clicked(bool)), SLOT(challengeResponseGroupToggled(bool)));
|
connect(m_ui->challengeResponseGroup, SIGNAL(clicked(bool)), SLOT(challengeResponseGroupToggled(bool)));
|
||||||
connect(m_ui->buttonRedetectYubikey, SIGNAL(clicked()), SLOT(pollYubikey()));
|
connect(m_ui->buttonRedetectYubikey, SIGNAL(clicked()), SLOT(pollYubikey()));
|
||||||
|
|
||||||
connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection);
|
connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection);
|
||||||
connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
|
connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
|
||||||
|
#else
|
||||||
|
m_ui->challengeResponseGroup->setVisible(false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeMasterKeyWidget::~ChangeMasterKeyWidget()
|
ChangeMasterKeyWidget::~ChangeMasterKeyWidget()
|
||||||
@ -98,8 +104,10 @@ void ChangeMasterKeyWidget::clearForms()
|
|||||||
m_ui->keyFileGroup->setChecked(false);
|
m_ui->keyFileGroup->setChecked(false);
|
||||||
m_ui->togglePasswordButton->setChecked(false);
|
m_ui->togglePasswordButton->setChecked(false);
|
||||||
|
|
||||||
|
#ifdef WITH_XC_YUBIKEY
|
||||||
m_ui->challengeResponseGroup->setChecked(false);
|
m_ui->challengeResponseGroup->setChecked(false);
|
||||||
m_ui->comboChallengeResponse->clear();
|
m_ui->comboChallengeResponse->clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
m_ui->enterPasswordEdit->setFocus();
|
m_ui->enterPasswordEdit->setFocus();
|
||||||
}
|
}
|
||||||
@ -118,9 +126,10 @@ void ChangeMasterKeyWidget::generateKey()
|
|||||||
{
|
{
|
||||||
m_key.clear();
|
m_key.clear();
|
||||||
|
|
||||||
bool anyChecked = m_ui->passwordGroup->isChecked();
|
bool anyChecked = m_ui->passwordGroup->isChecked() | m_ui->keyFileGroup->isChecked();
|
||||||
anyChecked |= m_ui->keyFileGroup->isChecked();
|
#ifdef WITH_XC_YUBIKEY
|
||||||
anyChecked |= m_ui->challengeResponseGroup->isChecked();
|
anyChecked |= m_ui->challengeResponseGroup->isChecked();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!anyChecked) {
|
if (!anyChecked) {
|
||||||
if (MessageBox::warning(this, tr("No authentication factor chosen"),
|
if (MessageBox::warning(this, tr("No authentication factor chosen"),
|
||||||
@ -160,6 +169,7 @@ void ChangeMasterKeyWidget::generateKey()
|
|||||||
m_key.addKey(fileKey);
|
m_key.addKey(fileKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WITH_XC_YUBIKEY
|
||||||
if (m_ui->challengeResponseGroup->isChecked()) {
|
if (m_ui->challengeResponseGroup->isChecked()) {
|
||||||
int i = m_ui->comboChallengeResponse->currentIndex();
|
int i = m_ui->comboChallengeResponse->currentIndex();
|
||||||
i = m_ui->comboChallengeResponse->itemData(i).toInt();
|
i = m_ui->comboChallengeResponse->itemData(i).toInt();
|
||||||
@ -174,6 +184,7 @@ void ChangeMasterKeyWidget::generateKey()
|
|||||||
|
|
||||||
m_key.addChallengeResponseKey(key);
|
m_key.addChallengeResponseKey(key);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
m_ui->messageWidget->hideMessage();
|
m_ui->messageWidget->hideMessage();
|
||||||
emit editFinished(true);
|
emit editFinished(true);
|
||||||
|
@ -29,14 +29,16 @@
|
|||||||
#include "format/KeePass2Reader.h"
|
#include "format/KeePass2Reader.h"
|
||||||
#include "keys/FileKey.h"
|
#include "keys/FileKey.h"
|
||||||
#include "keys/PasswordKey.h"
|
#include "keys/PasswordKey.h"
|
||||||
#include "keys/YkChallengeResponseKey.h"
|
|
||||||
#include "crypto/Random.h"
|
#include "crypto/Random.h"
|
||||||
|
#include "keys/YkChallengeResponseKey.h"
|
||||||
|
|
||||||
|
#include "config-keepassx.h"
|
||||||
|
|
||||||
|
|
||||||
DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
|
DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
|
||||||
: DialogyWidget(parent)
|
: DialogyWidget(parent),
|
||||||
, m_ui(new Ui::DatabaseOpenWidget())
|
m_ui(new Ui::DatabaseOpenWidget()),
|
||||||
, m_db(nullptr)
|
m_db(nullptr)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
@ -49,11 +51,6 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
|
|||||||
|
|
||||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
|
|
||||||
m_ui->yubikeyProgress->setVisible(false);
|
|
||||||
QSizePolicy sp = m_ui->yubikeyProgress->sizePolicy();
|
|
||||||
sp.setRetainSizeWhenHidden(true);
|
|
||||||
m_ui->yubikeyProgress->setSizePolicy(sp);
|
|
||||||
|
|
||||||
m_ui->buttonTogglePassword->setIcon(filePath()->onOffIcon("actions", "password-show"));
|
m_ui->buttonTogglePassword->setIcon(filePath()->onOffIcon("actions", "password-show"));
|
||||||
connect(m_ui->buttonTogglePassword, SIGNAL(toggled(bool)),
|
connect(m_ui->buttonTogglePassword, SIGNAL(toggled(bool)),
|
||||||
m_ui->editPassword, SLOT(setShowPassword(bool)));
|
m_ui->editPassword, SLOT(setShowPassword(bool)));
|
||||||
@ -61,21 +58,33 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
|
|||||||
|
|
||||||
connect(m_ui->editPassword, SIGNAL(textChanged(QString)), SLOT(activatePassword()));
|
connect(m_ui->editPassword, SIGNAL(textChanged(QString)), SLOT(activatePassword()));
|
||||||
connect(m_ui->comboKeyFile, SIGNAL(editTextChanged(QString)), SLOT(activateKeyFile()));
|
connect(m_ui->comboKeyFile, SIGNAL(editTextChanged(QString)), SLOT(activateKeyFile()));
|
||||||
connect(m_ui->comboChallengeResponse, SIGNAL(activated(int)), SLOT(activateChallengeResponse()));
|
|
||||||
|
|
||||||
connect(m_ui->checkPassword, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
|
connect(m_ui->checkPassword, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
|
||||||
connect(m_ui->checkKeyFile, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
|
connect(m_ui->checkKeyFile, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
|
||||||
connect(m_ui->comboKeyFile, SIGNAL(editTextChanged(QString)), SLOT(setOkButtonEnabled()));
|
connect(m_ui->comboKeyFile, SIGNAL(editTextChanged(QString)), SLOT(setOkButtonEnabled()));
|
||||||
connect(m_ui->checkChallengeResponse, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
|
|
||||||
connect(m_ui->comboChallengeResponse, SIGNAL(activated(int)), SLOT(setOkButtonEnabled()));
|
|
||||||
|
|
||||||
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase()));
|
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase()));
|
||||||
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
|
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
|
||||||
|
|
||||||
|
#ifdef WITH_XC_YUBIKEY
|
||||||
|
m_ui->yubikeyProgress->setVisible(false);
|
||||||
|
QSizePolicy sp = m_ui->yubikeyProgress->sizePolicy();
|
||||||
|
sp.setRetainSizeWhenHidden(true);
|
||||||
|
m_ui->yubikeyProgress->setSizePolicy(sp);
|
||||||
|
|
||||||
connect(m_ui->buttonRedetectYubikey, SIGNAL(clicked()), SLOT(pollYubikey()));
|
connect(m_ui->buttonRedetectYubikey, SIGNAL(clicked()), SLOT(pollYubikey()));
|
||||||
|
connect(m_ui->comboChallengeResponse, SIGNAL(activated(int)), SLOT(activateChallengeResponse()));
|
||||||
|
connect(m_ui->checkChallengeResponse, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
|
||||||
|
connect(m_ui->comboChallengeResponse, SIGNAL(activated(int)), SLOT(setOkButtonEnabled()));
|
||||||
|
|
||||||
connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection);
|
connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection);
|
||||||
connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
|
connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
|
||||||
|
#else
|
||||||
|
m_ui->checkChallengeResponse->setVisible(false);
|
||||||
|
m_ui->buttonRedetectYubikey->setVisible(false);
|
||||||
|
m_ui->comboChallengeResponse->setVisible(false);
|
||||||
|
m_ui->yubikeyProgress->setVisible(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
// add random padding to layouts to align widgets properly
|
// add random padding to layouts to align widgets properly
|
||||||
@ -109,10 +118,12 @@ void DatabaseOpenWidget::load(const QString& filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
#ifdef WITH_XC_YUBIKEY
|
||||||
|
|
||||||
m_ui->comboChallengeResponse->clear();
|
m_ui->comboChallengeResponse->clear();
|
||||||
pollYubikey();
|
pollYubikey();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||||
|
|
||||||
m_ui->editPassword->setFocus();
|
m_ui->editPassword->setFocus();
|
||||||
}
|
}
|
||||||
@ -199,9 +210,12 @@ CompositeKey DatabaseOpenWidget::databaseKey()
|
|||||||
|
|
||||||
if (config()->get("RememberLastKeyFiles").toBool()) {
|
if (config()->get("RememberLastKeyFiles").toBool()) {
|
||||||
config()->set("LastKeyFiles", lastKeyFiles);
|
config()->set("LastKeyFiles", lastKeyFiles);
|
||||||
config()->set("LastChallengeResponse", lastChallengeResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WITH_XC_YUBIKEY
|
||||||
|
if (config()->get("RememberLastKeyFiles").toBool()) {
|
||||||
|
config()->set("LastChallengeResponse", lastChallengeResponse);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_ui->checkChallengeResponse->isChecked()) {
|
if (m_ui->checkChallengeResponse->isChecked()) {
|
||||||
int i = m_ui->comboChallengeResponse->currentIndex();
|
int i = m_ui->comboChallengeResponse->currentIndex();
|
||||||
@ -210,6 +224,7 @@ CompositeKey DatabaseOpenWidget::databaseKey()
|
|||||||
|
|
||||||
masterKey.addChallengeResponseKey(key);
|
masterKey.addChallengeResponseKey(key);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return masterKey;
|
return masterKey;
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,7 @@ bool YubiKey::getSerial(unsigned int& serial) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
YubiKey::ChallengeResult YubiKey::challenge(int slot, bool mayBlock,
|
YubiKey::ChallengeResult YubiKey::challenge(int slot, bool mayBlock, const QByteArray& chal, QByteArray& resp) const
|
||||||
const QByteArray& chal,
|
|
||||||
QByteArray& resp) const
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(slot);
|
Q_UNUSED(slot);
|
||||||
Q_UNUSED(mayBlock);
|
Q_UNUSED(mayBlock);
|
||||||
|
Loading…
Reference in New Issue
Block a user