二、对安全性至关重要的实例参数
对于数据库的安全性来说,某些实例参数至关重要。这些参数的默认值通常都是合适的,但在某些情况下可能需要修改。
1、UTL_FILE_DIR
gyj1@OCM> show parameter utl_file
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
utl_file_dir string
utl_file_dir默认为空值,设置这个参数需要小心,utl_file_dir参数允许PL/SQL通过UTL_FILE包来访问服务器计算机文件系统。而UTL_FILE包具有打开并读写文件的过程,唯一的限制是Oracle拥有者必须能访问所列出的目录。
utl_file_dir参数接受一个用逗号分隔的目录列表,并且是静态的,如下操作:
sys@OCM> alter system set utl_file_dir='/oracle/ocp','/oracle/ocm/' scope=spfile;
System altered.
2、OS_AUTHENT_PREFIX
这个参数控制某个用户是否参够在不需要给出口令的情况下从远程计算机上连接数据库。
sys@OCM> show parameter os_authent
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
os_authent_prefix string ops$
remote_os_authent boolean FALSE
(1)修改参数
sys@OCM> alter system set os_authent_prefix='' scope=spfile;
System altered.
sys@OCM> startup force;
(2)建操作系统用户及设置密码
[root@ocm ~]# useradd joe
[root@ocm ~]# passwd joe
Changing password for user joe.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
(3)建数据库用户及授权
sys@OCM> create user joe identified externally;
User created.
sys@OCM> grant dba to joe;
Grant succeeded.
(4)操作系统认证
[root@ocm ~]# su - joe
[joe@ocm ~]$ export ORACLE_BASE=/u01/app/oracle
[joe@ocm ~]$ export ORACLE_HOME=$ORACLE_BASE/product/11.2.0
[joe@ocm ~]$ export ORACLE_SID=ocm
[joe@ocm ~]$ export PATH=$ORACLE_HOME/bin:$PATH
[joe@ocm ~]$ sqlplus /
SQL*Plus: Release 11.2.0.1.0 Production on Mon Mar 11 21:25:13 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
只要服务器操作系统安全,那么上面的操作也是安全的。
3、REMOTE_OS_AUTHENT
gyj1@OCM> show parameter remote_os_authent
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_os_authent boolean FALSE
默认是 FALSE,把它改成TRUE
gyj1@OCM> conn / as sysdba
Connected.
sys@OCM> alter system set remote_os_authent=TRUE scope=spfile;
System altered.
sys@OCM> startup force;
[joe@ocm ~]$ sqlplus /@ocm
SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 12 19:41:59 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
joe@OCM>
注意这里要想成功操作系统登录,必须把sqlnet.ora给干掉(mv sqlnet.ora sqlnet.ora.bak)
remote_os_authent这个参数开启后, 存在很大的安全隐患, 远端服务器只要根据数据库中存在的外部用户来创建用户, 就可以登陆到数据库中, 因此除非必要, 否则不建议开启这个参数。
