Details
Description
VR CsFile search utility methods fail when search string has char *, + etc.
These utility methods in CsFile [1] uses python regular expression module to search a string in a file. However, if caller passes a search string, that has chars *, +, . etc that are also happen to be express wild card / match expression in regular expression results in exceptions from python 're' module.
For instance searching for VPN user [2] passes "username * password *" as search string, if password has chars the interfer with regular expression metacharecters then search will result in exception.
2016-09-12 13:55:48,976 configure.py add_l2tp_ipsec_user:569 Adding vpn user murali * abcd++efgh## *
2016-09-12 13:55:48,976 CsFile.py load:39 Reading file /etc/ppp/chap-secrets
2016-09-12 13:55:48,976 CsFile.py searchString:140 Searching for murali * abcd++efgh## * string
2016-09-12 13:55:48,976 configure.py main:1020 Exception while configuring router
Traceback (most recent call last):
File "/opt/cloud/bin/configure.py", line 965, in main
vpnuser.process()
File "/opt/cloud/bin/configure.py", line 559, in process
self.add_l2tp_ipsec_user(user, userconfig)
File "/opt/cloud/bin/configure.py", line 572, in add_l2tp_ipsec_user
userfound = file.searchString(userSearchEntry, '#')
File "/opt/cloud/bin/cs/CsFile.py", line 146, in searchString
if re.search(search, line):
File "/usr/lib/python2.7/re.py", line 142, in search
return _compile(pattern, flags).search(string)
File "/usr/lib/python2.7/re.py", line 242, in _compile
raise error, v # invalid expression
1 https://github.com/apache/cloudstack/blob/master/systemvm/patches/debian/config/opt/cloud/bin/cs/CsFile.py
2 https://github.com/apache/cloudstack/blob/master/systemvm/patches/debian/config/opt/cloud/bin/configure.py#L572
Attachments
Issue Links
- links to