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

[crmsh-4.6] Fix: sh: pass env to child process explicitly (bsc#1205925) #1356

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Fix: utils: set env CIB_shadow using os.environ (bsc#1205925)
`os.environ` is captured once from libc on python process startup (when
module `os` is imported from `site.py`) and is the only one interface
able to enumerate environment variables. Changing environment variables
with other interfaces (including `os.putenv`, `os.unsetenv`, or call
libc interface in some CPython modules) makes `os.environ` out of sync
and should be avoided.
  • Loading branch information
nicholasyang2022 committed Mar 13, 2024
commit 1ceec363c4ecbc8da6f3f3e449f2482a4f08869b
5 changes: 3 additions & 2 deletions crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,14 @@


def set_cib_in_use(name):
os.putenv(_cib_shadow, name)
os.environ[_cib_shadow] = name

Check warning on line 153 in crmsh/utils.py

View check run for this annotation

Codecov / codecov/patch

crmsh/utils.py#L153

Added line #L153 was not covered by tests
global _cib_in_use
_cib_in_use = name


def clear_cib_in_use():
os.unsetenv(_cib_shadow)
if _cib_shadow in os.environ:
del os.environ[_cib_shadow]

Check warning on line 160 in crmsh/utils.py

View check run for this annotation

Codecov / codecov/patch

crmsh/utils.py#L159-L160

Added lines #L159 - L160 were not covered by tests
global _cib_in_use
_cib_in_use = ''

Expand Down Expand Up @@ -798,7 +799,7 @@
def ext_cmd_nosudo(cmd, shell=True):
if options.regression_tests:
print(".EXT", cmd)
return subprocess.call(

Check warning on line 802 in crmsh/utils.py

View check run for this annotation

Codecov / codecov/patch

crmsh/utils.py#L802

Added line #L802 was not covered by tests
cmd,
shell=shell,
env=os.environ, # bsc#1205925
Expand Down
Loading