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

Fixed CORE-4879: Minor inconvenience in user management via services API - fixed order of parameters in SPB required

This commit is contained in:
alexpeshkoff 2015-07-26 18:13:04 +00:00
parent 8400f91796
commit 9816b9257a
2 changed files with 40 additions and 16 deletions

View File

@ -2499,8 +2499,8 @@ bool Service::process_switches(ClumpletReader& spb, string& switches)
int nbk_level = -1;
bool val_database = false;
bool found = false;
string::size_type userPos = string::npos;
do
{
@ -2593,6 +2593,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches)
{
return false;
}
found = true;
if (spb.isEof() && (svc_action == isc_action_svc_display_user ||
svc_action == isc_action_svc_display_user_adm))
@ -2602,15 +2603,10 @@ bool Service::process_switches(ClumpletReader& spb, string& switches)
break;
}
if (spb.getClumpTag() != isc_spb_sec_username &&
spb.getClumpTag() != isc_spb_dbname &&
spb.getClumpTag() != isc_spb_sql_role_name)
if (spb.getClumpTag() != isc_spb_sec_username)
{
// unexpected item in service parameter block, expected @1
status_exception::raise(Arg::Gds(isc_unexp_spb_form) << Arg::Str(SPB_SEC_USERNAME));
userPos = switches.getCount();
}
found = true;
}
switch (spb.getClumpTag())
@ -2621,13 +2617,16 @@ bool Service::process_switches(ClumpletReader& spb, string& switches)
{
return false;
}
// fall through ....
case isc_spb_sec_username:
get_action_svc_string(spb, switches);
break;
case isc_spb_sec_username:
get_action_svc_string_pos(spb, switches, userPos);
break;
default:
return false;
fatal_exception::raise("Invalid item in service parameter block - invalid code for security database operation");
// no return
}
break;
@ -2639,13 +2638,12 @@ bool Service::process_switches(ClumpletReader& spb, string& switches)
{
return false;
}
found = true;
if (spb.getClumpTag() != isc_spb_sec_username)
{
// unexpected item in service parameter block, expected @1
status_exception::raise(Arg::Gds(isc_unexp_spb_form) << Arg::Str(SPB_SEC_USERNAME));
userPos = switches.getCount();
}
found = true;
}
switch (spb.getClumpTag())
@ -2678,11 +2676,14 @@ bool Service::process_switches(ClumpletReader& spb, string& switches)
{
return false;
}
// fall through ....
case isc_spb_sec_username:
get_action_svc_string(spb, switches);
break;
case isc_spb_sec_username:
get_action_svc_string_pos(spb, switches, userPos);
userPos = string::npos;
break;
default:
return false;
}
@ -2904,6 +2905,13 @@ bool Service::process_switches(ClumpletReader& spb, string& switches)
spb.moveNext();
} while (! spb.isEof());
if (userPos != string::npos && svc_action != isc_action_svc_display_user &&
svc_action != isc_action_svc_display_user_adm)
{
// unexpected item in service parameter block, expected @1
status_exception::raise(Arg::Gds(isc_unexp_spb_form) << Arg::Str(SPB_SEC_USERNAME));
}
// postfixes for burp & nbackup
switch (svc_action)
{
@ -2995,6 +3003,19 @@ void Service::get_action_svc_string(const ClumpletReader& spb, string& switches)
}
void Service::get_action_svc_string_pos(const ClumpletReader& spb, string& switches, string::size_type p)
{
if (p == string::npos)
get_action_svc_string(spb, switches);
else
{
string s;
get_action_svc_string(spb, s);
switches.insert(p, s);
}
}
void Service::get_action_svc_data(const ClumpletReader& spb, string& switches)
{
string s;

View File

@ -247,6 +247,9 @@ private:
Firebird::string& sw);
// Get string from within spb buffer, add it to the command line
static void get_action_svc_string(const Firebird::ClumpletReader& spb, Firebird::string& sw);
// Get string from within spb buffer, insert it at given position into command line
static void get_action_svc_string_pos(const Firebird::ClumpletReader& spb, Firebird::string& switches,
Firebird::string::size_type p = Firebird::string::npos);
// Get integer from within spb buffer, add it to the command line
static void get_action_svc_data(const Firebird::ClumpletReader& spb, Firebird::string& sw);
// Get parameter from within spb buffer, find corresponding switch within specified table,