Add in the keyfile reading on the local client

This commit is contained in:
Thomas S Hatch 2011-03-07 09:58:23 -07:00
parent e4fd8db176
commit d1d4db4302
2 changed files with 18 additions and 3 deletions

View file

@ -25,11 +25,26 @@ The data structurte needs to be:
# small, and only start with the ability to execute salt commands locally.
# This means that the primary client to build is, the LocalClient
class SaltClientError(Exception): pass
class LocalClient(object):
'''
Connect to the salt master via the local server and via root
'''
def __init__(self):
pass
def __init__(self, c_path='/etc/salt/master'):
self.opts = salt.config.master_config(c_path)
self.key = self.__read_master_key()
def __read_master_key(self):
'''
Read in the rotating master authentication key
'''
try:
keyfile = os.path.join(self.opts['cachedir'], '.root_key')
key = open(keyfile, 'r').read()
return key
except:
raise SaltClientError('Failed to read in the salt root key')

View file

@ -100,7 +100,7 @@ class ReqServer(threading.Thread):
A key needs to be placed in the filesystem with permissions 0400 so
clients are required to run as root.
'''
keyfile = os.path.join(self.opts['cachedir'], 'root_key')
keyfile = os.path.join(self.opts['cachedir'], '.root_key')
key = salt.crypt.Crypticle.generate_key_string()
open(keyfile, 'w+').write(key)
return key