Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8d8afd4

Browse files
Allow pg_monitor to execute pg_current_logfile().
We allow roles with privileges of pg_monitor to execute functions like pg_ls_logdir(), so it seems natural that such roles would also be able to execute this function. Bumps catversion. Co-authored-by: Pavlo Golub Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/CAK7ymcLmEYWyQkiCZ64WC-HCzXAB0omM%3DYpj9B3rXe8vUAFMqw%40mail.gmail.com
1 parent 3e8235b commit 8d8afd4

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

doc/src/sgml/func.sgml

+5
Original file line numberDiff line numberDiff line change
@@ -23735,6 +23735,11 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
2373523735
<xref linkend="guc-log-destination"/>.
2373623736
The result reflects the contents of
2373723737
the <filename>current_logfiles</filename> file.
23738+
</para>
23739+
<para>
23740+
This function is restricted to superusers and roles with privileges of
23741+
the <literal>pg_monitor</literal> role by default, but other users can
23742+
be granted EXECUTE to run the function.
2373823743
</para></entry>
2373923744
</row>
2374023745

src/backend/catalog/system_functions.sql

+4
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,10 @@ GRANT EXECUTE ON FUNCTION pg_ls_logicalmapdir() TO pg_monitor;
777777

778778
GRANT EXECUTE ON FUNCTION pg_ls_replslotdir(text) TO pg_monitor;
779779

780+
GRANT EXECUTE ON FUNCTION pg_current_logfile() TO pg_monitor;
781+
782+
GRANT EXECUTE ON FUNCTION pg_current_logfile(text) TO pg_monitor;
783+
780784
GRANT pg_read_all_settings TO pg_monitor;
781785

782786
GRANT pg_read_all_stats TO pg_monitor;

src/include/catalog/catversion.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/* yyyymmddN */
60-
#define CATALOG_VERSION_NO 202402141
60+
#define CATALOG_VERSION_NO 202402142
6161

6262
#endif

src/test/regress/expected/misc_functions.out

+20
Original file line numberDiff line numberDiff line change
@@ -683,3 +683,23 @@ SELECT gist_stratnum_identity(18::smallint);
683683
18
684684
(1 row)
685685

686+
-- pg_current_logfile
687+
CREATE ROLE regress_current_logfile;
688+
-- not available by default
689+
SELECT has_function_privilege('regress_current_logfile',
690+
'pg_current_logfile()', 'EXECUTE');
691+
has_function_privilege
692+
------------------------
693+
f
694+
(1 row)
695+
696+
GRANT pg_monitor TO regress_current_logfile;
697+
-- role has privileges of pg_monitor and can execute the function
698+
SELECT has_function_privilege('regress_current_logfile',
699+
'pg_current_logfile()', 'EXECUTE');
700+
has_function_privilege
701+
------------------------
702+
t
703+
(1 row)
704+
705+
DROP ROLE regress_current_logfile;

src/test/regress/sql/misc_functions.sql

+11
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,14 @@ FROM pg_walfile_name_offset('0/0'::pg_lsn + :segment_size - 1),
254254
-- test stratnum support functions
255255
SELECT gist_stratnum_identity(3::smallint);
256256
SELECT gist_stratnum_identity(18::smallint);
257+
258+
-- pg_current_logfile
259+
CREATE ROLE regress_current_logfile;
260+
-- not available by default
261+
SELECT has_function_privilege('regress_current_logfile',
262+
'pg_current_logfile()', 'EXECUTE');
263+
GRANT pg_monitor TO regress_current_logfile;
264+
-- role has privileges of pg_monitor and can execute the function
265+
SELECT has_function_privilege('regress_current_logfile',
266+
'pg_current_logfile()', 'EXECUTE');
267+
DROP ROLE regress_current_logfile;

0 commit comments

Comments
 (0)