@@ -5337,7 +5337,9 @@ has_privs_of_role_strict_no_cache(Oid member, Oid role)
53375337*/
53385338
53395339bool
5340- has_privs_of_unwanted_system_role (Oid role ) {
5340+ has_privs_of_unwanted_system_role (Oid role , bool check_mdb_service_auth ) {
5341+ Oid mdb_service_authoid ;
5342+
53415343 if (has_privs_of_role_strict (role , ROLE_PG_READ_SERVER_FILES )) {
53425344 return true;
53435345 }
@@ -5354,6 +5356,14 @@ has_privs_of_unwanted_system_role(Oid role) {
53545356 return true;
53555357 }
53565358
5359+ if (check_mdb_service_auth ) {
5360+ mdb_service_authoid = get_role_oid ("mdb_service_auth" , true);
5361+
5362+ if (has_privs_of_role_strict (role , mdb_service_authoid )) {
5363+ return true;
5364+ }
5365+ }
5366+
53575367 return false;
53585368}
53595369
@@ -5400,7 +5410,7 @@ has_privs_of_role(Oid member, Oid role)
54005410 * if target role is neither superuser nor
54015411 * some dangerous system role
54025412 */
5403- if (!has_privs_of_unwanted_system_role (role )) {
5413+ if (!has_privs_of_unwanted_system_role (role , true )) {
54045414 return true;
54055415 }
54065416 }
@@ -5455,7 +5465,7 @@ mdb_admin_allow_bypass_owner_checks(Oid userId, Oid ownerId)
54555465 */
54565466
54575467 /* All checks passed, hope will not be hacked here (again) */
5458- return !has_privs_of_unwanted_system_role (ownerId );
5468+ return !has_privs_of_unwanted_system_role (ownerId , true );
54595469}
54605470
54615471// -- non-upstream patch end
@@ -5534,7 +5544,7 @@ check_mdb_admin_is_member_of_role(Oid member, Oid role)
55345544 GetUserNameFromId (role , false))));
55355545 }
55365546
5537- if (has_privs_of_unwanted_system_role (role )) {
5547+ if (has_privs_of_unwanted_system_role (role , true )) {
55385548 ereport (ERROR ,
55395549 (errcode (ERRCODE_INSUFFICIENT_PRIVILEGE ),
55405550 errmsg ("forbidden to transfer ownership to this system role in Cloud" )));
@@ -5568,7 +5578,7 @@ bool mdb_admin_is_member_of_role(Oid member, Oid role) {
55685578 return false;
55695579 }
55705580
5571- return !has_privs_of_unwanted_system_role (role );
5581+ return !has_privs_of_unwanted_system_role (role , true );
55725582}
55735583
55745584// -- mdb admin patch
0 commit comments