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

Execute source using /bin/bash not /bin/sh #547

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion lib/fencing.py.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ def fence_logout(conn, logout_string, sleep=0):
def source_env(env_file):
# POSIX: name shall not contain '=', value doesn't contain '\0'
output = subprocess.check_output("source {} && env -0".format(env_file), shell=True,
executable="/bin/sh")
executable="/bin/bash")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case, the bash´ism should be removed. /bin/bash is not available on all systems.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works fine if you replace "source" with "." (tested with bash, dash and sh on FreeBSD):
output = subprocess.check_output(". {} && env -0".format(env_file), shell=True, executable="/bin/sh")

# replace env
os.environ.clear()
os.environ.update(line.partition('=')[::2] for line in output.decode("utf-8").split('\0') if not re.match("^\s*$", line))
Expand Down