mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 19:23:03 +01:00
added support to enter password from terminal
This commit is contained in:
parent
f2e2f17636
commit
000f7b3d3e
@ -667,7 +667,8 @@ int gbak(Firebird::UtilSvc* uSvc)
|
||||
BURP_error(307, true);
|
||||
// too many passwords provided
|
||||
}
|
||||
FILE *passfile = fopen(argv[itr], "rt");
|
||||
Firebird::PathName fName(argv[itr]);
|
||||
FILE *passfile = (fName == "stdin") ? stdin : fopen(argv[itr], "rt");
|
||||
if (!passfile)
|
||||
{
|
||||
BURP_error(308, true, MsgFormat::SafeArg() << argv[itr] << errno);
|
||||
@ -675,13 +676,21 @@ int gbak(Firebird::UtilSvc* uSvc)
|
||||
}
|
||||
try
|
||||
{
|
||||
if (isatty(fileno(passfile)))
|
||||
{
|
||||
fprintf(stderr, "Enter password: ");
|
||||
fflush(stderr);
|
||||
}
|
||||
Firebird::string pwd;
|
||||
pwd.LoadFromFile(passfile);
|
||||
tdgbl->gbl_sw_password = strdup(pwd.c_str());
|
||||
}
|
||||
catch (Firebird::Exception&)
|
||||
{
|
||||
fclose(passfile);
|
||||
if (passfile != stdin)
|
||||
{
|
||||
fclose(passfile);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
fclose(passfile);
|
||||
|
Loading…
Reference in New Issue
Block a user