diff --git a/saspy/sasiohttp.py b/saspy/sasiohttp.py index 8d10f03a..8ea6cf8e 100644 --- a/saspy/sasiohttp.py +++ b/saspy/sasiohttp.py @@ -393,10 +393,11 @@ def __init__(self, session, **kwargs): try: fid = open(pwf, mode='r') for line in fid: - if line.startswith(pauthkey): - puser = line.partition(' user' )[2].lstrip().partition(' ')[0].partition('\n')[0] - ppw = line.partition(' password')[2].lstrip().partition(' ')[0].partition('\n')[0] - found = True + ls = line.split() + if len(ls) == 5 and ls[0] == self.sascfg.authkey and ls[1] == 'user' and ls[3] == 'password': + user = ls[2] + pw = ls[4] + found = True break fid.close() except OSError as e: diff --git a/saspy/sasioiom.py b/saspy/sasioiom.py index fe5dd533..7f94b509 100644 --- a/saspy/sasioiom.py +++ b/saspy/sasioiom.py @@ -358,10 +358,12 @@ def _startsas(self): try: fid = open(pwf, mode='r') for line in fid: - if line.startswith(self.sascfg.authkey): - user = line.partition(' user')[2].lstrip().partition(' ')[0].partition('\n')[0] - pw = line.partition(' password')[2].lstrip().partition(' ')[0].partition('\n')[0] + ls = line.split() + if len(ls) == 5 and ls[0] == self.sascfg.authkey and ls[1] == 'user' and ls[3] == 'password': + user = ls[2] + pw = ls[4] found = True + break fid.close() except OSError as e: logger.warning('Error trying to read authinfo file:'+pwf+'\n'+str(e))