oravirt / ansible-oracle-modules

Oracle modules for Ansible
MIT License
214 stars 159 forks source link

check_db_exists and sid=None #94

Open Rendanic opened 5 years ago

Rendanic commented 5 years ago

There is a major bug in all functions check_db_exists with parameter sid.


 def check_db_exists(module, msg, oracle_home, db_name, sid, db_unique_name ):
     if sid is None:
         sid = ''

-                    elif re.search(db_name +':', line) or re.search(sid +':', line):
+                    elif re.search('^%s:' % db_name, line) or (sid is not None and re.search('^%s:' % sid, line)):

There are some problems:
- ORACLE_HOME could be wrong for an instance in oratab due to wrong regular expression
- sid = None is an issue, with empty SID line in oratab
Example: ':/u01/app/oracle/...:N'

That issue affects all modules with check_db_exists and sid parameter.