Skip to content

Commit

Permalink
Fix autodetect failure on Android in toybox
Browse files Browse the repository at this point in the history
The sysctl utility returns 1 there (maybe because of lack of privileges).

Let's check the size of the output to understand whether `sysctl -a` failed.

Thanks to @Fi5t for the report.

Fixes #177.
  • Loading branch information
a13xp0p0v committed Feb 1, 2025
1 parent 0b33945 commit 0c00f3f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel_hardening_checker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def get_local_sysctl_file() -> Tuple[StrOrNone, str]:
ret = subprocess.run([sysctl_bin, '-a'], check=False, stdout=f,
stderr=subprocess.DEVNULL, shell=False).returncode
if ret != 0:
return None, f'sysctl command returned {ret}, stdout is saved to {sysctl_tmpfile}'
print(f'[!] WARNING: sysctl command returned {ret}')
if os.stat(sysctl_tmpfile).st_size == 0:
return None, f'sysctl command returned {ret}, stdout is empty'
return sysctl_tmpfile, 'OK'


Expand Down

0 comments on commit 0c00f3f

Please sign in to comment.