diff --git a/pkg/common/salt-master.service b/pkg/common/salt-master.service index 257ecc283fe..377c87afeb9 100644 --- a/pkg/common/salt-master.service +++ b/pkg/common/salt-master.service @@ -8,7 +8,6 @@ LimitNOFILE=100000 Type=notify NotifyAccess=all ExecStart=/usr/bin/salt-master -User=salt [Install] WantedBy=multi-user.target diff --git a/pkg/old/deb/salt-master.service b/pkg/old/deb/salt-master.service index f9dca296b4a..b5d0cdd22cd 100644 --- a/pkg/old/deb/salt-master.service +++ b/pkg/old/deb/salt-master.service @@ -7,7 +7,6 @@ LimitNOFILE=16384 Type=notify NotifyAccess=all ExecStart=/usr/bin/salt-master -User=salt [Install] WantedBy=multi-user.target diff --git a/pkg/old/suse/salt-master.service b/pkg/old/suse/salt-master.service index caabca511c9..9e002d16cae 100644 --- a/pkg/old/suse/salt-master.service +++ b/pkg/old/suse/salt-master.service @@ -8,7 +8,6 @@ LimitNOFILE=100000 Type=simple ExecStart=/usr/bin/salt-master TasksMax=infinity -User=salt [Install] WantedBy=multi-user.target diff --git a/salt/cli/daemons.py b/salt/cli/daemons.py index 3d90e1409ce..efd89219551 100644 --- a/salt/cli/daemons.py +++ b/salt/cli/daemons.py @@ -6,7 +6,6 @@ import os import warnings -import salt.defaults.exitcodes import salt.utils.kinds as kinds from salt.exceptions import SaltClientError, SaltSystemExit, get_error_message from salt.utils import migrations @@ -73,16 +72,6 @@ def verify_hash_type(self): self.__class__.__name__, ) - def verify_user(self): - """ - Verify Salt configured user for Salt and shutdown daemon if not valid. - - :return: - """ - if not check_user(self.config["user"]): - self.action_log_info("Cannot switch to configured user for Salt. Exiting") - self.shutdown(salt.defaults.exitcodes.EX_NOUSER) - def action_log_info(self, action): """ Say daemon starting. @@ -208,10 +197,6 @@ def prepare(self): self.config["interface"] = ip_bracket(self.config["interface"]) migrations.migrate_paths(self.config) - # Ensure configured user is valid and environment is properly set - # before initializating rest of the stack. - self.verify_user() - # Late import so logging works correctly import salt.master @@ -324,10 +309,6 @@ def prepare(self): transport = self.config.get("transport").lower() - # Ensure configured user is valid and environment is properly set - # before initializating rest of the stack. - self.verify_user() - try: # Late import so logging works correctly import salt.minion @@ -516,10 +497,6 @@ def prepare(self): self.action_log_info("An instance is already running. Exiting") self.shutdown(1) - # Ensure configured user is valid and environment is properly set - # before initializating rest of the stack. - self.verify_user() - # TODO: AIO core is separate from transport # Late import so logging works correctly import salt.minion @@ -618,10 +595,6 @@ def prepare(self): self.action_log_info('Setting up "{}"'.format(self.config["id"])) - # Ensure configured user is valid and environment is properly set - # before initializating rest of the stack. - self.verify_user() - # Late import so logging works correctly import salt.minion diff --git a/salt/cli/ssh.py b/salt/cli/ssh.py index aa043dbf9af..78522a044a9 100644 --- a/salt/cli/ssh.py +++ b/salt/cli/ssh.py @@ -1,9 +1,7 @@ import sys import salt.client.ssh -import salt.defaults.exitcodes import salt.utils.parsers -from salt.utils.verify import check_user class SaltSSH(salt.utils.parsers.SaltSSHOptionParser): @@ -17,12 +15,6 @@ def run(self): # that won't be used anyways with -H or --hosts self.parse_args() - if not check_user(self.config["user"]): - self.exit( - salt.defaults.exitcodes.EX_NOUSER, - "Cannot switch to configured user for Salt. Exiting", - ) - ssh = salt.client.ssh.SSH(self.config) try: ssh.run() diff --git a/salt/utils/verify.py b/salt/utils/verify.py index 3735e477241..85d9e568390 100644 --- a/salt/utils/verify.py +++ b/salt/utils/verify.py @@ -346,8 +346,8 @@ def check_user(user): # We could just reset the whole environment but let's just override # the variables we can get from pwuser - # We ensure HOME is always present and set according to pwuser - os.environ["HOME"] = pwuser.pw_dir + if "HOME" in os.environ: + os.environ["HOME"] = pwuser.pw_dir if "SHELL" in os.environ: os.environ["SHELL"] = pwuser.pw_shell diff --git a/tests/pytests/integration/cli/test_salt_minion.py b/tests/pytests/integration/cli/test_salt_minion.py index 55120259aff..8c03f482ec3 100644 --- a/tests/pytests/integration/cli/test_salt_minion.py +++ b/tests/pytests/integration/cli/test_salt_minion.py @@ -50,7 +50,7 @@ def test_exit_status_unknown_user(salt_master, minion_id): ), }, ) - factory.start(start_timeout=30, max_start_attempts=1) + factory.start(start_timeout=10, max_start_attempts=1) assert exc.value.process_result.returncode == salt.defaults.exitcodes.EX_NOUSER assert "The user is not available." in exc.value.process_result.stderr