DatabaseProcApplicationCreatedLinks
sybsystemprocssp_monitor_check_permission  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** This stored procedure checks if the user has sa_role or mon_role
4     ** It also calls proc_role() which generates appropriate audit records
5     **
6     ** Parameters:
7     **      @procname       - Name of the caller
8     **
9     ** Returns:
10    **      0 in case of success
11    **      1 in case of failure
12    */
13    create or replace procedure sp_monitor_check_permission @procname varchar(30)
14    as
15        declare @retstat int
16        declare @dummy int
17        declare @nullarg char(1)
18        declare @gp_enabled int
19        declare @status1 int
20        declare @status2 int
21    
22        select @status1 = 1
23        select @status2 = 1
24    
25    
26        /*
27        **  If granular permissions is not enabled, 
28        **  Accounts with sa_role or mon_role role can execute it.
29        **  If granular permissions is enabled then users with 
30        ** 'manage server configuration' permission can execute it.
31        */
32        select @nullarg = NULL
33        execute @status1 = sp_aux_checkroleperm "sa_role", "manage server configuration",
34            @nullarg, @gp_enabled output
35    
36        if (@gp_enabled = 0)
37        begin
38            if (@status1 != 0)
39            begin
40                execute @status2 = sp_aux_checkroleperm "mon_role",
41                    @nullarg, @nullarg, @gp_enabled output
42    
43                if (@status2 != 0)
44                begin
45                    /* 
46                    ** proc_role() will raise permission errors
47                    ** and send audit records to the audit trail.
48                    */
49                    select @dummy = proc_role("sa_role")
50                    select @dummy = proc_role("mon_role")
51                    return (1)
52                end
53            end
54            if (@status1 = 0)
55                select @dummy = proc_role("sa_role")
56    
57            if (@status2 = 0)
58                select @dummy = proc_role("mon_role")
59        end
60        else
61        begin
62            select @dummy = proc_auditperm("manage server configuration",
63                    @status1)
64            if (@status1 != 0)
65                return 1
66        end
67        return (0)
68    

DEFECTS
 MUCO 3 Useless Code Useless Brackets 36
 MUCO 3 Useless Code Useless Brackets 38
 MUCO 3 Useless Code Useless Brackets 43
 MUCO 3 Useless Code Useless Brackets 51
 MUCO 3 Useless Code Useless Brackets 54
 MUCO 3 Useless Code Useless Brackets 57
 MUCO 3 Useless Code Useless Brackets 64
 MUCO 3 Useless Code Useless Brackets 67
 VNRD 3 Variable is not read @gp_enabled 41
 VNRD 3 Variable is not read @dummy 62
 VUNU 3 Variable is not used @retstat 15
 MTR1 2 Metrics: Comments Ratio Comments: 33% 13
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 6 = 7dec - 3exi + 2 13
 MTR3 2 Metrics: Query Complexity Complexity: 32 13

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_aux_checkroleperm  
   reads table master..syscurconfigs (1)  
   reads table master..sysconfigures (1)