mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 06:03:02 +01:00
This is the first attempt to fix CORE-1667 (Reading password from file/stdin).
Please take a look at it and comment, before adding support to other utilities. Main problems seen: - Name of a switch (now -@PASSWORD, may be -PASSFILE is better?) - How to provide support for stdin?
This commit is contained in:
parent
61cc103fda
commit
17ae73b5d7
@ -648,8 +648,44 @@ int gbak(Firebird::UtilSvc* uSvc)
|
||||
// password parameter missing
|
||||
}
|
||||
uSvc->hidePasswd(argv, itr);
|
||||
if (tdgbl->gbl_sw_password)
|
||||
{
|
||||
BURP_error(307, true);
|
||||
// too many passwords provided
|
||||
}
|
||||
tdgbl->gbl_sw_password = argv[itr];
|
||||
}
|
||||
else if (in_sw_tab->in_sw == IN_SW_BURP_PASSFILE)
|
||||
{
|
||||
if (++itr >= argc)
|
||||
{
|
||||
BURP_error(189, true);
|
||||
// password parameter missing
|
||||
}
|
||||
if (tdgbl->gbl_sw_password)
|
||||
{
|
||||
BURP_error(307, true);
|
||||
// too many passwords provided
|
||||
}
|
||||
FILE *passfile = fopen(argv[itr], "rt");
|
||||
if (!passfile)
|
||||
{
|
||||
BURP_error(308, true, MsgFormat::SafeArg() << argv[itr] << errno);
|
||||
// error @2 opening password file @1
|
||||
}
|
||||
try
|
||||
{
|
||||
Firebird::string pwd;
|
||||
pwd.LoadFromFile(passfile);
|
||||
tdgbl->gbl_sw_password = strdup(pwd.c_str());
|
||||
}
|
||||
catch (Firebird::Exception&)
|
||||
{
|
||||
fclose(passfile);
|
||||
throw;
|
||||
}
|
||||
fclose(passfile);
|
||||
}
|
||||
else if (in_sw_tab->in_sw == IN_SW_BURP_USER)
|
||||
{
|
||||
if (++itr >= argc)
|
||||
@ -885,6 +921,7 @@ int gbak(Firebird::UtilSvc* uSvc)
|
||||
break;
|
||||
|
||||
case (IN_SW_BURP_PASS):
|
||||
case (IN_SW_BURP_PASSFILE):
|
||||
dpb.insertString(tdgbl->uSvc->isService() ?
|
||||
isc_dpb_password_enc : isc_dpb_password,
|
||||
tdgbl->gbl_sw_password, strlen(tdgbl->gbl_sw_password));
|
||||
|
@ -91,6 +91,8 @@ const int IN_SW_BURP_TRUSTED_ROLE = 42; // use trusted role on attach
|
||||
const int IN_SW_BURP_FIX_FSS_DATA = 43; // fix unicode_fss data
|
||||
const int IN_SW_BURP_FIX_FSS_METADATA = 44; // fix unicode_fss metadata
|
||||
|
||||
const int IN_SW_BURP_PASSFILE = 45; // read default password to use on attach from file
|
||||
|
||||
/**************************************************************************/
|
||||
// used 0BCDEFGILMNOPRSTUVYZ available AHJQWX
|
||||
|
||||
@ -147,6 +149,8 @@ static const in_sw_tab_t reference_burp_in_sw_table [] =
|
||||
// msg 101: %sPAGE_SIZE override default page size
|
||||
{IN_SW_BURP_PASS, 0, "PASSWORD", 0, 0, 0, FALSE, 190, 0, NULL},
|
||||
// msg 190: %sPA(SSWORD) Firebird password
|
||||
{IN_SW_BURP_PASSFILE, 0, "@PASSWORD", 0, 0, 0, FALSE, 306, 0, NULL},
|
||||
// msg 306: %s@(PASSWORD) Read firebird password from file
|
||||
{IN_SW_BURP_RECREATE, 0, "RECREATE_DATABASE", 0, 0, 0, FALSE, 284, 0, NULL},
|
||||
// msg 284: %sR(ECREATE_DATABASE) [O(VERWRITE)] create (or replace if OVERWRITE used) database from backup file
|
||||
{IN_SW_BURP_R, isc_spb_res_replace, "REPLACE_DATABASE", 0, 0, 0, FALSE, 112, 0, NULL},
|
||||
|
@ -17,7 +17,7 @@ set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUM
|
||||
--
|
||||
('1996-11-07 13:39:40', 'INSTALL', 10, 1)
|
||||
('1996-11-07 13:38:41', 'TEST', 11, 4)
|
||||
('2008-04-10 23:40:00', 'GBAK', 12, 306)
|
||||
('2008-11-24 18:20:48', 'GBAK', 12, 309)
|
||||
('2008-09-26 07:37:16', 'SQLERR', 13, 969)
|
||||
('1996-11-07 13:38:42', 'SQLWARN', 14, 613)
|
||||
('2006-09-10 03:04:31', 'JRD_BUGCHK', 15, 307)
|
||||
|
@ -2449,6 +2449,9 @@ ERROR: Backup incomplete', NULL, NULL);
|
||||
(NULL, NULL, 'burp.cpp', NULL, 12, 303, NULL, ' @1FIX_FSS_M(ETADATA) fix malformed UNICODE_FSS metadata', NULL, NULL);
|
||||
(NULL, 'BURP_gbak', 'burp.cpp', NULL, 12, 304, NULL, 'Character set parameter missing', NULL, NULL);
|
||||
(NULL, 'restore', 'restore.epp', NULL, 12, 305, NULL, 'Character set @1 not found', NULL, NULL);
|
||||
(NULL, 'BURP_gbak', 'burp.cpp', NULL, 12, 306, NULL, ' @1@@(PASSWORD) read password from file', NULL, NULL);
|
||||
(NULL, 'BURP_gbak', 'burp.cpp', NULL, 12, 307, NULL, 'too many passwords provided', NULL, NULL);
|
||||
(NULL, 'BURP_gbak', 'burp.cpp', NULL, 12, 308, NULL, 'could not open password file @1, errno @2', NULL, NULL);
|
||||
-- SQLERR
|
||||
(NULL, NULL, NULL, NULL, 13, 1, NULL, 'Firebird error', NULL, NULL);
|
||||
(NULL, NULL, NULL, NULL, 13, 74, NULL, 'Rollback not performed', NULL, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user