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

Commitaa5d3c0

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 parentb58c433 commitaa5d3c0

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

@@ -272,7 +273,8 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
272273
permissive_policies,
273274
restrictive_policies,
274275
withCheckOptions,
275-
hasSubLinks);
276+
hasSubLinks,
277+
false);
276278

277279
/*
278280
* Get and add ALL/SELECT policies, if SELECT rights are required for
@@ -295,7 +297,8 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
295297
select_permissive_policies,
296298
select_restrictive_policies,
297299
withCheckOptions,
298-
hasSubLinks);
300+
hasSubLinks,
301+
true);
299302
}
300303

301304
/*
@@ -324,7 +327,8 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
324327
conflict_permissive_policies,
325328
conflict_restrictive_policies,
326329
withCheckOptions,
327-
hasSubLinks);
330+
hasSubLinks,
331+
true);
328332

329333
/*
330334
* Get and add ALL/SELECT policies, as WCO_RLS_CONFLICT_CHECK WCOs
@@ -346,7 +350,8 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
346350
conflict_select_permissive_policies,
347351
conflict_select_restrictive_policies,
348352
withCheckOptions,
349-
hasSubLinks);
353+
hasSubLinks,
354+
true);
350355
}
351356

352357
/* Enforce the WITH CHECK clauses of the UPDATE policies */
@@ -355,7 +360,8 @@ get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index,
355360
conflict_permissive_policies,
356361
conflict_restrictive_policies,
357362
withCheckOptions,
358-
hasSubLinks);
363+
hasSubLinks,
364+
false);
359365
}
360366
}
361367

@@ -659,13 +665,14 @@ add_with_check_options(Relation rel,
659665
List*permissive_policies,
660666
List*restrictive_policies,
661667
List**withCheckOptions,
662-
bool*hasSubLinks)
668+
bool*hasSubLinks,
669+
boolforce_using)
663670
{
664671
ListCell*item;
665672
List*permissive_quals=NIL;
666673

667674
#defineQUAL_FOR_WCO(policy) \
668-
(kind != WCO_RLS_CONFLICT_CHECK && \
675+
(!force_using && \
669676
(policy)->with_check_qual != NULL ? \
670677
(policy)->with_check_qual : (policy)->qual )
671678

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp