Hi all!
I include below my script and the files involved.
Currently, it prints the sqlnet.ora files that contain SQLNET.AUTHENTICATION_SERVICES set to something other than (NONE).
However, I need to add a condition that includes in this list files that don´t contain this parameter as well, but I can´t think of a way to check this without going line by line and erroring for each line that doesn´t contain it (which isn´t what I want).
Can anybody help me? This is probably easy for you gurus, and I´m learning a lot from this forum, but I´m kinda stuck now. )
Thanks in advance,
T.
My script:
=================================================
#!/usr/bin/perl
my $oratab='/home/tmillan/oratab';
open(BIN, "<$oratab\n") or die "Couldn't open file for reading: $!n";
while (<BIN>) {
s/#.*//; #ignore comments
next if /^(\s)*$/; #ignore blank lines
chomp;
my ($orahome) = (split /:/)[1];
push @homes, "$orahome" ;
}
close BIN;
foreach (@homes) {
my $sqlnet="$_/network/admin/sqlnet.ora";
# print "$sqlnet\n";
open (BIN2, "<$sqlnet\n") or die "cant open $sqlnet: $!";
while (<BIN2>) {
s/#*//; #ignore comments
next if /^(\s)+$/; #ignore blanks
chomp;
if ($_ =~ /^SQLNET\.AUTHENTICATION_SERVICES/i) {
(undef, $test) = split /\=/;
if ($test eq '(NONE)') {
print "good: SQLNET.AUTHENTICATION_SERVICES is set to (NONE) in $sqlnet.\n";
}
else {
push (@baddies, "$sqlnet contains $_, ");
}
}
}
close BIN2;
}
print "emrep: Change the value of SQLNET.AUTHENTICATION_SEVICES to (NONE) in the following configuration files to prevent SYS connections that do not require a password: @baddies\n";
exit;
====================================================
/home/tmillan/oratab:
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
HELIO:/home/oracle10/oracle/product/10.2.0/db_1:Y
TUNEZ:/oracle/product/11g:N
================================================
/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora:
==================================================
# sqlnet.ora Network Configuration File: /u02/db102/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
SQLNET.AUTHENTICATION_SERVICES=(baddie1)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
=================================================
/oracle/product/11g/network/admin:
===============================================
# sqlnet.ora Network Configuration File: /u02/db102/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
SQLNET.AUTHENTICATION_SERVICES=(baddie2)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
I include below my script and the files involved.
Currently, it prints the sqlnet.ora files that contain SQLNET.AUTHENTICATION_SERVICES set to something other than (NONE).
However, I need to add a condition that includes in this list files that don´t contain this parameter as well, but I can´t think of a way to check this without going line by line and erroring for each line that doesn´t contain it (which isn´t what I want).
Can anybody help me? This is probably easy for you gurus, and I´m learning a lot from this forum, but I´m kinda stuck now. )
Thanks in advance,
T.
My script:
=================================================
#!/usr/bin/perl
my $oratab='/home/tmillan/oratab';
open(BIN, "<$oratab\n") or die "Couldn't open file for reading: $!n";
while (<BIN>) {
s/#.*//; #ignore comments
next if /^(\s)*$/; #ignore blank lines
chomp;
my ($orahome) = (split /:/)[1];
push @homes, "$orahome" ;
}
close BIN;
foreach (@homes) {
my $sqlnet="$_/network/admin/sqlnet.ora";
# print "$sqlnet\n";
open (BIN2, "<$sqlnet\n") or die "cant open $sqlnet: $!";
while (<BIN2>) {
s/#*//; #ignore comments
next if /^(\s)+$/; #ignore blanks
chomp;
if ($_ =~ /^SQLNET\.AUTHENTICATION_SERVICES/i) {
(undef, $test) = split /\=/;
if ($test eq '(NONE)') {
print "good: SQLNET.AUTHENTICATION_SERVICES is set to (NONE) in $sqlnet.\n";
}
else {
push (@baddies, "$sqlnet contains $_, ");
}
}
}
close BIN2;
}
print "emrep: Change the value of SQLNET.AUTHENTICATION_SEVICES to (NONE) in the following configuration files to prevent SYS connections that do not require a password: @baddies\n";
exit;
====================================================
/home/tmillan/oratab:
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
HELIO:/home/oracle10/oracle/product/10.2.0/db_1:Y
TUNEZ:/oracle/product/11g:N
================================================
/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora:
==================================================
# sqlnet.ora Network Configuration File: /u02/db102/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
SQLNET.AUTHENTICATION_SERVICES=(baddie1)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
=================================================
/oracle/product/11g/network/admin:
===============================================
# sqlnet.ora Network Configuration File: /u02/db102/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
SQLNET.AUTHENTICATION_SERVICES=(baddie2)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)