Skip to content

Commit

Permalink
Moving keyFile after password. (keepassxreboot#830)
Browse files Browse the repository at this point in the history
* Moving keyFile after password.

* Using tr() in unlockFromStdin.
  • Loading branch information
louib authored Jul 31, 2017
1 parent fe87748 commit 839a61e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/core/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,27 +403,28 @@ Database* Database::openDatabaseFile(QString fileName, CompositeKey key)
Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilename)
{
CompositeKey compositeKey;
QTextStream outputTextStream(stdout);
QTextStream errorTextStream(stderr);

outputTextStream << QObject::tr("Insert password to unlock %1: ").arg(databaseFilename);
outputTextStream.flush();

QString line = Utils::getPassword();
PasswordKey passwordKey;
passwordKey.setPassword(line);
compositeKey.addKey(passwordKey);

if (!keyFilename.isEmpty()) {
FileKey fileKey;
QString errorMessage;
if (!fileKey.load(keyFilename, &errorMessage)) {
qCritical("Failed to load key file %s : %s", qPrintable(keyFilename), qPrintable(errorMessage));
errorTextStream << QObject::tr("Failed to load key file %1 : %2").arg(keyFilename).arg(errorMessage);
errorTextStream << endl;
return nullptr;
}
compositeKey.addKey(fileKey);
}

QTextStream outputTextStream(stdout);

outputTextStream << QString("Insert password to unlock " + databaseFilename + "\n> ");
outputTextStream.flush();

QString line = Utils::getPassword();
PasswordKey passwordKey;
passwordKey.setPassword(line);
compositeKey.addKey(passwordKey);

return Database::openDatabaseFile(databaseFilename, compositeKey);
}

Expand Down

0 comments on commit 839a61e

Please sign in to comment.