mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Enable temporary write permission so can update keys on write_local
This commit is contained in:
parent
1dc254cc1e
commit
227ffcc412
@ -62,7 +62,6 @@ class BasicTestCase(unittest.TestCase):
|
||||
self.localFilepath = os.path.join(pkiDirpath, 'local.key')
|
||||
if os.path.exists(self.localFilepath):
|
||||
mode = os.stat(self.localFilepath).st_mode
|
||||
print mode
|
||||
os.chmod(self.localFilepath, mode | stat.S_IWUSR | stat.S_IWUSR)
|
||||
|
||||
self.cacheDirpath = os.path.join(self.saltDirpath, 'cache')
|
||||
@ -78,7 +77,7 @@ class BasicTestCase(unittest.TestCase):
|
||||
)
|
||||
|
||||
self.mainKeeper = RaetKey(opts=self.opts)
|
||||
self.baseDirpath = tempfile.mkdtemp(prefix="salt", suffix="keep", dir='/tmp')
|
||||
self.baseDirpath = tempfile.mkdtemp(prefix="salt", suffix="base", dir='/tmp')
|
||||
|
||||
def tearDown(self):
|
||||
if os.path.exists(self.saltDirpath):
|
||||
|
@ -104,10 +104,9 @@ def test():
|
||||
localFilepath = os.path.join(pkiDirpath, 'local.key')
|
||||
if os.path.exists(localFilepath):
|
||||
mode = os.stat(localFilepath).st_mode
|
||||
print mode
|
||||
os.chmod(localFilepath, mode | stat.S_IWUSR | stat.S_IRUSR)
|
||||
mode = os.stat(localFilepath).st_mode
|
||||
print mode
|
||||
|
||||
|
||||
|
||||
cacheDirpath = os.path.join('/tmp/raet', 'cache', 'minion')
|
||||
sockDirpath = os.path.join('/tmp/raet', 'sock', 'minion')
|
||||
@ -319,11 +318,9 @@ class BasicTestCase(unittest.TestCase):
|
||||
transport='raet',
|
||||
)
|
||||
|
||||
self.masterSafe = salting.SaltSafe(opts=self.opts)
|
||||
print("masterSafe local =\n{0}".format(masterSafe.loadLocalData()))
|
||||
print("masterSafe remote =\n{0}".format(masterSafe.loadAllRemoteData()))
|
||||
self.mainSafe = salting.SaltSafe(opts=self.opts)
|
||||
|
||||
self.baseDirpath = tempfile.mkdtemp(prefix="raet", suffix="keep", '/tmp')
|
||||
self.baseDirpath = tempfile.mkdtemp(prefix="raet", suffix="base", dir='/tmp')
|
||||
|
||||
|
||||
|
||||
@ -379,10 +376,11 @@ class BasicTestCase(unittest.TestCase):
|
||||
|
||||
stack = stacking.RoadStack(name=data['name'],
|
||||
local=local,
|
||||
auto=auto,
|
||||
main=main,
|
||||
dirpath=data['dirpath'],
|
||||
store=self.store)
|
||||
store=self.store,
|
||||
safe=safe,
|
||||
auto=auto,)
|
||||
|
||||
return stack
|
||||
|
||||
@ -432,16 +430,17 @@ class BasicTestCase(unittest.TestCase):
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testBasic.__doc__))
|
||||
|
||||
self.assertEqual(self.mainSafe.loadLocalData(), None)
|
||||
self.assertEqual(self.mainSafe.loadAllRemoteData(), {})
|
||||
|
||||
auto = True
|
||||
data = self.createRoadData(name='main', base=self.baseDirpath)
|
||||
keeping.clearAllKeepSafe(data['dirpath'])
|
||||
|
||||
main = self.createRoadStack(data=data,
|
||||
eid=1,
|
||||
main=True,
|
||||
auto=auto,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
safe=self.masterSafe)
|
||||
safe=self.mainSafe)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\nsafe dirpath = {0}\n".format(
|
||||
main.name, main.keep.dirpath, main.safe.dirpath))
|
||||
|
@ -7,6 +7,7 @@ used to manage salt keys directly without interfacing with the CLI.
|
||||
# Import python libs
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import stat
|
||||
import shutil
|
||||
import fnmatch
|
||||
import hashlib
|
||||
@ -1047,6 +1048,10 @@ class RaetKey(Key):
|
||||
'sign': sign}
|
||||
path = os.path.join(self.opts['pki_dir'], 'local.key')
|
||||
c_umask = os.umask(191)
|
||||
if os.path.exists(path):
|
||||
#mode = os.stat(path).st_mode
|
||||
os.chmod(path, stat.S_IWUSR | stat.S_IRUSR)
|
||||
with salt.utils.fopen(path, 'w+') as fp_:
|
||||
fp_.write(self.serial.dumps(keydata))
|
||||
os.chmod(path, stat.S_IRUSR)
|
||||
os.umask(c_umask)
|
||||
|
Loading…
Reference in New Issue
Block a user