From 98a7c097aa135b5b91e5f65e76222c35b027b6ce Mon Sep 17 00:00:00 2001 From: Jason Zaman Date: Sun, 13 Sep 2015 01:00:37 +0800 Subject: [PATCH] salt/master: chdir to root not homedir The pre-flight checks try to change to $HOME, this can fail for multiple reasons. /root is a protected dir. The daemon should instead change to the root dir which is the only that is always going to be there. --- salt/master.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/salt/master.py b/salt/master.py index 248b30b..8edf281 100644 --- a/salt/master.py +++ b/salt/master.py @@ -387,22 +387,15 @@ class Master(SMaster): errors = [] critical_errors = [] - if salt.utils.is_windows() and self.opts['user'] == 'root': - # 'root' doesn't typically exist on Windows. Use the current user - # home directory instead. - home = os.path.expanduser('~' + salt.utils.get_user()) + if salt.utils.is_windows(): + root = 'C:\\' else: - home = os.path.expanduser('~' + self.opts['user']) + root = '/' try: - if salt.utils.is_windows() and not os.path.isdir(home): - # On Windows, Service account home directories may not - # initially exist. If this is the case, make sure the - # directory exists before continuing. - os.mkdir(home, 0o755) - os.chdir(home) + os.chdir(root) except OSError as err: errors.append( - 'Cannot change to home directory {0} ({1})'.format(home, err) + 'Cannot change to root directory {0} ({1})'.format(root, err) ) fileserver = salt.fileserver.Fileserver(self.opts) -- 2.4.6