Skip to content

Commit

Permalink
Fix: utils: set env CIB_shadow using os.environ (bsc#1205925)
Browse files Browse the repository at this point in the history
`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 14, 2024
1 parent 20b954f commit ca85c40
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ def this_node():


def set_cib_in_use(name):
os.putenv(_cib_shadow, name)
os.environ[_cib_shadow] = name
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]
global _cib_in_use
_cib_in_use = ''

Expand Down

0 comments on commit ca85c40

Please sign in to comment.