DatabaseProcApplicationCreatedLinks
sybsystemprocssp_clearpsexe  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** Generated by spgenmsgs.pl on Thu Mar 29 17:13:37 2012 
4     */
5     /* Sccsid = "%Z% generic/sproc/%M% %I% %G% */
6     /*
7     ** raiserror Messages for clearpsexe [Total 8]
8     **
9     ** 17038, "The permission '%1!' is required in order to modify attributes of another process."
10    ** 17039, "The permission '%1!' is required in order to change the priority."
11    ** 17260, "Can't run %1! from within a transaction."
12    ** 18262, "A non-SA user can not modify attributes of another process."
13    ** 18263, "A non-SA user can only modify its priority value."
14    ** 18265, "No specification for the specified process exists."
15    ** 18266, "%1! is not a valid execution attribute."
16    ** 18267, "Failed to clear value of attribute '%1!' for spid '%2!'. Check server errorlog for any additional information."
17    */
18    /*
19    ** sp_getmessage Messages for clearpsexe [Total 0]
20    */
21    /*
22    ** End spgenmsgs.pl output.
23    */
24    
25    create or replace procedure sp_clearpsexe
26        @spid int, /* name of class */
27        @exeattr varchar(12) /* name of execution attribute */
28    as
29    
30        declare @attrib_id int,
31            @user_id int,
32            @action int,
33            @my_suid int,
34            @object_type varchar(2),
35            @dummy int,
36            @loc int,
37            @role int,
38            @kernel_mode varchar(15),
39            @attr_val varchar(255)
40    
41        declare @nullarg char(1)
42        declare @status int
43        declare @gp_enabled int
44    
45        /*
46        **  IF we're in a transaction, disallow this since it might make recovery
47        **  impossible.
48        */
49        IF @@trancount > 0
50        BEGIN
51            /*
52            ** 17260, "Can't run %1! from within a transaction."
53            */
54            raiserror 17260, "sp_clearpsexe"
55            return (1)
56        END
57        ELSE
58        BEGIN
59            /* Use TSQL mode of unchained transactions */
60            set chained off
61        END
62    
63        /* Dont do "Dirty Reads" */
64        set transaction isolation level 1
65    
66        select @kernel_mode = @@kernelmode
67        select @action = 3
68        select @user_id = NULL /* Id of user from Syslogins table */
69    
70        /*
71        ** If granular permissions is not enabled then sa_role is required.
72        ** If granular permissions is enabled then the permission 
73        ** 'manage any execution class' is required.  proc_role and proc_auditperm 
74        ** will also do auditing if required. Both will also print error message 
75        ** if required.
76        */
77    
78        select @nullarg = NULL
79        execute @status = sp_aux_checkroleperm "sa_role",
80            "manage any execution class", @nullarg, @gp_enabled output
81    
82    
83        /* check that user has sa role or modifying self */
84        IF (@status != 0)
85        BEGIN
86            select @my_suid = (select suid from master..sysprocesses
87                    where spid = @spid)
88            IF (@my_suid != suser_id())
89            BEGIN
90                if (@gp_enabled = 0)
91                BEGIN
92                    /*
93                    ** 18262, "A non-SA user can not modify attributes of another
94                    ** process."
95                    */
96                    raiserror 18262
97                END
98                ELSE
99                BEGIN
100                   /*
101                   ** 17038, "The permission 'manage any execution class' is 
102                   ** required in order to modify attributes of another process."
103                   */
104   
105                   raiserror 17038, 'manage any execution class'
106               END
107               return (1)
108           END
109           ELSE IF @exeattr != "priority"
110           BEGIN
111               if (@gp_enabled = 0)
112               BEGIN
113                   /*
114                   ** 18263, "A non-SA user can only modify its priority value"
115                   */
116                   raiserror 18263
117               END
118               ELSE
119               BEGIN
120                   /*
121                   ** 17039, "The permission 'manage any execution class' is 
122                   ** required in order to change the priority value of another 
123                   ** process."
124                   */
125                   raiserror 17039, 'manage any execution class'
126               END
127               return (1)
128           END
129       END
130       ELSE
131       IF (@gp_enabled = 0)
132       BEGIN
133           /* validate that this guy is really the sa */
134           IF (proc_role("sa_role") = 0)
135               return 1
136       END
137       ELSE
138       BEGIN
139           select @dummy = proc_auditperm("manage any execution class",
140                   @status)
141       END
142   
143       /* check that @exeattr value specified is valid */
144       IF ((@exeattr != 'priority')
145               and (@exeattr != 'timeslice')
146               and (((@kernel_mode = 'process') AND (@exeattr != 'enginegroup'))
147                   OR ((@kernel_mode = 'threaded') AND (@exeattr != 'threadpool'))))
148       BEGIN
149           /*
150           ** 18266, "'%1!' is not a valid execution attribute"
151           */
152           raiserror 18266, @exeattr
153           return (1)
154       END
155   
156   
157   
158       /* Check that an entry exists in the sysattributes table */
159       select @attr_val = (select char_value from master..sysattributes where
160                   (class = 6 AND
161                       attribute = 3 AND
162                       object_type = "PS" AND
163                       object_info1 = @spid AND
164                       object_cinfo = @exeattr))
165       IF (@attr_val is NULL)
166       BEGIN
167           /*
168           ** 18265, "No specification for the specified process exists."
169           */
170           raiserror 18265
171           return (1)
172       END
173   
174       /* Now hook up with Sysattributes Table */
175   
176       select @attrib_id = 3
177       select @object_type = "PS"
178       BEGIN
179           delete master..sysattributes
180           where class = 6 AND
181               attribute = 3 AND
182               object_type = "PS" AND
183               object_info1 = @spid AND
184               object_cinfo = @exeattr
185   
186           IF attrib_notify(6, @attrib_id, @object_type, NULL, @spid,
187                   NULL, NULL, @exeattr, NULL, NULL,
188                   NULL, NULL, "", @action) = 0
189           BEGIN
190               insert master..sysattributes
191               (class, attribute, object_type, object_info1, object_cinfo,
192                   char_value)
193               values (6, 3, 'PS', @spid, @exeattr, @attr_val)
194   
195               /*
196               ** 18267, "Failed to clear value of attribute '%1!' for
197               **	   spid '%2!'. Check server errorlog for any
198               **	   additional information."
199               */
200               raiserror 18267, @exeattr, @spid
201               return (1)
202           END
203       END
204       return (0)
205   


exec sp_procxmode 'sp_clearpsexe', 'AnyMode'
go

Grant Execute on sp_clearpsexe to public
go
DEFECTS
 MEST 4 Empty String will be replaced by Single Space 188
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 MTYP 4 Assignment type mismatch @kernel_mode: varchar(15) = int 66
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 87
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 160
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 161
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 180
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 181
 TNOI 4 Table with no index master..sysprocesses master..sysprocesses
 MGTP 3 Grant to public master..sysattributes  
 MGTP 3 Grant to public master..sysprocesses  
 MGTP 3 Grant to public sybsystemprocs..sp_clearpsexe  
 MNER 3 No Error Check should check @@error after delete 179
 MNER 3 No Error Check should check @@error after insert 190
 MUCO 3 Useless Code Useless Brackets 55
 MUCO 3 Useless Code Useless Brackets 84
 MUCO 3 Useless Code Useless Brackets 88
 MUCO 3 Useless Code Useless Brackets 90
 MUCO 3 Useless Code Useless Brackets 107
 MUCO 3 Useless Code Useless Brackets 111
 MUCO 3 Useless Code Useless Brackets 127
 MUCO 3 Useless Code Useless Brackets 131
 MUCO 3 Useless Code Useless Brackets 134
 MUCO 3 Useless Code Useless Brackets 144
 MUCO 3 Useless Code Useless Brackets 153
 MUCO 3 Useless Code Useless Brackets 160
 MUCO 3 Useless Code Useless Brackets 165
 MUCO 3 Useless Code Useless Brackets 171
 MUCO 3 Useless Code Useless Begin-End Pair 178
 MUCO 3 Useless Code Useless Brackets 201
 MUCO 3 Useless Code Useless Brackets 204
 MUOT 3 Updates outside transaction 190
 QISO 3 Set isolation level 64
 QIWC 3 Insert with not all columns specified missing 9 columns out of 15 191
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_info1, object_type, object_cinfo, attribute, class}
160
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_info1, object_type, object_cinfo, attribute, class}
180
 VNRD 3 Variable is not read @user_id 68
 VNRD 3 Variable is not read @dummy 139
 VUNU 3 Variable is not used @loc 36
 VUNU 3 Variable is not used @role 37
 MSUB 2 Subquery Marker 86
 MSUB 2 Subquery Marker 159
 MTR1 2 Metrics: Comments Ratio Comments: 47% 25
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 15 = 21dec - 8exi + 2 25
 MTR3 2 Metrics: Query Complexity Complexity: 77 25

DATA PROPAGATION detailed
ColumnWritten To
@exeattrsysattributes.object_cinfo   sp_optgoal_rset_002.name sp_passwordpolicy_rset_001.value sp_rjs_retrieve_rset_001.js_server
@spidsysattributes.object_info1   °.char_value   sysattributes.object_info1   °.int_value   °.char_value   sp_dropdevice_rset_001.device sp_displayroles_rset_001.Role Name sp_displayroles_rset_002.Role Name sp_displayroles_rset_003.Role Name sp_displayroles_rset_004.Role Name
sp_dropdevice_rset_001.device sp_forceonline_object_rset_001.Object °.status sp_forceonline_object_rset_002.Object °.status sp_forceonline_page_rset_001.status sp_forceonline_page_rset_002.status sp_listsuspect_object_rset_001.Object °.Access sp_listsuspect_page_rset_001.Object
°.Access sp_makesuspect_obj_rset_001.Obj °.Indid °.LogType °.PageType °.ErrType °.Delay °.TotalNum sp_makesuspect_obj_rset_002.Obj °.Indid
°.LogType °.PageType °.ErrType °.Delay °.TotalNum sp_makesuspect_obj_rset_003.Obj °.Indid °.LogType °.PageType °.ErrType
°.Delay °.TotalNum sp_memlog_rset_001.dumps_per_file sp_passwordpolicy_rset_001.message sp_passwordpolicy_rset_002.value sp_passwordpolicy_rset_003.value sp_passwordpolicy_rset_004.Policy_option sp_rjs_retrieve_rset_001.host_name sp_setsuspect_granularity_rset_001.Online mode sp_ssladmin_rset_001.certificate_path
sp_ssladmin_rset_002.Cipher Suite Name °.Preference

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