Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

Free Oracle Tips

HTML Text

 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB   


 

 

 


 

 

 
 

Granting ALTER SYSTEM KILL SESSION to users

Oracle Tips by Burleson Consulting
December 16,  2008

Question:

Is it possible to use this command [alter system kill session] without having DBA privileges?  What is the privilege that needs to be granted to the ordinary users in order to execute the ALTER SYSTEM KILL SESSION statement?

Answer:

It is possible to grant "ALTER SYSTEM"

Please exercise extreme caution when granting the privilege to users, especially on a production machine, as it could cause a lot of problems.  I would not grant such a privilege to any user on a production machine.

To do this, simply create a packaged procedure which kills sessions, and grant execute privileges on that.

Again, I would not grant alter system to just any user. This method is the way to go, but make sure the procedure restricts which sessions can be killed

Russ Cannon adds:

There must be a check to prevent users from killing privileged DBA sessions:

create or replace procedure kill_session
(pn_sid number
,pn_serial number)
as
lv_user varchar2(30);
begin
select username into lv_user from v$session where sid = pn_sid and serial# = pn_serial;
if lv_user is not null and lv_user not in ('SYS','SYSTEM') then
execute immediate 'alter system kill session '''||pn_sid||','||pn_serial||'''';
else
raise_application_error(-20000,'Attempt to kill protected system session has been blocked.');
end if;
end;
/
 

Note: The check for LV_USER IS NOT NULL is not strictly necessary because KILL SESSION will not kill non-user sessions, but I include it so as to raise my own error for those as well.

 You should add any DBA accounts that you have to the list of privileged users ('SYS','SYSTEM','MYDBA',etc.).

 For this code to work, you will have to create a direct select grant on sys.v_$session to the owner of this procedure as follows:

 grant select on v_$session to <owner>

Where <owner> is the schema that owns the above procedure. This has to be a direct grant and not through a role.

This does what you want and prevents users from clobbering DBA sessions. It also obviates the need for granting the dangerous 'alter system' privilege to non-DBAs.

 

Laurent Schneider adds:

“On the one hand, "ALTER SYSTEM" privilege is MUCH SAFER than granting "DBA".  The privileged user could not read/drop tables/tablespaces/database. So, if you are granting this to a "Junior DBA", it is, in my opinion, acceptable.

On the other hand, if you grant this to an applicative user, it means the security design of your database is bad. I would, in this case, oppose myself to such permissive access to the database.  If it is needed to kill other sessions, find out why other sessions must be killed!  If the sessions are just "hanging" when middleware died, then watch out for "SQLNET.EXPIRE_TIME" in sqlnet.ora.  

If you want to prevent user from accessing the databases, maybe there is a way to "lock" the tables, or to make your transaction read-only. 

Also teach the users to make appropriate selections (like always selecting where txn_date < trunc(sysdate) in some reporting dbs).”

 

Related Links: 

http://www.dba-oracle.com/t_ault_25_dbms_sql_alter.htm
http://www.dba-oracle.com/tips_oracle_orakill.htm



 

 

  
 

 
 
 
 
Oracle performance tuning software
 
 

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright ? 1996 -  2011 by Burleson Enterprises

All rights reserved.

Oracle ? is the registered trademark of Oracle Corporation.