Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Make sure configured user is properly set by Salt" (bsc#1216284) #614

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/common/salt-master.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ LimitNOFILE=100000
Type=notify
NotifyAccess=all
ExecStart=/usr/bin/salt-master
User=salt

[Install]
WantedBy=multi-user.target
1 change: 0 additions & 1 deletion pkg/old/deb/salt-master.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ LimitNOFILE=16384
Type=notify
NotifyAccess=all
ExecStart=/usr/bin/salt-master
User=salt

[Install]
WantedBy=multi-user.target
1 change: 0 additions & 1 deletion pkg/old/suse/salt-master.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ LimitNOFILE=100000
Type=simple
ExecStart=/usr/bin/salt-master
TasksMax=infinity
User=salt

[Install]
WantedBy=multi-user.target
27 changes: 0 additions & 27 deletions salt/cli/daemons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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
Expand Down Expand Up @@ -74,16 +73,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.
Expand Down Expand Up @@ -189,10 +178,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

Expand Down Expand Up @@ -305,10 +290,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
Expand Down Expand Up @@ -497,10 +478,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
Expand Down Expand Up @@ -599,10 +576,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

Expand Down
8 changes: 0 additions & 8 deletions salt/cli/ssh.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -17,11 +15,5 @@ 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)
ssh.run()
4 changes: 2 additions & 2 deletions salt/utils/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,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
Expand Down
4 changes: 2 additions & 2 deletions tests/pytests/integration/cli/test_salt_minion.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_exit_status_unknown_user(salt_master, minion_id):
factory = salt_master.salt_minion_daemon(
minion_id, overrides={"user": "unknown-user"}
)
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
Expand All @@ -53,7 +53,7 @@ def test_exit_status_unknown_argument(salt_master, minion_id):
"""
with pytest.raises(FactoryNotStarted) as exc:
factory = salt_master.salt_minion_daemon(minion_id)
factory.start("--unknown-argument", start_timeout=30, max_start_attempts=1)
factory.start("--unknown-argument", start_timeout=10, max_start_attempts=1)

assert exc.value.process_result.returncode == salt.defaults.exitcodes.EX_USAGE
assert "Usage" in exc.value.process_result.stderr
Expand Down
Loading