8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 16:03:02 +01:00

added support to enter password from terminal

This commit is contained in:
alexpeshkoff 2008-11-25 14:27:12 +00:00
parent f2e2f17636
commit 000f7b3d3e

View File

@ -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);