Skip to content

Commit

Permalink
Grant USAGE on debug schema
Browse files Browse the repository at this point in the history
Make it possible for regular users to execute functions in the schema
`_timescaledb_debug`.

As a consequence, the `extension_state()` function in this schema can
now be executed by "public". This is the only function in this schema
and there is no security risk in making it accessible.
  • Loading branch information
erimatnor committed Sep 19, 2024
1 parent 5cd23f9 commit fc5d07d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
3 changes: 2 additions & 1 deletion sql/pre_install/schemas.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ GRANT USAGE ON SCHEMA
_timescaledb_internal,
_timescaledb_config,
timescaledb_information,
timescaledb_experimental
timescaledb_experimental,
_timescaledb_debug
TO PUBLIC;

8 changes: 2 additions & 6 deletions test/expected/debug_utils.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.
\c :TEST_DBNAME :ROLE_SUPERUSER
SET ROLE :ROLE_DEFAULT_PERM_USER;
SELECT _timescaledb_debug.extension_state();
extension_state
-----------------
created
(1 row)

SET ROLE :ROLE_DEFAULT_PERM_USER;
\set ON_ERROR_STOP 0
SELECT _timescaledb_debug.extension_state();
ERROR: permission denied for schema _timescaledb_debug at character 8
\set ON_ERROR_STOP 1
\c :TEST_DBNAME :ROLE_SUPERUSER
RESET ROLE;
DO $$
DECLARE
module text;
Expand Down
2 changes: 1 addition & 1 deletion test/sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ set(TEST_FILES
ddl.sql
ddl_errors.sql
ddl_extra.sql
delete.sql
debug_utils.sql
delete.sql
drop_extension.sql
drop_hypertable.sql
drop_rename_hypertable.sql
Expand Down
7 changes: 2 additions & 5 deletions test/sql/debug_utils.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
-- LICENSE-APACHE for a copy of the license.

\c :TEST_DBNAME :ROLE_SUPERUSER
SELECT _timescaledb_debug.extension_state();

SET ROLE :ROLE_DEFAULT_PERM_USER;

\set ON_ERROR_STOP 0
SELECT _timescaledb_debug.extension_state();
\set ON_ERROR_STOP 1

\c :TEST_DBNAME :ROLE_SUPERUSER
RESET ROLE;

DO $$
DECLARE
module text;
Expand Down

0 comments on commit fc5d07d

Please sign in to comment.