Skip to content
Merged
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
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