Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit92b1522

Browse files
committed
RLS: Fix ALL vs. SELECT+UPDATE policy usage
When we add the SELECT-privilege based policies to the RLS with checkoptions (such as for an UPDATE statement, or when we have INSERT ...RETURNING), we need to be sure and use the 'USING' case if the policy isactually an 'ALL' policy (which could have both a USING clause and anindependent WITH CHECK clause).This could result in policies acting differently when built using ALL(when the ALL had both USING and WITH CHECK clauses) and when buildingthe policies independently as SELECT and UPDATE policies.Fix this by adding an explicit boolean to add_with_check_options() toindicate when the USING policy should be used, even if the policy hasboth USING and WITH CHECK policies on it.Reported by: Rod TaylorBack-patch to 9.5 where RLS was introduced.
1 parenta24a1a2 commit92b1522

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

‎src/backend/rewrite/rowsecurity.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ static void add_with_check_options(Relation rel,
7878
List*permissive_policies,
7979
List*restrictive_policies,
8080
List**withCheckOptions,
81-
bool*hasSubLinks);
81+
bool*hasSubLinks,
82+
boolforce_using);
8283

8384
staticboolcheck_role_for_policy(ArrayType*policy_roles,Oiduser_id);
8485

@@ -271,7 +272,8 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
271272
permissive_policies,
272273
restrictive_policies,
273274
withCheckOptions,
274-
hasSubLinks);
275+
hasSubLinks,
276+
false);
275277

276278
/*
277279
* Get and add ALL/SELECT policies, if SELECT rights are required for
@@ -294,7 +296,8 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
294296
select_permissive_policies,
295297
select_restrictive_policies,
296298
withCheckOptions,
297-
hasSubLinks);
299+
hasSubLinks,
300+
true);
298301
}
299302

300303
/*
@@ -323,7 +326,8 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
323326
conflict_permissive_policies,
324327
conflict_restrictive_policies,
325328
withCheckOptions,
326-
hasSubLinks);
329+
hasSubLinks,
330+
true);
327331

328332
/*
329333
* Get and add ALL/SELECT policies, as WCO_RLS_CONFLICT_CHECK WCOs
@@ -345,7 +349,8 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
345349
conflict_select_permissive_policies,
346350
conflict_select_restrictive_policies,
347351
withCheckOptions,
348-
hasSubLinks);
352+
hasSubLinks,
353+
true);
349354
}
350355

351356
/* Enforce the WITH CHECK clauses of the UPDATE policies */
@@ -354,7 +359,8 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
354359
conflict_permissive_policies,
355360
conflict_restrictive_policies,
356361
withCheckOptions,
357-
hasSubLinks);
362+
hasSubLinks,
363+
false);
358364
}
359365
}
360366

@@ -645,13 +651,14 @@ add_with_check_options(Relation rel,
645651
List*permissive_policies,
646652
List*restrictive_policies,
647653
List**withCheckOptions,
648-
bool*hasSubLinks)
654+
bool*hasSubLinks,
655+
boolforce_using)
649656
{
650657
ListCell*item;
651658
List*permissive_quals=NIL;
652659

653660
#defineQUAL_FOR_WCO(policy) \
654-
(kind != WCO_RLS_CONFLICT_CHECK && \
661+
(!force_using && \
655662
(policy)->with_check_qual != NULL ? \
656663
(policy)->with_check_qual : (policy)->qual )
657664

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp