Revoke oracle public privleges

本文深入探讨了Oracle权限管理,包括执行权限的定义与使用,Oracle内置包的默认权限设置,如何撤销公共权限及其可能的影响,以及应用补丁后权限重置的解决策略。

1. Introduction of Oracle privilege
A privilege is a right to execute an SQL statement or to access another user's object. Privilege mentioned in this bug is related with package objects.

When dealing with functions and procedures, you can grant users the ability to execute these functions and procedures. The Execute privilege is explained below:

  
ExecuteAbility to compile the function/procedure.
Ability to execute the function/procedure directly.
The syntax for granting execute privileges on a function/procedure is:

           grant execute on object to user;

2. What is the default privilege of UTL_FILE, DBMS_OBFUSCATION_TOOLKIT, DBMS_LOB?
UTL_FILE, DBMS_OBFUSCATION_TOOLKIT, DBMS_LOB are Oracle installed packages. By default, they are granted to PUBLIC, which means that all users can use them.

3. How to revoke the public privilege?
Use revoke. Take package UTL_FILE for example:
a. Connect to the database as SYS. 
   SQL> connect / AS SYSDBA
b. Revoke execute privileges on the utl_file package from PUBLIC. 
   SQL> revoke execute on utl_file from public;

4. What would be the impact if we revoke the privilege?
Oracle highly recommends keeping DBMS_SQL, DBMS_JOB, DBMS_LOB granted to PUBLIC just to keep user’s database running. Otherwise lots of things break including some of the utilities like Import/Export, Datapump expdp/impdp, SQL*Loader, etc.

If you still want to revoke privileges from PUBLIC make sure that you re-grant privileges to user that require them and recompile possible invalidated objects:
a. Re-grant permissions only to users that require them. 
   Example:
   SQL> grant execute on utl_file to sadmin;
b. Run any suitable tests to ensure that the application runs properly. 
   One way of checking is to see if any objects become invalid after removing the grants:
   select owner, object_name, object_type from dba_objects
   where status <>'VALID' ;
c. Recompile the invalidated objects.

5. Applying a oracle patch may cause the privileges on these packages are reset to public.
Solution: Put all revoke statements that are non-default in a script that can be run again. You may also want to put the grants you need for individual users in this script, then everytime you  apply a patchset, or you do a mayor upgrade, you can run this custom script again to make sure all grants are as you see fit.


6. Reference in oracle support:
 Note:247093.1 Be Cautious When Revoking Privileges Granted to PUBLIC

 Note:390225.1 Execute Privileges Are Reset For Public After Applying Patchset


转载本站文章请注明作者和出处:http://blog.youkuaiyun.com/crazy_samba ,请勿用于任何商业用途

### 在 DB2 中执行 REVOKE PUBLIC 操作的影响 在 DB2 数据库中,`PUBLIC` 是一个特殊的角色,表示所有用户。通过执行 `REVOKE` 操作从 `PUBLIC` 移除权限,可以限制数据库对象的访问范围。以下是具体影响及后果的详细说明: 1. **权限的广泛移除** 当执行 `db2 revoke IMPLICIT_SCHEMA on database from public` 或 `db2 revoke CREATETAB on database from public` 时,`PUBLIC` 的默认权限被移除[^1]。这意味着所有未明确分配权限的用户将无法创建表或隐式模式(schema)。这种操作显著提高了数据库的安全性,但也可能导致某些用户的正常操作受到影响。 2. **对普通用户的访问限制** 默认情况下,`PUBLIC` 拥有一些基本权限,例如查询系统目录视图、创建临时表等。如果这些权限被撤销,普通用户可能无法执行以下操作: - 查询系统视图或表。 - 创建临时表或使用全局临时表。 - 访问未明确授权的数据库对象。 3. **增强安全性** 通过移除 `PUBLIC` 的权限,数据库管理员能够更精细地控制谁可以访问哪些资源。这有助于减少潜在的安全风险,确保只有经过授权的用户才能执行特定操作[^4]。 4. **潜在问题** - 如果某些应用程序依赖于 `PUBLIC` 的默认权限来运行,撤销这些权限可能会导致应用程序失败。 - 用户可能需要重新分配明确的权限以恢复功能,这增加了管理复杂性。 - 对于不熟悉权限管理的开发者或管理员,可能会无意中引入不可预见的问题。 5. **示例代码** 下面是一个简单的 `REVOKE` 示例,用于从 `PUBLIC` 移除权限: ```sql -- 移除创建表的权限 REVOKE CREATETAB ON DATABASE FROM PUBLIC; -- 移除隐式模式创建的权限 REVOKE IMPLICIT_SCHEMA ON DATABASE FROM PUBLIC; ``` 这些命令会直接影响所有未明确授予权限的用户[^1]。 6. **角色和权限管理的替代方案** 使用角色(role)是一种更为灵活的方式,可以组织和分配权限。通过创建角色并将权限分配给角色,管理员可以简化权限管理流程。例如: ```sql -- 创建一个新角色 CREATE ROLE db_admin; -- 为角色分配权限 GRANT CREATETAB ON DATABASE TO ROLE db_admin; -- 将角色分配给特定用户 GRANT ROLE db_admin TO USER john_doe; ``` 这种方法不仅提高了管理效率,还减少了直接操作 `PUBLIC` 的需求[^4]。 ### 总结 执行 `REVOKE` 操作从 `PUBLIC` 移除权限可以显著提升数据库的安全性,但同时也可能影响普通用户的正常使用。因此,在实施此类操作之前,建议仔细评估所有可能的后果,并为受影响的用户或应用程序提供适当的替代权限。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值