mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-26 02:44:29 +00:00
Enhanced permissions calculation which now supports the idea of bind/unbind
and 'all'.
This commit is contained in:
parent
7f9653c783
commit
3f3804cd43
@ -225,7 +225,9 @@ DECLARE
|
|||||||
in_to ALIAS FOR $2;
|
in_to ALIAS FOR $2;
|
||||||
out_confers TEXT;
|
out_confers TEXT;
|
||||||
tmp_confers TEXT;
|
tmp_confers TEXT;
|
||||||
|
tmp_txt TEXT;
|
||||||
dbg TEXT DEFAULT '''';
|
dbg TEXT DEFAULT '''';
|
||||||
|
counter INT;
|
||||||
BEGIN
|
BEGIN
|
||||||
-- Self can always have full access
|
-- Self can always have full access
|
||||||
IF in_from = in_to THEN
|
IF in_from = in_to THEN
|
||||||
@ -251,10 +253,22 @@ BEGIN
|
|||||||
IF out_confers = tmp_confers THEN
|
IF out_confers = tmp_confers THEN
|
||||||
RETURN dbg || out_confers;
|
RETURN dbg || out_confers;
|
||||||
ELSE
|
ELSE
|
||||||
IF length( out_confers ) < length( tmp_confers ) THEN
|
IF tmp_confers ~* ''A'' AND NOT tmp_confers ~* ''BRWU'' THEN
|
||||||
|
-- Ensure that A is expanded to all privs
|
||||||
|
tmp_confers := tmp_confers || ''BRWU'';
|
||||||
|
END IF;
|
||||||
|
IF (SELECT substring(setting,1,3)::numeric >= 8.1 FROM pg_settings WHERE name = ''server_version'') THEN
|
||||||
|
-- PostgreSQL 8.1 or later. regexp_replace exists!
|
||||||
|
out_confers := regexp_replace( out_confers, ''([^'' || tmp_confers || '']*)'', '''' );
|
||||||
RETURN dbg || out_confers;
|
RETURN dbg || out_confers;
|
||||||
ELSE
|
ELSE
|
||||||
RETURN dbg || tmp_confers;
|
tmp_txt = '''';
|
||||||
|
FOR counter IN 1 .. length(tmp_confers) LOOP
|
||||||
|
IF out_confers ~* substring(tmp_confers,counter,1) THEN
|
||||||
|
tmp_txt := tmp_txt || substring(tmp_confers,counter,1);
|
||||||
|
END IF;
|
||||||
|
END LOOP;
|
||||||
|
RETURN dbg || tmp_txt;
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user