mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add in the keyfile reading on the local client
This commit is contained in:
parent
e4fd8db176
commit
d1d4db4302
2 changed files with 18 additions and 3 deletions
|
@ -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')
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue