mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-26 07:49:50 -05:00
Fix unlocking multiple databases with pw-stdin when input is a pipe
This works: ``` $ keepassxc test1.kdbx test2.kdbx --pw-stdin Database password: <manual input 1234> Database password: <manual input 4321> ``` But this doesn't (only `test1.kdbx` is unlocked): ``` $ printf '%s\n' 1234 4321 | keepassxc test1.kdbx test2.kdbx --pw-stdin Database password: Database password: ``` The problem is that `Utils::setDefaultTextStreams()` is called multiple times when unlocking multiple databases with `--pw-stdin`, which appears to break the pipe. Simply call it once to avoid the problem. Fixes: #5012 (as far as I can tell by simulating the script in Linux) Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
This commit is contained in:
parent
486779cce7
commit
e6bf8463d9
@ -166,6 +166,9 @@ int main(int argc, char** argv)
|
||||
#endif
|
||||
|
||||
const bool pwstdin = parser.isSet(pwstdinOption);
|
||||
if (!fileNames.isEmpty() && pwstdin) {
|
||||
Utils::setDefaultTextStreams();
|
||||
}
|
||||
for (const QString& filename : fileNames) {
|
||||
QString password;
|
||||
if (pwstdin) {
|
||||
@ -173,7 +176,6 @@ int main(int argc, char** argv)
|
||||
// buffer for native messaging, even if the specified file does not exist
|
||||
QTextStream out(stdout, QIODevice::WriteOnly);
|
||||
out << QObject::tr("Database password: ") << flush;
|
||||
Utils::setDefaultTextStreams();
|
||||
password = Utils::getPassword();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user