Permalink
Browse files

Make token_file option more robust

  • Loading branch information...
1 parent fab0b58 commit a3774b8669fd158486d93a73570013d6263ae148 @thatch45 thatch45 committed Oct 9, 2012
Showing with 16 additions and 5 deletions.
  1. +10 −1 salt/auth/__init__.py
  2. +6 −4 salt/config.py
View
@@ -116,7 +116,7 @@ def mk_token(self, load):
'token': tok}
with open(t_path, 'w+') as fp_:
fp_.write(self.serial.dumps(tdata))
- return tok
+ return tdata
def get_tok(self, tok):
'''
@@ -182,3 +182,12 @@ def cli(self, eauth):
ret[kwarg] = raw_input('{0} [{1}]: '.format(kwarg, default))
return ret
+
+ def token_cli(self, eauth):
+ '''
+ Create the token from the cli and request the correct data to
+ authenticate via the passed authentication mechanism
+ '''
+ load = self.cli(eauth)
+ tdata = self.auth.mktoken(load)
+
View
@@ -347,11 +347,13 @@ def client_config(path):
searches for client specific configurations and adds them to the data from
the master configuration.
'''
- opts = master_config(path)
+ opts = {'token_file': os.path.expanduser('~/.salt_token')}
+ opts.update(master_config(path))
cpath = os.path.expanduser('~/.salt')
load_config(opts, cpath, 'SALT_CLIENT_CONFIG')
if 'token_file' in opts:
- if os.path.isfile(opts['token_file']):
- with open(opts['token_file']) as fp_:
- opts['token'] = fp_.read().strip()
+ opts['token_file'] = os.path.expand_user(opts['token_file'])
+ if os.path.isfile(opts['token_file']):
+ with open(opts['token_file']) as fp_:
+ opts['token'] = fp_.read().strip()
return opts

0 comments on commit a3774b8

Please sign in to comment.