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

Fixed CORE-4164: Owner name is missing for generators/exceptions restored from a backup.

Also propagated the sysflag/owner/secclass assignment and validation to all object types and wiped out the duplicating system triggers.
Warning: testing is required!
This commit is contained in:
dimitr 2013-08-04 15:19:31 +00:00
parent ccef8ee6de
commit 69961e9bae
13 changed files with 155 additions and 203 deletions

View File

@ -1526,6 +1526,8 @@ C --
PARAMETER (GDS__include_depth = 335545056)
INTEGER*4 GDS__include_miss
PARAMETER (GDS__include_miss = 335545057)
INTEGER*4 GDS__protect_ownership
PARAMETER (GDS__protect_ownership = 335545058)
INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw

View File

@ -770,6 +770,7 @@ const
gds_conf_include = 335545055;
gds_include_depth = 335545056;
gds_include_miss = 335545057;
gds_protect_ownership = 335545058;
gds_gfix_db_name = 335740929;
gds_gfix_invalid_sw = 335740930;
gds_gfix_incmp_sw = 335740932;

View File

@ -759,6 +759,7 @@ static const struct {
{"conf_include", 335545055},
{"include_depth", 335545056},
{"include_miss", 335545057},
{"protect_ownership", 335545058},
{"gfix_db_name", 335740929},
{"gfix_invalid_sw", 335740930},
{"gfix_incmp_sw", 335740932},

View File

@ -793,6 +793,7 @@ const ISC_STATUS isc_conf_line = 335545054L;
const ISC_STATUS isc_conf_include = 335545055L;
const ISC_STATUS isc_include_depth = 335545056L;
const ISC_STATUS isc_include_miss = 335545057L;
const ISC_STATUS isc_protect_ownership = 335545058L;
const ISC_STATUS isc_gfix_db_name = 335740929L;
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@ -1237,7 +1238,7 @@ const ISC_STATUS isc_trace_switch_user_only = 337182757L;
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
const ISC_STATUS isc_err_max = 1181;
const ISC_STATUS isc_err_max = 1182;
#else /* c definitions */
@ -2000,6 +2001,7 @@ const ISC_STATUS isc_err_max = 1181;
#define isc_conf_include 335545055L
#define isc_include_depth 335545056L
#define isc_include_miss 335545057L
#define isc_protect_ownership 335545058L
#define isc_gfix_db_name 335740929L
#define isc_gfix_invalid_sw 335740930L
#define isc_gfix_incmp_sw 335740932L
@ -2444,7 +2446,7 @@ const ISC_STATUS isc_err_max = 1181;
#define isc_trace_switch_param_miss 337182758L
#define isc_trace_param_act_notcompat 337182759L
#define isc_trace_mandatory_switch_miss 337182760L
#define isc_err_max 1181
#define isc_err_max 1182
#endif

View File

@ -762,6 +762,7 @@ Data source : @4"}, /* eds_statement */
{335545055, "Invalid include operator in @1 for <@2>"}, /* conf_include */
{335545056, "Include depth too big"}, /* include_depth */
{335545057, "File to include not found"}, /* include_miss */
{335545058, "Only the owner can change the ownership"}, /* protect_ownership */
{335740929, "data base file name (@1) already given"}, /* gfix_db_name */
{335740930, "invalid switch @1"}, /* gfix_invalid_sw */
{335740932, "incompatible switch combination"}, /* gfix_incmp_sw */

View File

@ -758,6 +758,7 @@ static const struct {
{335545055, -902}, /* 735 conf_include */
{335545056, -902}, /* 736 include_depth */
{335545057, -902}, /* 737 include_miss */
{335545058, -552}, /* 738 protect_ownership */
{335740929, -901}, /* 1 gfix_db_name */
{335740930, -901}, /* 2 gfix_invalid_sw */
{335740932, -901}, /* 4 gfix_incmp_sw */

View File

@ -758,6 +758,7 @@ static const struct {
{335545055, "XX000"}, // 735 conf_include
{335545056, "XX000"}, // 736 include_depth
{335545057, "XX000"}, // 737 include_miss
{335545058, "28000"}, // 738 protect_ownership
{335740929, "00000"}, // 1 gfix_db_name
{335740930, "00000"}, // 2 gfix_invalid_sw
{335740932, "00000"}, // 4 gfix_incmp_sw

View File

@ -105,15 +105,6 @@ static const jrd_trg triggers[] =
{ "RDB$TRIGGER_3", (UCHAR) nam_trgs,
RDB$TRIGGERS.RDB$TRIGGER_TYPE.PRE_ERASE, sizeof(trigger4), trigger4,
0, ODS_8_0 },
{ "RDB$TRIGGER_4", (UCHAR) nam_relations,
RDB$TRIGGERS.RDB$TRIGGER_TYPE.PRE_STORE, sizeof(trigger5), trigger5,
0, ODS_8_0 },
{ "RDB$TRIGGER_5", (UCHAR) nam_relations,
RDB$TRIGGERS.RDB$TRIGGER_TYPE.PRE_MODIFY, sizeof(trigger6), trigger6,
0, ODS_8_0 },
{ "RDB$TRIGGER_6", (UCHAR) nam_gens,
RDB$TRIGGERS.RDB$TRIGGER_TYPE.PRE_STORE, sizeof(trigger7), trigger7,
0, ODS_8_0 },
{ "RDB$TRIGGER_26", (UCHAR) nam_rel_constr,
RDB$TRIGGERS.RDB$TRIGGER_TYPE.PRE_STORE, sizeof(trigger26), trigger26,
0, ODS_8_0 },
@ -168,15 +159,6 @@ static const jrd_trg triggers[] =
{ "RDB$TRIGGER_27", (UCHAR) nam_r_fields,
RDB$TRIGGERS.RDB$TRIGGER_TYPE.POST_ERASE, sizeof(trigger27),
trigger27, 0, ODS_8_0 },
{ "RDB$TRIGGER_28", (UCHAR) nam_procedures,
RDB$TRIGGERS.RDB$TRIGGER_TYPE.PRE_STORE, sizeof(trigger28), trigger28,
0, ODS_8_0 },
{ "RDB$TRIGGER_29", (UCHAR) nam_procedures,
RDB$TRIGGERS.RDB$TRIGGER_TYPE.PRE_MODIFY, sizeof(trigger29),
trigger29, 0, ODS_8_0 },
{ "RDB$TRIGGER_30", (UCHAR) nam_exceptions,
RDB$TRIGGERS.RDB$TRIGGER_TYPE.PRE_STORE, sizeof(trigger30), trigger30,
0, ODS_8_0 },
{ "RDB$TRIGGER_31", (UCHAR) nam_user_privileges,
RDB$TRIGGERS.RDB$TRIGGER_TYPE.PRE_MODIFY, sizeof(trigger31),
trigger31, 0, ODS_8_1 },
@ -212,7 +194,6 @@ static const trigger_msg trigger_messages[] =
{ "RDB$TRIGGER_1", 0, "existing_priv_mod", ODS_8_0 },
{ "RDB$TRIGGER_2", 0, "systrig_update", ODS_8_0 },
{ "RDB$TRIGGER_3", 0, "systrig_update", ODS_8_0 },
{ "RDB$TRIGGER_5", 0, "not_rel_owner", ODS_8_0 },
{ "RDB$TRIGGER_24", 1, "cnstrnt_fld_rename", ODS_8_0 },
{ "RDB$TRIGGER_23", 1, "cnstrnt_fld_del", ODS_8_0 },
{ "RDB$TRIGGER_22", 1, "check_trig_update", ODS_8_0 },

View File

@ -1106,68 +1106,6 @@ static const UCHAR trigger4[] =
};
static const UCHAR trigger5[] =
{
blr_version5,
blr_if,
blr_missing,
blr_field, 1, 14, 'R', 'D', 'B', '$', 'O', 'W', 'N', 'E', 'R', '_', 'N',
'A', 'M', 'E',
blr_assignment,
blr_upcase,
blr_user_name,
blr_field, 1, 14, 'R', 'D', 'B', '$', 'O', 'W', 'N', 'E', 'R', '_', 'N',
'A', 'M', 'E',
blr_end,
blr_eoc
};
/******
static const TEXT trigger_6_msg_0 [] = "only the owner of a relation may reassign ownership";
******/
static const UCHAR trigger6[] =
{
blr_version5,
blr_if,
blr_and,
blr_neq,
blr_field, 0, 14, 'R', 'D', 'B', '$', 'O', 'W', 'N', 'E', 'R', '_', 'N',
'A', 'M', 'E',
blr_field, 1, 14, 'R', 'D', 'B', '$', 'O', 'W', 'N', 'E', 'R', '_', 'N',
'A', 'M', 'E',
blr_neq,
blr_field, 0, 14, 'R', 'D', 'B', '$', 'O', 'W', 'N', 'E', 'R', '_', 'N',
'A', 'M', 'E',
blr_upcase,
blr_user_name,
blr_leave, 0,
blr_end,
blr_eoc
};
static const UCHAR trigger7[] =
{
blr_version5,
blr_begin,
blr_if,
blr_missing,
blr_field, 1, 16, 'R', 'D', 'B', '$', 'G', 'E', 'N', 'E', 'R', 'A', 'T',
'O', 'R', '_', 'I', 'D',
blr_assignment,
blr_gen_id, 14, 'R', 'D', 'B', '$', 'G', 'E', 'N', 'E', 'R', 'A', 'T',
'O', 'R', 'S',
blr_literal, blr_long, 0, 1, 0, 0, 0,
blr_field, 1, 16, 'R', 'D', 'B', '$', 'G', 'E', 'N', 'E', 'R', 'A', 'T',
'O', 'R', '_', 'I', 'D',
blr_end,
blr_end,
blr_eoc
};
/* define trigger add_constraint for rdb$relation_constraints */
/******
@ -2444,77 +2382,6 @@ static const UCHAR trigger27[] =
};
static const UCHAR trigger28[] =
{
blr_version5,
blr_begin,
blr_if,
blr_missing,
blr_field, 1, 14, 'R', 'D', 'B', '$', 'O', 'W', 'N', 'E', 'R', '_', 'N',
'A', 'M', 'E',
blr_assignment,
blr_upcase,
blr_user_name,
blr_field, 1, 14, 'R', 'D', 'B', '$', 'O', 'W', 'N', 'E', 'R', '_', 'N',
'A', 'M', 'E',
blr_end,
blr_if,
blr_missing,
blr_field, 1, 16, 'R', 'D', 'B', '$', 'P', 'R', 'O', 'C', 'E', 'D', 'U',
'R', 'E', '_', 'I', 'D',
blr_assignment,
blr_gen_id, 14, 'R', 'D', 'B', '$', 'P', 'R', 'O', 'C', 'E', 'D', 'U',
'R', 'E', 'S',
blr_literal, blr_long, 0, 1, 0, 0, 0,
blr_field, 1, 16, 'R', 'D', 'B', '$', 'P', 'R', 'O', 'C', 'E', 'D', 'U',
'R', 'E', '_', 'I', 'D',
blr_end,
blr_end,
blr_eoc
};
static const UCHAR trigger29[] =
{
blr_version5,
blr_if,
blr_and,
blr_neq,
blr_field, 0, 14, 'R', 'D', 'B', '$', 'O', 'W', 'N', 'E', 'R', '_', 'N',
'A', 'M', 'E',
blr_field, 1, 14, 'R', 'D', 'B', '$', 'O', 'W', 'N', 'E', 'R', '_', 'N',
'A', 'M', 'E',
blr_neq,
blr_field, 0, 14, 'R', 'D', 'B', '$', 'O', 'W', 'N', 'E', 'R', '_', 'N',
'A', 'M', 'E',
blr_upcase,
blr_user_name,
blr_leave, 0,
blr_end,
blr_eoc
};
static const UCHAR trigger30[] =
{
blr_version5,
blr_begin,
blr_if,
blr_missing,
blr_field, 1, 20, 'R', 'D', 'B', '$', 'E', 'X', 'C', 'E', 'P', 'T', 'I',
'O', 'N', '_', 'N', 'U', 'M', 'B', 'E', 'R',
blr_assignment,
blr_gen_id, 14, 'R', 'D', 'B', '$', 'E', 'X', 'C', 'E', 'P', 'T', 'I',
'O', 'N', 'S',
blr_literal, blr_long, 0, 1, 0, 0, 0,
blr_field, 1, 20, 'R', 'D', 'B', '$', 'E', 'X', 'C', 'E', 'P', 'T', 'I',
'O', 'N', '_', 'N', 'U', 'M', 'B', 'E', 'R',
blr_end,
blr_end,
blr_eoc
};
/* new trigger to create ODS 8.1 (and to upgrade from ODS 8.0 to ODS 8.1 */
static const UCHAR trigger31[] =
{

View File

@ -96,6 +96,7 @@ using namespace Jrd;
using namespace Firebird;
static void check_class(thread_db*, jrd_tra*, record_param*, record_param*, USHORT);
static void check_owner(thread_db*, jrd_tra*, record_param*, record_param*, USHORT);
static bool check_user(thread_db*, const dsc*);
static int check_precommitted(const jrd_tra*, const record_param*);
static void check_rel_field_class(thread_db*, record_param*, SecurityClass::flags_t, jrd_tra*);
@ -161,8 +162,9 @@ static void purge(thread_db*, record_param*);
static Record* replace_gc_record(jrd_rel*, Record**, USHORT);
static void replace_record(thread_db*, record_param*, PageStack*, const jrd_tra*);
static SSHORT set_metadata_id(thread_db*, Record*, USHORT, drq_type_t, const char*);
static void set_owner_name(thread_db*, Record*, USHORT);
static void set_security_class(thread_db*, Record*, USHORT);
static void set_system_flag(thread_db*, Record*, USHORT, SSHORT);
static void set_system_flag(thread_db*, Record*, USHORT);
static void update_in_place(thread_db*, jrd_tra*, record_param*, record_param*);
static void verb_post(thread_db*, jrd_tra*, record_param*, Record*, const bool, const bool);
@ -2361,6 +2363,7 @@ void VIO_modify(thread_db* tdbb, record_param* org_rpb, record_param* new_rpb, j
EVL_field(0, org_rpb->rpb_record, f_rel_name, &desc1);
SCL_check_relation(tdbb, &desc1, SCL_alter);
check_class(tdbb, transaction, org_rpb, new_rpb, f_rel_class);
check_owner(tdbb, transaction, org_rpb, new_rpb, f_rel_owner);
DFW_post_work(transaction, dfw_update_format, &desc1, 0);
break;
@ -2368,6 +2371,7 @@ void VIO_modify(thread_db* tdbb, record_param* org_rpb, record_param* new_rpb, j
if (EVL_field(0, org_rpb->rpb_record, f_pkg_name, &desc1))
SCL_check_package(tdbb, &desc1, SCL_alter);
check_class(tdbb, transaction, org_rpb, new_rpb, f_pkg_class);
check_owner(tdbb, transaction, org_rpb, new_rpb, f_pkg_owner);
break;
case rel_procedures:
@ -2384,6 +2388,7 @@ void VIO_modify(thread_db* tdbb, record_param* org_rpb, record_param* new_rpb, j
}
check_class(tdbb, transaction, org_rpb, new_rpb, f_prc_class);
check_owner(tdbb, transaction, org_rpb, new_rpb, f_prc_owner);
if (dfw_should_know(org_rpb, new_rpb, f_prc_desc, true))
{
@ -2407,6 +2412,7 @@ void VIO_modify(thread_db* tdbb, record_param* org_rpb, record_param* new_rpb, j
}
check_class(tdbb, transaction, org_rpb, new_rpb, f_fun_class);
check_owner(tdbb, transaction, org_rpb, new_rpb, f_fun_owner);
if (dfw_should_know(org_rpb, new_rpb, f_fun_desc, true))
{
@ -2420,6 +2426,8 @@ void VIO_modify(thread_db* tdbb, record_param* org_rpb, record_param* new_rpb, j
EVL_field(0, org_rpb->rpb_record, f_gen_name, &desc1);
MOV_get_metaname(&desc1, object_name);
SCL_check_generator(tdbb, object_name, SCL_alter);
check_class(tdbb, transaction, org_rpb, new_rpb, f_gen_class);
check_owner(tdbb, transaction, org_rpb, new_rpb, f_gen_owner);
break;
case rel_rfr:
@ -2479,6 +2487,8 @@ void VIO_modify(thread_db* tdbb, record_param* org_rpb, record_param* new_rpb, j
if ((!rc1 || MOV_get_long(&desc3, 0) == 0) && rc2 && MOV_get_long(&desc4, 0) != 0)
DFW_post_work_arg(transaction, dw, &desc2, 0, dfw_arg_field_not_null);
}
check_class(tdbb, transaction, org_rpb, new_rpb, f_fld_class);
check_owner(tdbb, transaction, org_rpb, new_rpb, f_fld_owner);
break;
case rel_classes:
@ -2553,18 +2563,24 @@ void VIO_modify(thread_db* tdbb, record_param* org_rpb, record_param* new_rpb, j
EVL_field(0, new_rpb->rpb_record, f_cs_cs_name, &desc1);
MOV_get_metaname(&desc1, object_name);
SCL_check_charset(tdbb, object_name, SCL_alter);
check_class(tdbb, transaction, org_rpb, new_rpb, f_cs_class);
check_owner(tdbb, transaction, org_rpb, new_rpb, f_cs_owner);
break;
case rel_collations:
EVL_field(0, new_rpb->rpb_record, f_coll_name, &desc1);
MOV_get_metaname(&desc1, object_name);
SCL_check_collation(tdbb, object_name, SCL_alter);
check_class(tdbb, transaction, org_rpb, new_rpb, f_coll_class);
check_owner(tdbb, transaction, org_rpb, new_rpb, f_coll_owner);
break;
case rel_exceptions:
EVL_field(0, new_rpb->rpb_record, f_xcp_name, &desc1);
MOV_get_metaname(&desc1, object_name);
SCL_check_exception(tdbb, object_name, SCL_alter);
check_class(tdbb, transaction, org_rpb, new_rpb, f_xcp_class);
check_owner(tdbb, transaction, org_rpb, new_rpb, f_xcp_owner);
break;
default:
@ -2874,8 +2890,11 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
*
**************************************/
SET_TDBB(tdbb);
jrd_req* request = tdbb->getRequest();
jrd_req* const request = tdbb->getRequest();
DeferredWork* work = NULL;
MetaName package_name;
USHORT object_id;
#ifdef VIO_DEBUG
VIO_trace(DEBUG_WRITES,
@ -2896,24 +2915,28 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
EVL_field(0, rpb->rpb_record, f_rel_name, &desc);
DFW_post_work(transaction, dfw_create_relation, &desc, 0);
DFW_post_work(transaction, dfw_update_format, &desc, 0);
set_system_flag(tdbb, rpb->rpb_record, f_rel_sys_flag, 0);
set_system_flag(tdbb, rpb->rpb_record, f_rel_sys_flag);
set_security_class(tdbb, rpb->rpb_record, f_rel_class);
set_owner_name(tdbb, rpb->rpb_record, f_rel_owner);
break;
case rel_packages:
set_system_flag(tdbb, rpb->rpb_record, f_pkg_sys_flag, 0);
set_system_flag(tdbb, rpb->rpb_record, f_pkg_sys_flag);
set_security_class(tdbb, rpb->rpb_record, f_pkg_class);
set_owner_name(tdbb, rpb->rpb_record, f_pkg_owner);
break;
case rel_procedures:
EVL_field(0, rpb->rpb_record, f_prc_name, &desc);
if (EVL_field(0, rpb->rpb_record, f_prc_pkg_name, &desc2))
MOV_get_metaname(&desc2, package_name);
object_id = set_metadata_id(tdbb, rpb->rpb_record,
f_prc_id, drq_g_nxt_prc_id, "RDB$PROCEDURES");
work = DFW_post_work(transaction, dfw_create_procedure, &desc, object_id, package_name);
{ // scope
MetaName package_name;
if (EVL_field(0, rpb->rpb_record, f_prc_pkg_name, &desc2))
MOV_get_metaname(&desc2, package_name);
EVL_field(0, rpb->rpb_record, f_prc_id, &desc2);
const USHORT id = MOV_get_long(&desc2, 0);
work = DFW_post_work(transaction, dfw_create_procedure, &desc, id, package_name);
bool check_blr = true;
if (EVL_field(0, rpb->rpb_record, f_prc_valid_blr, &desc2))
check_blr = MOV_get_long(&desc2, 0) != 0;
@ -2921,22 +2944,23 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
if (check_blr)
DFW_post_work_arg(transaction, work, NULL, 0, dfw_arg_check_blr);
} // scope
set_system_flag(tdbb, rpb->rpb_record, f_prc_sys_flag, 0);
set_system_flag(tdbb, rpb->rpb_record, f_prc_sys_flag);
set_security_class(tdbb, rpb->rpb_record, f_prc_class);
set_owner_name(tdbb, rpb->rpb_record, f_prc_owner);
break;
case rel_funs:
EVL_field(0, rpb->rpb_record, f_fun_name, &desc);
if (EVL_field(0, rpb->rpb_record, f_fun_pkg_name, &desc2))
MOV_get_metaname(&desc2, package_name);
object_id = set_metadata_id(tdbb, rpb->rpb_record,
f_fun_id, drq_g_nxt_fun_id, "RDB$FUNCTIONS");
work = DFW_post_work(transaction, dfw_create_function, &desc, object_id, package_name);
{ // scope
MetaName package_name;
if (EVL_field(0, rpb->rpb_record, f_fun_pkg_name, &desc2))
MOV_get_metaname(&desc2, package_name);
const USHORT id =
set_metadata_id(tdbb, rpb->rpb_record, f_fun_id, drq_g_nxt_fun_id, "RDB$FUNCTIONS");
work = DFW_post_work(transaction, dfw_create_function, &desc, id, package_name);
set_security_class(tdbb, rpb->rpb_record, f_fun_class);
bool check_blr = true;
if (EVL_field(0, rpb->rpb_record, f_fun_valid_blr, &desc2))
check_blr = MOV_get_long(&desc2, 0) != 0;
@ -2944,7 +2968,10 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
if (check_blr)
DFW_post_work_arg(transaction, work, NULL, 0, dfw_arg_check_blr);
} // scope
set_system_flag(tdbb, rpb->rpb_record, f_fun_sys_flag, 0);
set_system_flag(tdbb, rpb->rpb_record, f_fun_sys_flag);
set_security_class(tdbb, rpb->rpb_record, f_fun_class);
set_owner_name(tdbb, rpb->rpb_record, f_fun_owner);
break;
case rel_indices:
@ -2959,13 +2986,14 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
else {
DFW_post_work(transaction, dfw_create_index, &desc, tdbb->getDatabase()->dbb_max_idx);
}
set_system_flag(tdbb, rpb->rpb_record, f_idx_sys_flag);
break;
case rel_rfr:
EVL_field(0, rpb->rpb_record, f_rfr_rname, &desc);
SCL_check_relation(tdbb, &desc, SCL_control);
DFW_post_work(transaction, dfw_update_format, &desc, 0);
set_system_flag(tdbb, rpb->rpb_record, f_rfr_sys_flag, 0);
set_system_flag(tdbb, rpb->rpb_record, f_rfr_sys_flag);
break;
case rel_classes:
@ -2976,8 +3004,9 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
case rel_fields:
EVL_field(0, rpb->rpb_record, f_fld_name, &desc);
DFW_post_work(transaction, dfw_create_field, &desc, 0);
set_system_flag(tdbb, rpb->rpb_record, f_fld_sys_flag, 0);
set_system_flag(tdbb, rpb->rpb_record, f_fld_sys_flag);
set_security_class(tdbb, rpb->rpb_record, f_fld_class);
set_owner_name(tdbb, rpb->rpb_record, f_fld_owner);
break;
case rel_files:
@ -3016,9 +3045,8 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
EVL_field(0, rpb->rpb_record, f_trg_rname, &desc);
// check if this request go through without checking permissions
if (!(request->getStatement()->flags & JrdStatement::FLAG_IGNORE_PERM)) {
if (!(request->getStatement()->flags & JrdStatement::FLAG_IGNORE_PERM))
SCL_check_relation(tdbb, &desc, SCL_control);
}
if (EVL_field(0, rpb->rpb_record, f_trg_rname, &desc2))
DFW_post_work(transaction, dfw_update_format, &desc2, 0);
@ -3034,16 +3062,14 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
DFW_post_work_arg(transaction, work, &desc2,
(USHORT) MOV_get_int64(&desc2, 0), dfw_arg_trg_type);
}
set_system_flag(tdbb, rpb->rpb_record, f_trg_sys_flag);
break;
case rel_priv:
EVL_field(0, rpb->rpb_record, f_prv_rname, &desc);
EVL_field(0, rpb->rpb_record, f_prv_o_type, &desc2);
{ // scope
const USHORT id = MOV_get_long(&desc2, 0);
DFW_post_work(transaction, dfw_grant, &desc, id);
} // scope
object_id = MOV_get_long(&desc2, 0);
DFW_post_work(transaction, dfw_grant, &desc, object_id);
break;
case rel_vrel:
@ -3062,24 +3088,33 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
case rel_gens:
EVL_field(0, rpb->rpb_record, f_gen_name, &desc);
EVL_field(0, rpb->rpb_record, f_gen_id, &desc2);
{
const USHORT id = MOV_get_long(&desc2, 0);
transaction->getGenIdCache()->put(id, 0);
DFW_post_work(transaction, dfw_set_generator, &desc, id);
}
object_id = set_metadata_id(tdbb, rpb->rpb_record,
f_gen_id, drq_g_nxt_gen_id, "RDB$GENERATORS");
transaction->getGenIdCache()->put(object_id, 0);
DFW_post_work(transaction, dfw_set_generator, &desc, object_id);
set_system_flag(tdbb, rpb->rpb_record, f_gen_sys_flag);
set_security_class(tdbb, rpb->rpb_record, f_gen_class);
set_owner_name(tdbb, rpb->rpb_record, f_gen_owner);
break;
case rel_charsets:
set_system_flag(tdbb, rpb->rpb_record, f_cs_sys_flag);
set_security_class(tdbb, rpb->rpb_record, f_cs_class);
set_owner_name(tdbb, rpb->rpb_record, f_cs_owner);
break;
case rel_collations:
set_system_flag(tdbb, rpb->rpb_record, f_coll_sys_flag);
set_security_class(tdbb, rpb->rpb_record, f_coll_class);
set_owner_name(tdbb, rpb->rpb_record, f_coll_owner);
break;
case rel_exceptions:
set_metadata_id(tdbb, rpb->rpb_record,
f_xcp_number, drq_g_nxt_xcp_id, "RDB$EXCEPTIONS");
set_system_flag(tdbb, rpb->rpb_record, f_xcp_sys_flag);
set_security_class(tdbb, rpb->rpb_record, f_xcp_class);
set_owner_name(tdbb, rpb->rpb_record, f_xcp_owner);
break;
default: // Shut up compiler warnings
@ -3788,6 +3823,40 @@ static void check_class(thread_db* tdbb,
}
static void check_owner(thread_db* tdbb,
jrd_tra* transaction,
record_param* old_rpb, record_param* new_rpb, USHORT id)
{
/**************************************
*
* c h e c k _ o w n e r
*
**************************************
*
* Functional description
* A record in a system relation containing an owner is
* being changed. Check to see if the owner has changed,
* and if so, validate whether this action is allowed.
*
**************************************/
SET_TDBB(tdbb);
DSC desc1, desc2;
EVL_field(0, old_rpb->rpb_record, id, &desc1);
EVL_field(0, new_rpb->rpb_record, id, &desc2);
if (!MOV_compare(&desc1, &desc2))
return;
const Jrd::Attachment* const attachment = tdbb->getAttachment();
const Firebird::MetaName name(attachment->att_user->usr_user_name);
desc2.makeText((USHORT) name.length(), CS_METADATA, (UCHAR*) name.c_str());
if (!MOV_compare(&desc1, &desc2))
return;
ERR_post(Arg::Gds(isc_protect_ownership));
}
static bool check_user(thread_db* tdbb, const dsc* desc)
{
/**************************************
@ -5393,9 +5462,7 @@ static SSHORT set_metadata_id(thread_db* tdbb, Record* record, USHORT field_id,
dsc desc1;
if (EVL_field(0, record, field_id, &desc1))
{
return MOV_get_long(&desc1, 0);
}
SSHORT value = (SSHORT) DYN_UTIL_gen_unique_id(tdbb, dyn_id, name);
dsc desc2;
@ -5406,6 +5473,32 @@ static SSHORT set_metadata_id(thread_db* tdbb, Record* record, USHORT field_id,
}
static void set_owner_name(thread_db* tdbb, Record* record, USHORT field_id)
{
/**************************************
*
* s e t _ o w n e r _ n a m e
*
**************************************
*
* Functional description
* Set the owner name for the metadata object.
*
**************************************/
dsc desc1;
if (!EVL_field(0, record, field_id, &desc1))
{
const Jrd::Attachment* const attachment = tdbb->getAttachment();
const Firebird::MetaName name(attachment->att_user->usr_user_name);
dsc desc2;
desc2.makeText((USHORT) name.length(), CS_METADATA, (UCHAR*) name.c_str());
MOV_move(tdbb, &desc2, &desc1);
record->clearNull(field_id);
}
}
static void set_security_class(thread_db* tdbb, Record* record, USHORT field_id)
{
/**************************************
@ -5433,7 +5526,7 @@ static void set_security_class(thread_db* tdbb, Record* record, USHORT field_id)
}
static void set_system_flag(thread_db* tdbb, Record* record, USHORT field_id, SSHORT flag)
static void set_system_flag(thread_db* tdbb, Record* record, USHORT field_id)
{
/**************************************
*
@ -5447,14 +5540,14 @@ static void set_system_flag(thread_db* tdbb, Record* record, USHORT field_id, SS
**************************************/
dsc desc1;
if (EVL_field(0, record, field_id, &desc1)) {
return;
if (!EVL_field(0, record, field_id, &desc1))
{
SSHORT flag = 0;
dsc desc2;
desc2.makeShort(0, &flag);
MOV_move(tdbb, &desc2, &desc1);
record->clearNull(field_id);
}
dsc desc2;
desc2.makeShort(0, &flag);
MOV_move(tdbb, &desc2, &desc1);
record->clearNull(field_id);
}

View File

@ -1,7 +1,7 @@
/* MAX_NUMBER is the next number to be used, always one more than the highest message number. */
set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES (?, ?, ?, ?);
--
('2013-03-26 17:52:41', 'JRD', 0, 738)
('2013-03-26 17:52:41', 'JRD', 0, 739)
('2012-01-23 20:10:30', 'QLI', 1, 532)
('2009-07-16 05:26:11', 'GFIX', 3, 121)
('1996-11-07 13:39:40', 'GPRE', 4, 1)

View File

@ -845,6 +845,7 @@ Data source : @4', NULL, NULL)
('conf_include', NULL, 'config_file.cpp', NULL, 0, 735, NULL, 'Invalid include operator in @1 for <@2>', NULL, NULL);
('include_depth', NULL, 'config_file.cpp', NULL, 0, 736, NULL, 'Include depth too big', NULL, NULL);
('include_miss', NULL, 'config_file.cpp', NULL, 0, 737, NULL, 'File to include not found', NULL, NULL);
('protect_ownership', 'check_owner', 'vio.cpp', NULL, 0, 738, NULL, 'Only the owner can change the ownership', NULL, NULL);
-- QLI
(NULL, NULL, NULL, NULL, 1, 0, NULL, 'expected type', NULL, NULL);
(NULL, NULL, NULL, NULL, 1, 1, NULL, 'bad block type', NULL, NULL);

View File

@ -744,6 +744,7 @@ set bulk_insert INSERT INTO SYSTEM_ERRORS (SQL_CODE, SQL_CLASS, SQL_SUBCLASS, FA
(-902, 'XX', '000', 0, 735, 'conf_include', NULL, NULL)
(-902, 'XX', '000', 0, 736, 'include_depth', NULL, NULL)
(-902, 'XX', '000', 0, 737, 'include_miss', NULL, NULL)
(-552, '28', '000', 0, 738, 'protect_ownership', NULL, NULL)
-- GFIX
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)