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

added autoopen functionality (#477) #1053

Merged
merged 5 commits into from
Nov 30, 2017

Conversation

alterratz
Copy link
Contributor

@alterratz alterratz commented Oct 9, 2017

implementation of #477 autoopen

If a folder (within the root folder) is named "AutoOpen", all entries within this folder are opened automatically

password: the password of the "slave" database
url: the file name of the database which can be:
file:///absolute/path.kdbx
/absolute/path.kdbx
path.kbdx (which is relative to the current db)

Did not test it on windows or osx but since Qt file
functions have been used I suppose it will work fine.

Description

iterated over all items in the AutoOpen folder in updateTabNameFromDbWidgetSender which is called after a db is opened

also had to change a few lines in DatabaseTabWidget::openDatabase to set passwords for already open databases or ignore databases which have their password set already.

Motivation and context

implements feature request #477
I use dependent DBs a lot and manually opening them sucks

How has this been tested?

created a few (8) databases linked them to the master (4) and other "slave" DBs (4) using different url styles and loaded the master db as well as slave DBs
tried it with some of them opened before loading the master as well.

built it with following settings:
cmake -DWITH_XC_AUTOTYPE=ON -DWITH_XC_HTTP=ON -DWITH_XC_YUBIKEY=ON -DWITH_TESTS=ON -DWITH_ASAN=ON -DCMAKE_BUILD_TYPE=Release ..

Screenshots (if appropriate):

Types of changes

  • ✅ New feature (non-breaking change which adds functionality)

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]
  • ✅ TBD (when this is the only remaining obstacle for merging) My change requires a change to the documentation and I have updated it accordingly.

@droidmonkey
Copy link
Member

Much better!

@droidmonkey droidmonkey requested a review from a team October 9, 2017 13:12
@droidmonkey droidmonkey added this to the v2.3.0 milestone Oct 9, 2017
@TheZ3ro
Copy link
Contributor

TheZ3ro commented Oct 9, 2017

I would like some check on the file format since openDatabase assume it's a kdbx file

Copy link
Member

@phoerious phoerious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I marked a bunch of minor things to fix.
Generally, this looks good otherwise, but I need to test it first and see if it works properly, also with auto-filled key file paths.

Database* db = dbWidget->database();
Group *autoload = db->rootGroup()->findChildByName("AutoOpen");
if (autoload)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding style: pointer operator belongs to type, opening brace on same line as if.

QDir dbFolder(dbpath.canonicalPath());

for (auto entry : autoload->entries()) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line here.

continue;

QFileInfo filepath;
if (entry->url().startsWith("file:/")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be file:// (with a double slash)?

@alterratz
Copy link
Contributor Author

@TheZ3ro :
I am not sure what I shouls check. For instance if i look at main.cc there is also no checking on the command line arguments as they are directly fed to openDatabase.

        QString filename = args[ii];
        if (!filename.isEmpty() && QFile::exists(filename)) {
            QString password;
            if (parser.isSet(pwstdinOption)) {
                static QTextStream in(stdin, QIODevice::ReadOnly);
                password = in.readLine();
            }
            mainWindow.openDatabase(filename, password, parser.value(keyfileOption));
        }
    

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Oct 13, 2017

@alterratz I mean a check on the file format, if I try to open a .txt file there is something wrong.
Anyway nevermind, the checks are already performed by

raiseError(tr("Not a KeePass database."));

😉

@phoerious
Copy link
Member

Please update your branch, so I can merge. Thanks!

@alterratz
Copy link
Contributor Author

Updated it to current develop

@XA21X
Copy link

XA21X commented Apr 23, 2018

Finally got it working after realising from the code that "AutoOpen" is the name it's searching for. I must've missed the info about it being the same as KeeAutoExec... Got confused by the "autoload" in the description lol.

@hrehfeld
Copy link

hrehfeld commented Jun 3, 2019

Is this feature documented somewhere? ( https://duckduckgo.com/?q=keepassxc+auto+open )

@Emily7777
Copy link

How do we add a key file reference to the auto open vaults entries?

@droidmonkey
Copy link
Member

Auto-open does not support key files

@hrehfeld
Copy link

Bug: auto open on a file that in turn auto-opens the first file gets into an endless loop. This will probably also work transitively.

@droidmonkey
Copy link
Member

Don't do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new feature Pull request that adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants