-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add DBus support #283
Add DBus support #283
Conversation
Thanks for your pull request. I think this is mostly implemented by #135, though, which also adds automatic lock support on Windows and OS X, not only Linux. |
Any further comments on this? |
After a lot of check , #135 seems to subscribe and react to a d-bus event (passive mode). My PR provide another dbus interface (active mode). Both are not mutually exclusive and can be merged together. So I can modify my PR to use #135 lock feature, but it's very hard to do it until #135 is merged or not. |
Postponing to 2.3 |
I recommend closing this PR and performing a smart cherry pick of the differing capability than what was introduced with #545 |
@droidmonkey note that #545 is a dbus client (that listens for |
I don't think these will be a problem, but if others are added (eg. for reasing an entry), there should be a preferences option to not allow it. |
Hmmmm. Could this pose a security risk? |
Clearly yes, but outside the scope of keepassxc because you must provide a password on cli to open a database. The risk is that the password of the database can be found on bash_history. This problem is the same than all other cli tools and can be secured by using an askpass program like ksshaskpass or just not using this feature. |
This can serve as base for another projects. Like PR #608 which has potential to replace KeePassHTTP with 'Native Messaging'. In second variant it's using proxy that sits between browser and KeePassXC. Communication is done via UDP packets, but I can imagine to replace UDP for DBUS (on Linux), which would be awesome. |
Looks like this PR is getting lost with time, so I just want to pile on and say I would LOVE to have integration with |
Is this PR getting some love any time soon? If not, I'll close it. |
I will look into it ;) |
I've rebased this, added a method for locking all DBs (fix #687) and wrote the documentation on the wiki: Using-DBus-with-KeePassXC Ready for review and merge |
src/gui/MainWindow.cpp
Outdated
@@ -168,6 +175,17 @@ MainWindow::MainWindow() | |||
, m_appExiting(false) | |||
{ | |||
m_ui->setupUi(this); | |||
|
|||
#ifdef WITH_XC_DBUS | |||
#if defined(Q_OS_UNIX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably will trigger some problem on Q_OS_MACOS.
@weslly can you test this PR on a mac? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weslly Ok thanks, I will fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheZ3ro Appending && !defined(Q_OS_MAC)
on this line seems to solve the compilation issue, but that would mean the #undef
macro you used earlier had no effect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheZ3ro maybe adding this on src/CMakeLists.txt
would be better:
if(APPLE OR MINGW)
set(WITH_XC_DBUS OFF)
endif()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weslly pushed a different fix. Now should always work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheZ3ro works fine now :)
@weslly when you are free can you test this again? Thanks :) |
@TheZ3ro got this now: |
fe66a11
to
1af06af
Compare
This is now ready for review @keepassxreboot/core-developers |
CMakeLists.txt
Outdated
|
||
if(WITH_XC_HTTP) | ||
message(WARNING "KeePassHTTP support has been deprecated and will be removed in a future version. Please use WITH_XC_BROWSER instead!\n" | ||
"For enabling / disabling network access code, WITH_XC_HTTP has been replaced by WITH_XC_NETWORKING.") | ||
set(WITH_XC_NETWORKING ON CACHE BOOL "Include networking code (e.g. for downlading website icons)." FORCE) | ||
endif() | ||
|
||
if((NOT UNIX) OR APPLE AND WITH_XC_DBUS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant parentheses, use them around the whole OR expression instead.
src/CMakeLists.txt
Outdated
@@ -193,7 +193,7 @@ add_feature_info(KeePassXC-Browser WITH_XC_BROWSER "Browser integration with Kee | |||
add_feature_info(KeePassHTTP WITH_XC_HTTP "Browser integration compatible with ChromeIPass and PassIFox (deprecated, implies Networking)") | |||
add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent") | |||
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response") | |||
|
|||
add_feature_info(DBus WITH_XC_DBUS "Take keepassxc control by DBus") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Control KeePassXC via DBus"
But TBH, I don't think we need this flag. No matter what's selected here, DBus will always be compiled in on Linux, because we need it for detecting screen locking and for the stupid Unity menu bug workaround.
src/CMakeLists.txt
Outdated
if(WITH_XC_DBUS) | ||
set(keepassx_SOURCES | ||
${keepassx_SOURCES} | ||
gui/MainWindowAdaptor.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be written on a single line.
src/gui/MainWindow.cpp
Outdated
new MainWindowAdaptor(this); | ||
QDBusConnection dbus = QDBusConnection::sessionBus(); | ||
dbus.registerObject("/keepassxc", this); | ||
dbus.registerService("org.keepassxc.MainWindow"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be org.keepassxc.KeePassXC.MainWindow
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems redundant to me using the name 2 times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how the standard works.
src/gui/MainWindow.h
Outdated
@@ -37,6 +37,10 @@ class InactivityTimer; | |||
class MainWindow : public QMainWindow | |||
{ | |||
Q_OBJECT | |||
|
|||
#if defined(WITH_XC_DBUS) && !defined(QT_NO_DBUS) | |||
Q_CLASSINFO("D-Bus Interface", "org.keepassxc.MainWindow") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
src/gui/MainWindowAdaptor.cpp
Outdated
MainWindowAdaptor::MainWindowAdaptor(QObject *parent) | ||
: QDBusAbstractAdaptor(parent) | ||
{ | ||
// constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment.
src/gui/MainWindowAdaptor.cpp
Outdated
|
||
MainWindowAdaptor::~MainWindowAdaptor() | ||
{ | ||
// destructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
src/gui/MainWindowAdaptor.cpp
Outdated
|
||
void MainWindowAdaptor::appExit() | ||
{ | ||
// handle method call org.keepassxc.MainWindow.appExit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these comments should be doc comments above the method signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is auto-generated, the next time it will be generated it will have same comment as now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but it's so short, I don't even know if it's worth maintaining an XML file for it.
src/gui/MainWindowAdaptor.h
Outdated
void openDatabase(const QString &fileName); | ||
void openDatabase(const QString &fileName, const QString &pw); | ||
void openDatabase(const QString &fileName, const QString &pw, const QString &keyFile); | ||
Q_SIGNALS: // SIGNALS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace Q_SLOTS and Q_SIGNALS with keywords.
@@ -0,0 +1,67 @@ | |||
/* | |||
* This file was generated by qdbusxml2cpp version 0.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File should have the usual header, maybe with additional notices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sincerely, I would feel silly for adding a copyright notice to an autogenerated file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this file be generated by the build system then (add_custom_target or some shit)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can execute external programs in cmake I would say yes.
qdbusxml2cpp
comes in qtbase5-dev-tools
package on debian, so it's another dependency to add on linux.
Probably this file won't be edited for a long time, we should leave this here and don't bother too much, we just need to remember that's autogenerated and the header will come in handy
7c0673d
to
0edd9aa
Compare
@@ -0,0 +1,23 @@ | |||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> | |||
<node> | |||
<interface name="org.keepassxc.MainWindow"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs to be changed to org.keepassxc.KeePassXC.MainWindow.
src/config-keepassx.h.cmake
Outdated
@@ -18,6 +18,7 @@ | |||
#cmakedefine WITH_XC_HTTP | |||
#cmakedefine WITH_XC_YUBIKEY | |||
#cmakedefine WITH_XC_SSHAGENT | |||
#cmakedefine WITH_XC_DBUS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option does not exist anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed and rebased
…when log in, close all databases when log out)
- Add support for KDBX 4.0, Argon2 and ChaCha20 [#148, #1179, #1230, #1494] - Add SSH Agent feature [#1098, #1450, #1463] - Add preview panel with details of the selected entry [#879, #1338] - Add more and configurable columns to entry table and allow copying of values by double click [#1305] - Add KeePassXC-Browser API as a replacement for KeePassHTTP [#608] - Deprecate KeePassHTTP [#1392] - Add support for Steam one-time passwords [#1206] - Add support for multiple Auto-Type sequences for a single entry [#1390] - Adjust YubiKey HMAC-SHA1 challenge-response key generation for KDBX 4.0 [#1060] - Replace qHttp with cURL for website icon downloads [#1460] - Remove lock file [#1231] - Add option to create backup file before saving [#1385] - Ask to save a generated password before closing the entry password generator [#1499] - Resolve placeholders recursively [#1078] - Add Auto-Type button to the toolbar [#1056] - Improve window focus handling for Auto-Type dialogs [#1204, #1490] - Auto-Type dialog and password generator can now be exited with ESC [#1252, #1412] - Add optional dark tray icon [#1154] - Add new "Unsafe saving" option to work around saving problems with file sync services [#1385] - Add IBus support to AppImage and additional image formats to Windows builds [#1534, #1537] - Add diceware password generator to CLI [#1406] - Add --key-file option to CLI [#816, #824] - Add DBus interface for opening and closing KeePassXC databases [#283] - Add KDBX compression options to database settings [#1419] - Discourage use of old fixed-length key files in favor of arbitrary files [#1326, #1327] - Correct reference resolution in entry fields [#1486] - Fix window state and recent databases not being remembered on exit [#1453] - Correct history item generation when configuring TOTP for an entry [#1446] - Correct multiple TOTP bugs [#1414] - Automatic saving after every change is now a default [#279] - Allow creation of new entries during search [#1398] - Correct menu issues on macOS [#1335] - Allow compilation on OpenBSD [#1328] - Improve entry attachments view [#1139, #1298] - Fix auto lock for Gnome and Xfce [#910, #1249] - Don't remember key files in file dialogs when the setting is disabled [#1188] - Improve database merging and conflict resolution [#807, #1165] - Fix macOS pasteboard issues [#1202] - Improve startup times on some platforms [#1205] - Hide the notes field by default [#1124] - Toggle main window by clicking tray icon with the middle mouse button [#992] - Fix custom icons not copied over when databases are merged [#1008] - Allow use of DEL key to delete entries [#914] - Correct intermittent crash due to stale history items [#1527] - Sanitize newline characters in title, username and URL fields [#1502] - Reopen previously opened databases in correct order [#774] - Use system's zxcvbn library if available [#701] - Implement various i18n improvements [#690, #875, #1436]
Description
keepassxc can be basically controlled with others applications: open/close databases or exit.
Motivation and Context
React to desktop event automatically:
How Has This Been Tested?
Tested on Debug and RelWithDebInfo build type
qdbus org.keepassxc.MainWindow /keepassxc org.keepassxc.MainWindow.openDatabase mydb mypasswd mykeyfile
qdbus org.keepassxc.MainWindow /keepassxc org.keepassxc.MainWindow.closeAllDatabases
qdbus org.keepassxc.MainWindow /keepassxc org.keepassxc.MainWindow.appExit
Types of changes
Checklist: