diff --git a/src/jrd/scl.epp b/src/jrd/scl.epp index 94737fb38f..95e915cdbe 100644 --- a/src/jrd/scl.epp +++ b/src/jrd/scl.epp @@ -82,7 +82,8 @@ static inline void check_and_move(UCHAR from, Acl& to) to.push(from); } -struct P_NAMES { +struct P_NAMES +{ SecurityClass::flags_t p_names_priv; USHORT p_names_acl; const TEXT* p_names_string; @@ -185,12 +186,14 @@ void SCL_check_access(thread_db* tdbb, } } - if (denied_db) { + if (denied_db) + { ERR_post(Arg::Gds(isc_no_priv) << Arg::Str(names->p_names_string) << Arg::Str("DATABASE") << Arg::Str("")); } - else { + else + { ERR_post(Arg::Gds(isc_no_priv) << Arg::Str(names->p_names_string) << Arg::Str(type) << Arg::Str(name)); @@ -276,7 +279,8 @@ void SCL_check_index(thread_db* tdbb, const Firebird::MetaName& index_name, UCHA // No need to cache this request handle, it's only used when // new constraints are created - if (index_id < 1) { + if (index_id < 1) + { FOR(REQUEST_HANDLE request) IND IN RDB$INDICES CROSS REL IN RDB$RELATIONS OVER RDB$RELATION_NAME @@ -291,7 +295,8 @@ void SCL_check_index(thread_db* tdbb, const Firebird::MetaName& index_name, UCHA CMP_release(tdbb, request); } - else { + else + { idx_name_ptr = &aux_idx_name; FOR (REQUEST_HANDLE request) IND IN RDB$INDICES CROSS REL IN RDB$RELATIONS @@ -326,40 +331,41 @@ void SCL_check_index(thread_db* tdbb, const Firebird::MetaName& index_name, UCHA try { - // Check if the field used in the index has the appropriate - // permission. If the field in question does not have a security class - // defined, then the default security class for the table applies for that - // field. + // Check if the field used in the index has the appropriate + // permission. If the field in question does not have a security class + // defined, then the default security class for the table applies for that + // field. - // No need to cache this request handle, it's only used when - // new constraints are created + // No need to cache this request handle, it's only used when + // new constraints are created - FOR(REQUEST_HANDLE request) ISEG IN RDB$INDEX_SEGMENTS - CROSS RF IN RDB$RELATION_FIELDS - OVER RDB$FIELD_NAME - WITH RF.RDB$RELATION_NAME EQ reln_name.c_str() - AND ISEG.RDB$INDEX_NAME EQ idx_name_ptr->c_str() + FOR(REQUEST_HANDLE request) ISEG IN RDB$INDEX_SEGMENTS + CROSS RF IN RDB$RELATION_FIELDS + OVER RDB$FIELD_NAME + WITH RF.RDB$RELATION_NAME EQ reln_name.c_str() + AND ISEG.RDB$INDEX_NAME EQ idx_name_ptr->c_str() - Firebird::string fullFieldName(reln_name.c_str()); - fullFieldName += '.'; - fullFieldName += RF.RDB$FIELD_NAME; - fullFieldName.rtrim(); - if (!RF.RDB$SECURITY_CLASS.NULL) - { - s_class = SCL_get_class(tdbb, RF.RDB$SECURITY_CLASS); - SCL_check_access(tdbb, s_class, 0, NULL, NULL, NULL, mask, object_column, fullFieldName); - } - else - { - SCL_check_access(tdbb, default_s_class, 0, NULL, NULL, NULL, mask, object_column, - fullFieldName); - } + Firebird::string fullFieldName(reln_name.c_str()); + fullFieldName += '.'; + fullFieldName += RF.RDB$FIELD_NAME; + fullFieldName.rtrim(); + if (!RF.RDB$SECURITY_CLASS.NULL) + { + s_class = SCL_get_class(tdbb, RF.RDB$SECURITY_CLASS); + SCL_check_access(tdbb, s_class, 0, NULL, NULL, NULL, mask, object_column, fullFieldName); + } + else + { + SCL_check_access(tdbb, default_s_class, 0, NULL, NULL, NULL, mask, object_column, + fullFieldName); + } - END_FOR; + END_FOR; - CMP_release(tdbb, request); + CMP_release(tdbb, request); } - catch (const Firebird::Exception&) { + catch (const Firebird::Exception&) + { if (request) { CMP_release(tdbb, request); } @@ -667,7 +673,8 @@ void SCL_init(thread_db* tdbb, bool create, const UserId& tempId) // CVC: If we aren't creating a db and sql_role was specified, // then verify it against rdb$roles and rdb$user_privileges - if (!create && sql_role && *sql_role && strcmp(sql_role, NULL_ROLE)) { + if (!create && sql_role && *sql_role && strcmp(sql_role, NULL_ROLE)) + { bool found = false; jrd_req* request = CMP_find_request (tdbb, irq_verify_role_name, IRQ_REQUESTS); @@ -726,7 +733,8 @@ void SCL_init(thread_db* tdbb, bool create, const UserId& tempId) } } - if (sql_role) { + if (sql_role) + { if (role_name != NULL_ROLE) { role_name = sql_role; } @@ -741,7 +749,8 @@ void SCL_init(thread_db* tdbb, bool create, const UserId& tempId) user->usr_sql_role_name = role_name.c_str(); attachment->att_user = user; - if (!create) { + if (!create) + { jrd_req* handle = NULL; jrd_req* handle1 = NULL; jrd_req* handle2 = NULL; @@ -1187,6 +1196,7 @@ static SecurityClass::flags_t walk_acl(thread_db* tdbb, else { TEXT login_name[129]; + fb_assert(user.usr_user_name.length() < sizeof(login_name)); TEXT* pln = login_name; const TEXT* q = user.usr_user_name.c_str(); while (*pln++ = UPPER7(*q)) { @@ -1287,9 +1297,7 @@ static SecurityClass::flags_t walk_acl(thread_db* tdbb, break; case priv_write: - privilege |= - SCL_write | SCL_sql_insert | SCL_sql_update | - SCL_sql_delete; + privilege |= SCL_write | SCL_sql_insert | SCL_sql_update | SCL_sql_delete; break; case priv_sql_insert: