2021-12-30 19:43:52 +01:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
"""
|
|
|
|
ID: issue-6998
|
|
|
|
ISSUE: 6998
|
|
|
|
TITLE: Problems with access to RDB$CONFIG table for non-privileged user when he has
|
|
|
|
grant on execution of SP which has necessary access rights (created by SYSDBA with SQL DEFINER clause)
|
|
|
|
DESCRIPTION:
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.gh_6998
|
2022-01-27 20:08:36 +01:00
|
|
|
"""
|
2021-12-30 19:43:52 +01:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-12-30 19:43:52 +01:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
db = db_factory()
|
2021-12-30 19:43:52 +01:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
test_script = """
|
2021-12-30 19:43:52 +01:00
|
|
|
set bail on;
|
|
|
|
set list on;
|
|
|
|
create or alter user tmp$gh_6998 password '123' revoke admin role;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
set term ^;
|
|
|
|
create or alter procedure sp_check_rdb$config_avaliable
|
|
|
|
returns (cnt int)
|
|
|
|
sql security definer
|
|
|
|
as
|
|
|
|
begin
|
|
|
|
select count(*) from rdb$config into cnt;
|
|
|
|
suspend;
|
|
|
|
end
|
|
|
|
^
|
|
|
|
set term ;^
|
|
|
|
commit;
|
|
|
|
|
|
|
|
grant execute on procedure sp_check_rdb$config_avaliable to user tmp$gh_6998;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
connect '$(DSN)' user tmp$gh_6998 password '123';
|
|
|
|
commit;
|
2022-01-27 20:08:36 +01:00
|
|
|
|
2021-12-30 19:43:52 +01:00
|
|
|
select current_user as who_am_i, sign(p.cnt) as is_rdb$config_avaliable
|
|
|
|
from sp_check_rdb$config_avaliable p;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
connect '$(DSN)' user sysdba password 'masterkey';
|
|
|
|
drop user tmp$gh_6998;
|
|
|
|
commit;
|
|
|
|
"""
|
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
act = isql_act('db', test_script, substitutions=[('[ \t]+', ' ')])
|
2021-12-30 19:43:52 +01:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
expected_stdout = """
|
2021-12-30 19:43:52 +01:00
|
|
|
WHO_AM_I TMP$GH_6998
|
|
|
|
IS_RDB$CONFIG_AVALIABLE 1
|
|
|
|
"""
|
|
|
|
|
|
|
|
@pytest.mark.version('>=4.0.1')
|
2022-01-27 20:08:36 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|