Skip to content

Commit

Permalink
fix code finding authkey in authinfo file
Browse files Browse the repository at this point in the history
  • Loading branch information
tomweber-sas committed Aug 17, 2023
1 parent 367ffb2 commit e6079ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions saspy/sasiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 5 additions & 3 deletions saspy/sasioiom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit e6079ad

Please sign in to comment.