DatabaseProcApplicationCreatedLinks
sybsystemprocssp_lmconfig  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** Messages for "sp_lmconfig"
4     **
5     ** 17260, "Can't run %1! from within a transaction."
6     */
7     create or replace procedure sp_lmconfig
8         @configname varchar(255) = NULL, /* license config option name */
9         @configvalue varchar(255) = "1" /* license config value */
10    as
11        declare @config_id int /* config id for dbcc lmconfig */
12        declare @configvaluelen int /* length of license config value */
13        declare @nullarg char(1)
14        declare @dummy int
15        declare @status int
16        declare @gp_enabled int
17    
18        /*
19        ** dbcc lmconfig is not allowed in a transaction.
20        */
21        if @@trancount > 0
22        begin
23            /*
24            ** 17260, "Can't run %1! from within a transaction."
25            */
26            raiserror 17260, "sp_lmconfig"
27            return (1)
28        end
29    
30        set chained off
31    
32        set transaction isolation level 1
33    
34        /* 
35        ** If granular permissions is not enabled then sa_role is required.
36        ** If granular permissions is enabled then the permission 
37        ** 'manage server configuration' is required.  proc_role and proc_auditperm 
38        ** will also do auditing if required. Both will also print error message if 
39        ** required.
40        */
41    
42        select @nullarg = NULL
43        execute @status = sp_aux_checkroleperm "sa_role", "manage server configuration",
44            @nullarg, @gp_enabled output
45    
46        /* For Auditing */
47        if (@gp_enabled = 0)
48        begin
49            if (proc_role("sa_role") = 0)
50                return (1)
51        end
52        else
53        begin
54            select @dummy = proc_auditperm("manage server configuration", @status)
55        end
56    
57        if (@status != 0)
58            return (1)
59    
60        if (@configname is NULL)
61        begin
62            /* Display all license configuration and license status */
63            dbcc lmconfig
64        end
65        else
66        begin
67            /* Map config name to config id for dbcc lmconfig. */
68            select @config_id = case @configname
69                    when "edition" then 1
70                    when "license type" then 2
71                    when "smtp host" then 3
72                    when "email recipients" then 4
73                    when "email severity" then 5
74                    when "smtp port" then 6
75                    when "email sender" then 7
76                    else 0
77                end
78    
79            if (@config_id = 0)
80            begin
81                print "Error: No matching configuration options."
82                return (1)
83            end
84            else if (@configvalue = "1")
85            begin
86                /* (@config_id != 0) and (@configvalue is not specified) */
87                /* Display the license configuration */
88                dbcc lmconfig(@config_id)
89            end
90            else
91            begin
92                /* (@config_id != 0) and (@configvalue is specified) */
93                /* Set the license configuration */
94                if (@configvalue is null)
95                begin
96                    select @configvalue = "null"
97                end
98                select @configvaluelen = datalength(@configvalue)
99                dbcc lmconfig(@config_id, @configvalue, @configvaluelen)
100           end
101       end
102   
103       return (0)
104   


exec sp_procxmode 'sp_lmconfig', 'AnyMode'
go

Grant Execute on sp_lmconfig to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_lmconfig  
 MUCO 3 Useless Code Useless Brackets 27
 MUCO 3 Useless Code Useless Brackets 47
 MUCO 3 Useless Code Useless Brackets 49
 MUCO 3 Useless Code Useless Brackets 50
 MUCO 3 Useless Code Useless Brackets 57
 MUCO 3 Useless Code Useless Brackets 58
 MUCO 3 Useless Code Useless Brackets 60
 MUCO 3 Useless Code Useless Brackets 79
 MUCO 3 Useless Code Useless Brackets 82
 MUCO 3 Useless Code Useless Brackets 84
 MUCO 3 Useless Code Useless Brackets 94
 MUCO 3 Useless Code Useless Brackets 103
 QISO 3 Set isolation level 32
 VNRD 3 Variable is not read @dummy 54
 MTR1 2 Metrics: Comments Ratio Comments: 36% 7
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 7 = 9dec - 4exi + 2 7
 MTR3 2 Metrics: Query Complexity Complexity: 41 7

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