Skip to content

Commit

Permalink
Change ignore to surrogateescape for kernelparameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Zhestkov authored and Victor Zhestkov committed Sep 12, 2022
1 parent 60e72ea commit e0fd5f6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3170,7 +3170,9 @@ def kernelparams():
return {}
else:
try:
with salt.utils.files.fopen("/proc/cmdline", "r", errors="ignore") as fhr:
with salt.utils.files.fopen(
"/proc/cmdline", "r", errors="surrogateescape"
) as fhr:
cmdline = fhr.read()
grains = {"kernelparams": []}
for data in [
Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/unit/grains/proc-files/cmdline
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TEST_KEY1=VAL1 TEST_KEY2=VAL2 TEST_KEY_NOVAL TEST_KEY3=3
TEST_KEY1=VAL1 TEST_KEY2=VAL2 BOOTABLE_FLAG="�" TEST_KEY_NOVAL TEST_KEY3=3
1 change: 1 addition & 0 deletions tests/pytests/unit/grains/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,7 @@ def _open_mock(file_name, *args, **kwargs):
"kernelparams": [
("TEST_KEY1", "VAL1"),
("TEST_KEY2", "VAL2"),
("BOOTABLE_FLAG", "\udc80"),
("TEST_KEY_NOVAL", None),
("TEST_KEY3", "3"),
]
Expand Down

0 comments on commit e0fd5f6

Please sign in to comment.