From 284d26885503411a6ad4978668d01bd44fab3e87 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. One such case is that /root is a protected dir under SELinux which the master should not have access to. The daemon should instead change to the root dir which is the only dir that is always guaranteed to be there. The limited testing I have managed to do shows that windows accepts the '/' path too just fine so the os-specific case is not required either. --- salt/master.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/salt/master.py b/salt/master.py index 248b30b0a4..f54d0cd921 100644 --- a/salt/master.py +++ b/salt/master.py @@ -387,22 +387,11 @@ 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()) - else: - home = os.path.expanduser('~' + self.opts['user']) 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('/') except OSError as err: errors.append( - 'Cannot change to home directory {0} ({1})'.format(home, err) + 'Cannot change to root directory ({1})'.format(err) ) fileserver = salt.fileserver.Fileserver(self.opts)