Merge pull request #12230 from Security-Onion-Solutions/reyesj2-patch-sl

Handle non-zero
This commit is contained in:
Jorge Reyes
2024-01-23 08:31:48 -05:00
committed by GitHub

View File

@@ -40,15 +40,15 @@ def check_needs_restarted():
def check_for_fips(): def check_for_fips():
fips = 0 fips = 0
try: try:
result = subprocess.run(['fips-mode-setup', '--is-enabled'], check=True, stdout=subprocess.PIPE) result = subprocess.run(['fips-mode-setup', '--is-enabled'], stdout=subprocess.PIPE)
fips = int(result.returncode == 0) if result.returncode == 0:
fips = 1
except FileNotFoundError: except FileNotFoundError:
with open('/proc/sys/crypto/fips_enabled', 'r') as f: with open('/proc/sys/crypto/fips_enabled', 'r') as f:
contents = f.read() contents = f.read()
if '1' in contents: if '1' in contents:
fips = 1 fips = 1
else:
fips = 0
with open('/opt/so/log/sostatus/fips_enabled', 'w') as f: with open('/opt/so/log/sostatus/fips_enabled', 'w') as f:
f.write(str(fips)) f.write(str(fips))
@@ -61,8 +61,9 @@ def check_for_luks():
for gc in device['children']: for gc in device['children']:
if 'children' in gc: if 'children' in gc:
try: try:
result = subprocess.run(['cryptsetup', 'isLuks', gc['name']], check=True, stdout=subprocess.PIPE) result = subprocess.run(['cryptsetup', 'isLuks', gc['name']], stdout=subprocess.PIPE)
luks = int(result.returncode == 0) if result.returncode == 0:
luks = 1
except FileNotFoundError: except FileNotFoundError:
for ggc in gc['children']: for ggc in gc['children']:
if 'crypt' in ggc['type']: if 'crypt' in ggc['type']: