简述密码文件的两个特性

 

Oracle密码文件Password File是对sysdba和sysoper等高系统权限用户密码进行管理的一个载体。对我们来说,password file是在数据库之外的一个密码驻留点。本篇一起来讨论一下关于password file的一些特征和要点。

 

1、密码文件用户管理

 

我们选择Oracle 11g进行试验。密码文件在文件系统中是一个封闭的二进制文件,我们一般是没有办法看到其中的数据的。

 

但是,当Oracle启动之后,使用视图v$pwfile_users,我们可以看到当前密码文件其中包括的超级用户。

 

 

SQL> conn sys/oracle@ora11gp as sysdba

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0

Connected as SYS

 

SQL> select * from v$pwfile_users;

 

USERNAME                       SYSDBA SYSOPER SYSASM

------------------------------ ------ ------- ------

SYS                            TRUE   TRUE    FALSE

 

 

特殊权限用户名称全部列在其中。注意,在Oracle 11g中,引入了sysasm权限。在之前的版本中,我们只能看到sysdba和sysoper。

 

对于sysdba和sysoper的差别,主要体现在sysoper只有对于数据库一些管理性操作,如启动关闭数据库、备份还原等。而sysdba还要包括对象访问使用权限上。11g中新加入的sysasm权限主要是针对ASM和Grid Infrasture组件的管理。

 

如果我们显示的进行sysdba和sysoper权限的赋予,Oracle自动的将用户的信息添加到密码文件中。如下:

 

为了更好验证,我们创建一个名为test的用户。

 

 

SQL> create user test identified by test;

User created

 

SQL> grant resource, connect to test;

Grant succeeded

 

 

给scott和test两个用户分别授予sysdba和sysoper权限。

 

 

SQL> grant sysdba to scott;

Grant succeeded

 

SQL> grant sysoper to test;

Grant succeeded

 

SQL> select * from v$pwfile_users;

 

USERNAME                       SYSDBA SYSOPER SYSASM

------------------------------ ------ ------- ------

SYS                            TRUE   TRUE    FALSE

SCOTT                          TRUE   FALSE   FALSE

TEST                           FALSE  TRUE    FALSE

 

 

2、sysdba和sysoper用户登录试验

 

如果我们的scott和test两个用户已经有了sysdba和sysoper权限,就意味着两个人已经可以作为sysdba和sysoper登录。

 

当我们从远程系统进行登录的时候。

 

 

(远程)

SQL> conn scott/tiger@ora11gp as sysdba

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0

Connected as SYS

 

SQL> show user;

User is "SYS"

 

SQL> conn test/test@ora11gp as sysoper;

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0

Connected as PUBLIC

 

SQL> show user

User is "PUBLIC"

 

 

 

这里,我们发现了一个问题。首先,我们是通过远程登录的,OS匿名验证肯定是不能使用的,这里的密码验证一定是使用的。但是,我们登录之后,scott用户显示出的却是sys用户。而具有sysoper权限的test用户,显示出的却是public用户。Public用户是Oracle内部的一个“伪”用户,充当虚拟的角色。

 

那么,我们如果采用本地登录,效果是否相同呢?我们试验中首先禁用掉本地OS验证机制。

 

--已经禁用掉了OS验证;

[oracle@bsplinux admin]$ cat sqlnet.ora

SQLNET.AUTHENTICATION_SERVICES=(NONE)

[oracle@bsplinux admin]$

 

 

oracle@bsplinux admin]$ sqlplus /nolog

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 24 22:17:22 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

--匿名登录取消;

SQL> conn / as sysdba 

ERROR:

ORA-01031: insufficient privileges

 

--As sysdba

SQL> conn scott/tiger as sysdba

Connected.

SQL> show user

USER is "SYS"

SQL>

 

 

SQL> conn scott/tiger as sysoper;

ERROR:

ORA-01031: insufficient privileges

 

Warning: You are no longer connected to ORACLE.

 

 

SQL> conn test/test as sysdba

ERROR:

ORA-01031: insufficient privileges

 

--As sysoper

SQL> conn test/test as sysoper  

Connected.

SQL> show user

USER is "PUBLIC"

SQL>

 

 

效果相同。所以,我们可以得到结论:被赋予sysdba和sysoper权限的用户,是可以以as sysxxx的语句格式进行登录。但是登录之后,sysdba用户被替换为sys,而sysoper用户被替换为public。

 

3、密码文件重置

 

密码文件重置就是使用Oracle的orapwd工具重新创建一个全新的密码文件。但是,创建密码文件的时候,其中只会包括sys用户的信息,其他所有sysdba、sysoper和sysasm权限的用户不会被添加到文件中。并且进一步的是,这些用户的权限被剥夺。

 

Oracle密码文件位置遵守Oracle OFA规范。在windows环境下,该文件位于$ORACLE_HOME下的database文件夹。而在Linux/Unix环境下,位于dbs文件夹。

 

 

[oracle@bsplinux dbs]$ pwd

/u01/app/oracle/dbs

[oracle@bsplinux dbs]$ ls -l

total 9700

-rw-rw---- 1 oracle oinstall    1544 May 22 17:16 hc_DBUA0.dat

-rw-rw---- 1 oracle oinstall    1544 May 22 17:19 hc_ora11g.dat

-rw-r--r-- 1 oracle oinstall    2851 May 15  2009 init.ora

-rw-r----- 1 oracle oinstall      24 May 22 19:32 lkORA11G

-rw-r----- 1 oracle oinstall    2048 Sep 24 22:12 orapwora11g

drwx------ 2 oracle oinstall    4096 May 22 17:16 peshm_DBUA0_0

drwx------ 2 oracle oinstall    4096 May 22 17:19 peshm_ora11g_0

-rw-r----- 1 oracle oinstall 9846784 Sep 24 19:45 snapcf_ora11g.f

-rw-r----- 1 oracle oinstall    3584 Sep 24 22:14 spfileora11g.ora

 

 

我们可以使用orapwd工具重新生成密码文件。

 

 

[oracle@bsplinux dbs]$ orapwd file=orapwora11g password=oracle entries=5

[oracle@bsplinux dbs]$ ls -l

total 9692

-rw-rw---- 1 oracle oinstall    1544 May 22 17:16 hc_DBUA0.dat

-rw-rw---- 1 oracle oinstall    1544 May 22 17:19 hc_ora11g.dat

-rw-r--r-- 1 oracle oinstall    2851 May 15  2009 init.ora

-rw-r----- 1 oracle oinstall      24 May 22 19:32 lkORA11G

-rw-r----- 1 oracle oinstall    2048 Sep 24 22:21 orapwora11g

drwx------ 2 oracle oinstall    4096 May 22 17:16 peshm_DBUA0_0

drwx------ 2 oracle oinstall    4096 May 22 17:19 peshm_ora11g_0

 

 

对于新生成的密码文件orapwora11g,我们可以查看一下其中信息。

 

 

SQL> conn sys/oracle@ora11gp as sysdba

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0

Connected as SYS

 

SQL> select * from v$pwfile_users;

 

USERNAME                       SYSDBA SYSOPER SYSASM

------------------------------ ------ ------- ------

SYS                            TRUE   TRUE    FALSE

 

 

只有一条sys的用户信息。scott和test用户的sysdba和sysoper权限被剥夺。

 

 

SQL> conn scott/tiger@ora11gp as sysdba

ERROR:

ORA-01031: insufficient privileges

 

SQL> conn test/test@ora11gp as sysoper

ERROR:

ORA-01031: insufficient privileges

 

 

4、密码修改副效应

 

注意:在orapwd命令参数中,包括一个password参数,要求输入密码。这个参数存在一个潜在效果就是修改sys用户密码。

 

当前sys用户密码为oracle。

 

 

SQL> conn sys/oracle@ora11gp as sysdba

已连接。

SQL>

 

 

重新生成密码文件。

 

 

[oracle@bsplinux dbs]$ orapwd file=orapwora11g password=sys entries=5

[oracle@bsplinux dbs]$ ls -l

total 9692

-rw-rw---- 1 oracle oinstall    1544 May 22 17:16 hc_DBUA0.dat

-rw-rw---- 1 oracle oinstall    1544 May 22 17:19 hc_ora11g.dat

-rw-r--r-- 1 oracle oinstall    2851 May 15  2009 init.ora

-rw-r----- 1 oracle oinstall      24 May 22 19:32 lkORA11G

-rw-r----- 1 oracle oinstall    2048 Sep 24 22:25 orapwora11g

drwx------ 2 oracle oinstall    4096 May 22 17:16 peshm_DBUA0_0

drwx------ 2 oracle oinstall    4096 May 22 17:19 peshm_ora11g_0

-rw-r----- 1 oracle oinstall 9846784 Sep 24 19:45 snapcf_ora11g.f

-rw-r----- 1 oracle oinstall    3584 Sep 24 22:14 spfileora11g.ora

 

 

SQL> conn sys/oracle@ora11gp as sysdba

ERROR:

ORA-01017: invalid username/password; logon denied

 

警告: 您不再连接到 ORACLE。

SQL> conn sys/sys@ora11gp as sysdba

已连接。

SQL>

 

 

用户sys的密码被修改。

 

使用密码文件重新生成的方法来修改sys用户帐号,笔者认为存在很大的安全隐患。如果服务器OS用户可以自行orapwd程序,那么也就是控制了sys用户帐号。

 

另一方面,使用密码文件来修改稿权限用户帐号,也是一种策略手段。在MOS中,就有介绍使用密码文件重置来修改ASM实例管理员密码的方法。

 

 

5、结论

 

Oracle密码文件是Oracle安全的一道重要防线。

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17203031/viewspace-745065/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/17203031/viewspace-745065/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值