mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-18 10:47:22 -05:00
Moving keyFile after password. (#830)
* Moving keyFile after password. * Using tr() in unlockFromStdin.
This commit is contained in:
parent
fe877486ff
commit
839a61ef59
@ -403,20 +403,10 @@ Database* Database::openDatabaseFile(QString fileName, CompositeKey key)
|
|||||||
Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilename)
|
Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilename)
|
||||||
{
|
{
|
||||||
CompositeKey compositeKey;
|
CompositeKey compositeKey;
|
||||||
|
|
||||||
if (!keyFilename.isEmpty()) {
|
|
||||||
FileKey fileKey;
|
|
||||||
QString errorMessage;
|
|
||||||
if (!fileKey.load(keyFilename, &errorMessage)) {
|
|
||||||
qCritical("Failed to load key file %s : %s", qPrintable(keyFilename), qPrintable(errorMessage));
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
compositeKey.addKey(fileKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream outputTextStream(stdout);
|
QTextStream outputTextStream(stdout);
|
||||||
|
QTextStream errorTextStream(stderr);
|
||||||
|
|
||||||
outputTextStream << QString("Insert password to unlock " + databaseFilename + "\n> ");
|
outputTextStream << QObject::tr("Insert password to unlock %1: ").arg(databaseFilename);
|
||||||
outputTextStream.flush();
|
outputTextStream.flush();
|
||||||
|
|
||||||
QString line = Utils::getPassword();
|
QString line = Utils::getPassword();
|
||||||
@ -424,6 +414,17 @@ Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilenam
|
|||||||
passwordKey.setPassword(line);
|
passwordKey.setPassword(line);
|
||||||
compositeKey.addKey(passwordKey);
|
compositeKey.addKey(passwordKey);
|
||||||
|
|
||||||
|
if (!keyFilename.isEmpty()) {
|
||||||
|
FileKey fileKey;
|
||||||
|
QString errorMessage;
|
||||||
|
if (!fileKey.load(keyFilename, &errorMessage)) {
|
||||||
|
errorTextStream << QObject::tr("Failed to load key file %1 : %2").arg(keyFilename).arg(errorMessage);
|
||||||
|
errorTextStream << endl;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
compositeKey.addKey(fileKey);
|
||||||
|
}
|
||||||
|
|
||||||
return Database::openDatabaseFile(databaseFilename, compositeKey);
|
return Database::openDatabaseFile(databaseFilename, compositeKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user