DatabaseProcApplicationCreatedLinks
sybsystemprocssp_aux_checkroleperm  14 déc. 14Defects Propagation Dependencies

1     
2     
3     /* 
4     ** SP_AUX_CHECKROLEPERM
5     ** Checks if the user has a particular role or permission.  It does this
6     ** check depending on whether granular permissions is enabled or not.  If
7     ** it is not enabled then the role specified by @rolename will be checked
8     ** otherwise the permission specified by @role_perm_name will be checked.
9     ** If a @rolename is NULL and granular permissions is not enabled or
10    ** if granular permissions is enabled and @role_perm_name is NULL then
11    ** it assumed that there was no role/permission check required and a 
12    ** 0 is returned.
13    **
14    ** Parameters:
15    ** 	@rolename	- Name of role to check for if granular permissions 
16    **			  not enabled. If @rolename is "dbo" then we check
17    **			  to see if user_id() is 1. 
18    **
19    ** 	@role_perm_name - Name of role or permission to check if granular 
20    **			  permissions is enabled. When granular permissions is 
21    **			  enabled some stored procedures require either a 
22    **			  permission or a role.  In the case when checking for 
23    **			  a role a rolename may be passed in instead of a 
24    **			  permission name.
25    **
26    **	@dbname		- If not null then pass to has_privilege as database
27    **			  name to do the permission check in.
28    ** 	@gp_enabled	- (output) 0 if granular permissions is not enabled
29    **			  otherwise set to 1.
30    ** Returns:
31    ** 	0	- User has role or permission.
32    **	1	- role checked and user doesn't have it.
33    **	2	- permission checked and user doesn't have it.
34    ** History:
35    **	August 2010	malloy	written.
36    */
37    create or replace procedure sp_aux_checkroleperm
38        @rolename varchar(32) = NULL,
39        @role_perm_name varchar(32) = NULL,
40        @dbname varchar(255) = NULL,
41        @gp_enabled int = 0 output
42    as
43        begin -- { Beginning of sp_aux_checkroleperm
44            declare @config int
45            declare @haspriv int
46            declare @dummy int
47    
48            /* Initialize */
49            select @config = 526 /* config number for enable granular permissions. */
50            select @haspriv = 0
51    
52            /* Get config value for 'enable granular permissions' */
53            select @gp_enabled = a.value from master.dbo.syscurconfigs a,
54                master.dbo.sysconfigures b where
55                a.config = b.config and b.name
56                like 'enable granular permissions'
57    
58            if (@gp_enabled = 0 and @rolename is not NULL)
59            begin
60                /* If @rolename is "dbo" then we just check if user is dbo. */
61                if (@rolename = "dbo" or @rolename = "DBO")
62                begin
63                    if (user_id() = 1)
64                        return 0
65                    else
66                        return 1
67                end
68    
69                select @dummy = has_role(@rolename, 1)
70                if (@dummy = 0)
71                begin
72                    return 1
73                end
74            end
75            else if (@gp_enabled = 1 and @role_perm_name is not NULL)
76            begin
77                /* Are we really dealing with a role? */
78                if (@role_perm_name like "%_role")
79                begin
80                    select @dummy = has_role(@role_perm_name, 1)
81                    if (@dummy = 0)
82                    begin
83                        return 1
84                    end
85                    else
86                    begin
87                        return 0
88                    end
89                end
90                if (@dbname is null)
91                begin
92                    select @haspriv = has_privilege(@role_perm_name)
93                end
94                else
95                begin
96                    select @haspriv = has_privilege(@role_perm_name, @dbname)
97                end
98                if (@haspriv != 1)
99                begin
100                   /* Return 2 to specify user doesn't have privilege. */
101                   return 2
102               end
103           end
104           return 0
105       end -- } End of sp_aux_checkroleperm
106   


exec sp_procxmode 'sp_aux_checkroleperm', 'AnyMode'
go

Grant Execute on sp_aux_checkroleperm to public
go
DEFECTS
 MINU 4 Unique Index with nullable columns master..sysconfigures master..sysconfigures
 TNOI 4 Table with no index master..syscurconfigs master..syscurconfigs
 MGTP 3 Grant to public master..sysconfigures  
 MGTP 3 Grant to public master..syscurconfigs  
 MGTP 3 Grant to public sybsystemprocs..sp_aux_checkroleperm  
 MUCO 3 Useless Code Useless Begin-End Pair 43
 MUCO 3 Useless Code Useless Brackets 58
 MUCO 3 Useless Code Useless Brackets 61
 MUCO 3 Useless Code Useless Brackets 63
 MUCO 3 Useless Code Useless Brackets 70
 MUCO 3 Useless Code Useless Brackets 75
 MUCO 3 Useless Code Useless Brackets 78
 MUCO 3 Useless Code Useless Brackets 81
 MUCO 3 Useless Code Useless Brackets 90
 MUCO 3 Useless Code Useless Brackets 98
 QAFM 3 Var Assignment from potentially many rows 53
 QNAJ 3 Not using ANSI Inner Join 53
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysconfigures.csysconfigures unique clustered
(name, parent, config)
Intersection: {name}
55
 VNRD 3 Variable is not read @config 49
 MTR1 2 Metrics: Comments Ratio Comments: 58% 37
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 9 = 14dec - 7exi + 2 37
 MTR3 2 Metrics: Query Complexity Complexity: 43 37
 PRED_QUERY_COLLECTION 2 {c=master..sysconfigures, c2=master..syscurconfigs} 0 53

DEPENDENCIES
PROCS AND TABLES USED
reads table master..syscurconfigs (1)  
reads table master..sysconfigures (1)  

CALLERS
called by proc sybsystemprocs..sp_hadr_update  
called by proc sybsystemprocs..sp_placeobject  
called by proc sybsystemprocs..sp_object_stats  
called by proc sybsystemprocs..sp_optimal_text_space  
   called by proc sybsystemprocs..sp_chgattribute  
called by proc sybsystemprocs..sp_spaceusage_object_populate  
   called by proc sybsystemprocs..sp_spaceusage_object  
      called by proc sybsystemprocs..sp_spaceusage  
called by proc sybsystemprocs..sp_dboption_flmode  
   called by proc sybsystemprocs..sp_dboption  
called by proc sybsystemprocs..sp_shmdumpconfig_config  
   called by proc sybsystemprocs..sp_shmdumpconfig  
called by proc sybsystemprocs..sp_cmp_all_qplans  
called by proc sybsystemprocs..sp_downgrade  
called by proc sybsystemprocs..sp_logininfo  
called by proc sybsystemprocs..sp_configure  
   called by proc sybsystemprocs..sp_setlockpromote  
      called by proc sybsystemprocs..sp_setpglockpromote  
      called by proc sybsystemprocs..sp_setrowlockpromote  
   called by proc sybsystemprocs..sp_configure  
   called by proc sybsystemprocs..sp_downgrade_esd  
called by proc sybsystemprocs..sp_forceonline_page  
   called by proc sybsystemprocs..sp_forceonline_db  
called by proc sybsystemprocs..sp_cachestrategy  
called by proc sybsystemprocs..sp_querysmobj  
called by proc sybsystemprocs..sp_tables  
called by proc sybsystemprocs..sp_drop_qpgroup  
called by proc sybsystemprocs..sp_ldapadmin  
called by proc sybsystemprocs..sp_version  
called by proc sybsystemprocs..sp_droplanguage  
called by proc sybsystemprocs..sp_forceonline_db  
called by proc sybsystemprocs..sp_dropmessage  
called by proc sybsystemprocs..sp_forceonline_object  
called by proc sybsystemprocs..sp_addgroup  
called by proc sybsystemprocs..sp_flushstats  
called by proc sybsystemprocs..sp_locklogin  
   called by proc sybsystemprocs..sp_addlogin  
called by proc sybsystemprocs..sp_setrepdbmode  
called by proc sybsystemprocs..sp_downgrade_esd  
called by proc sybsystemprocs..sp_dropserver  
   called by proc sybsystemprocs..sp_hadr_admin  
      called by proc sybsystemprocs..sp_hadr_update  
called by proc sybsystemprocs..sp_fixindex  
called by proc sybsystemprocs..sp_cacheconfig  
   called by proc sybsystemprocs..sp_do_poolconfig  
      called by proc sybsystemprocs..sp_poolconfig  
called by proc sybsystemprocs..sp_defaultlanguage  
   called by proc sybsystemprocs..sp_modifylogin  
called by proc sybsystemprocs..sp_dump_history  
called by proc sybsystemprocs..sp_countmetadata  
called by proc sybsystemprocs..sp_serveroption  
called by proc sybsystemprocs..sp_reptostandby  
called by proc sybsystemprocs..sp_logintrigger  
   called by proc sybsystemprocs..sp_modifylogin  
called by proc sybsystemprocs..sp_drop_resource_limit  
called by proc sybsystemprocs..sp_dbrecovery_order  
called by proc sybsystemprocs..sp_drop_query_tuning  
   called by proc sybsystemprocs..sp_query_tuning  
called by proc sybsystemprocs..sp_displaylogin  
called by proc sybsystemprocs..sp_setlockpromote_ptn  
   called by proc sybsystemprocs..sp_setpglockpromote_ptn  
   called by proc sybsystemprocs..sp_setrowlockpromote_ptn  
called by proc sybsystemprocs..sp_maplogin  
called by proc sybsystemprocs..sp_changedbowner  
called by proc sybsystemprocs..sp_logdevice  
called by proc sybsystemprocs..sp_showtext  
   called by proc sybsystemprocs..sp_helptext_usage  
      called by proc sybsystemprocs..sp_helptext  
   called by proc sybsystemprocs..sp_helptext  
called by proc sybsystemprocs..sp_defaultdb  
   called by proc sybsystemprocs..sp_modifylogin  
called by proc sybsystemprocs..sp_stored_procedures  
called by proc sybsystemprocs..sp_modifythreshold  
called by proc sybsystemprocs..sp_dropengine  
called by proc sybsystemprocs..sp_add_resource_limit  
called by proc sybsystemprocs..sp_addthreshold  
called by proc sybsystemprocs..sp_addengine  
called by proc sybsystemprocs..sp_adduser  
called by proc sybsystemprocs..sp_setup_table_transfer  
called by proc sybsystemprocs..sp_addsegment  
called by proc sybsystemprocs..sp_rebuild_text  
called by proc sybsystemprocs..sp_helptext  
called by proc sybsystemprocs..sp_setlangalias  
called by proc sybsystemprocs..sp_addobjectdef  
   called by proc sybsystemprocs..sp_addtabledef  
called by proc sybsystemprocs..sp_helpmaplogin  
called by proc sybsystemprocs..sp_droplockpromote_ptn  
   called by proc sybsystemprocs..sp_dropglockpromote_ptn  
   called by proc sybsystemprocs..sp_droprowlockpromote_ptn  
called by proc sybsystemprocs..sp_dropalias  
called by proc sybsystemprocs..sp_merge_dup_inline_default  
called by proc sybsystemprocs..sp_addexeclass  
called by proc sybsystemprocs..sp_unbindcache  
called by proc sybsystemprocs..sp_setsuspect_threshold  
called by proc sybsystemprocs..sp_dumpoptimize  
called by proc sybsystemprocs..sp_showplan  
   called by proc sybsystemprocs..sp_monitor_procstack  
called by proc sybsystemprocs..sp_drop_qplan  
called by proc sybsystemprocs..sp_encryption  
   called by proc sybsystemprocs..sp_downgrade  
called by proc sybsystemprocs..sp_extengine  
called by proc sybsystemprocs..sp_reportstats  
   called by proc sybsystemprocs..sp_clearstats  
called by proc sybsystemprocs..sp_import_qpgroup  
called by proc sybsystemprocs..sp_help_qplan  
   called by proc sybsystemprocs..sp_cmp_all_qplans  
called by proc sybsystemprocs..sp_memlog  
called by proc sybsystemprocs..sp_addexternlogin  
called by proc sybsystemprocs..sp_copy_qplan  
   called by proc sybsystemprocs..sp_copy_all_qplans  
called by proc sybsystemprocs..sp_setreplicate  
called by proc sybsystemprocs..sp_addalias  
called by proc sybsystemprocs..sp_remoteoption  
called by proc sybsystemprocs..sp_unbindexeclass  
called by proc sybsystemprocs..sp_create_syscoordinations  
called by proc sybsystemprocs..sp_add_qpgroup  
   called by proc sybsystemprocs..sp_import_qpgroup  
called by proc sybsystemprocs..sp_setsuspect_granularity  
called by proc sybsystemprocs..sp_loginconfig  
called by proc sybsystemprocs..sp_plan_dbccdb  
called by proc sybsystemprocs..sp_droplockpromote  
   called by proc sybsystemprocs..sp_dropglockpromote  
   called by proc sybsystemprocs..sp_droprowlockpromote  
called by proc sybsystemprocs..sp_setrepdefmode  
called by proc sybsystemprocs..sp_start_rep_agent  
called by proc sybsystemprocs..sp_flushmetrics  
   called by proc sybsystemprocs..sp_metrics  
called by proc sybsystemprocs..sp_freedll  
called by proc sybsystemprocs..sp_update_authmech_value  
called by proc sybsystemprocs..sp_setpsexe  
called by proc sybsystemprocs..sp_modify_resource_limit  
called by proc sybsystemprocs..sp_dropthreshold  
called by proc sybsystemprocs..sp_hadr_admin  
called by proc sybsystemprocs..sp_help_rep_agent  
called by proc sybsystemprocs..sp_unbindcache_all  
called by proc sybsystemprocs..sp_dbremap  
called by proc sybsystemprocs..sp_securityprofile  
called by proc sybsystemprocs..sp_drop_all_qplans  
called by proc sybsystemprocs..sp_logiosize  
called by proc sybsystemprocs..sp_changegroup  
called by proc sybsystemprocs..sp_optgoal  
called by proc sybsystemprocs..sp_help_resource_limit  
called by proc sybsystemprocs..sp_modifylogin  
called by proc sybsystemprocs..sp_drop_metrics  
   called by proc sybsystemprocs..sp_metrics  
called by proc sybsystemprocs..sp_dropexeclass  
called by proc sybsystemprocs..sp_bindcache  
   called by proc sybsystemprocs..sp_unbindcache  
called by proc sybsystemprocs..sp_diskdefault  
called by proc sybsystemprocs..sp_ssladmin  
called by proc sybsystemprocs..sp_setrepcol  
called by proc sybsystemprocs..sp_export_qpgroup  
called by proc sybsystemprocs..sp_revokelogin  
called by proc sybsystemprocs..sp_deletesmobj  
called by proc sybsystemprocs..sp_drop_time_range  
called by proc sybsystemprocs..sp_addserver  
called by proc sybsystemprocs..sp_displaylevel  
called by proc sybsystemprocs..sp_dropuser  
called by proc sybsystemprocs..sp_config_rep_agent  
called by proc sybsystemprocs..sp_engine  
called by proc sybsystemprocs..sp_tempdb  
called by proc sybsystemprocs..sp_repdbsync  
called by proc sybsystemprocs..sp_helpapptrace  
called by proc sybsystemprocs..sp_addlogin  
called by proc sybsystemprocs..sp_dropexternlogin  
called by proc sybsystemprocs..sp_dropsegment  
called by proc sybsystemprocs..sp_droptype  
called by proc sybsystemprocs..sp_add_time_range  
called by proc sybsystemprocs..sp_show_query_tuning  
   called by proc sybsystemprocs..sp_query_tuning  
called by proc sybsystemprocs..sp_dropextendedproc  
called by proc sybsystemprocs..sp_extendsegment  
called by proc sybsystemprocs..sp_restore_system_role  
called by proc sybsystemprocs..sp_find_qplan  
called by proc sybsystemprocs..sp_cmp_qplans  
   called by proc sybsystemprocs..sp_copy_qplan  
called by proc sybsystemprocs..sp_displayroles  
called by proc sybsystemprocs..sp_ddlgen_permissions  
called by proc sybsystemprocs..sp_shmdumpdrop  
   called by proc sybsystemprocs..sp_shmdumpconfig  
called by proc sybsystemprocs..sp_modifystats  
called by proc sybsystemprocs..sp_setreptable  
called by proc sybsystemprocs..sp_flush_query_tuning  
   called by proc sybsystemprocs..sp_query_tuning  
called by proc sybsystemprocs..sp_filter_metrics  
   called by proc sybsystemprocs..sp_metrics  
called by proc sybsystemprocs..sp_addlanguage  
called by proc sybsystemprocs..sp_addmessage  
called by proc sybsystemprocs..sp_addremotelogin  
called by proc sybsystemprocs..sp_do_poolconfig  
called by proc sybsystemprocs..sp_dropremotelogin  
called by proc sybsystemprocs..sp_set_qplan  
called by proc sybsystemprocs..sp_autoconnect  
called by proc sybsystemprocs..sp_dropobjectdef  
   called by proc sybsystemprocs..sp_droptabledef  
called by proc sybsystemprocs..sp_errorlog  
called by proc sybsystemprocs..sp_dropgroup  
called by proc sybsystemprocs..sp_stop_rep_agent  
called by proc sybsystemprocs..sp_listener  
called by proc sybsystemprocs..sp_help_qpgroup  
called by proc sybsystemprocs..sp_monitor_check_permission  
called by proc sybsystemprocs..sp_passwordpolicy  
   called by proc sybsystemprocs..sp_downgrade  
called by proc sybsystemprocs..sp_password  
   called by proc sybsystemprocs..sp_addlogin  
called by proc sybsystemprocs..sp_renamedb  
called by proc sybsystemprocs..sp_lmconfig  
called by proc sybsystemprocs..sp_dropdevice  
called by proc sybsystemprocs..sp_dtx_purge_completedxacts  
called by proc sybsystemprocs..sp_backup_metrics  
   called by proc sybsystemprocs..sp_metrics  
called by proc sybsystemprocs..sp_deviceattr  
called by proc sybsystemprocs..sp_shmdumpconfig  
called by proc sybsystemprocs..sp_fix_dtm_ha_roles  
called by proc sybsystemprocs..sp_makesuspect_obj  
called by proc sybsystemprocs..sp_setlockpromote  
called by proc sybsystemprocs..sp_grantlogin  
called by proc sybsystemprocs..sp_altermessage  
called by proc sybsystemprocs..sp_bindexeclass  
called by proc sybsystemprocs..sp_post_xpload  
called by proc sybsystemprocs..sp_copy_all_qplans  
called by proc sybsystemprocs..sp_monitorconfig  
   called by proc sybsystemprocs..sp_sysmon_mdcache  
      called by proc sybsystemprocs..sp_sysmon_analyze  
         called by proc sybsystemprocs..sp_sysmon  
called by proc sybsystemprocs..sp_addextendedproc  
called by proc sybsystemprocs..sp_clearpsexe  
called by proc sybsystemprocs..sp_replication_path  
called by proc sybsystemprocs..sp_addumpdevice  
called by proc sybsystemprocs..sp_modify_time_range  
called by proc sybsystemprocs..sp_config_dump  
   called by proc sybsystemprocs..sp_downgrade_dump_config  
called by proc sybsystemprocs..sp_rename_qpgroup  
called by proc sybsystemprocs..sp_clearstats  
called by proc sybsystemprocs..sp_setrepproc  
called by proc sybsystemprocs..sp_dboption