File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,26 @@ def selinux_enforcing?
334334 raise 'Could not determine SELinux status'
335335 end
336336
337+ #
338+ # Returns Yama LSM ptrace scope level
339+ #
340+ # @return [Integer] Yama ptrace scope level (0 if disabled or not installed)
341+ # @raise [RuntimeError] If execution fails.
342+ #
343+ def yama_ptrace_scope
344+ ptrace_scope = read_file ( '/proc/sys/kernel/yama/ptrace_scope' ) . to_s . strip
345+
346+ return 0 unless ptrace_scope
347+
348+ level = ptrace_scope . scan ( /\A (\d +)\z / ) . flatten . first . to_i
349+
350+ return 0 unless level
351+
352+ level
353+ rescue StandardError
354+ raise 'Could not determine Yama scope'
355+ end
356+
337357 #
338358 # Returns true if Yama is installed
339359 #
@@ -356,9 +376,7 @@ def yama_installed?
356376 # @raise [RuntimeError] If execution fails.
357377 #
358378 def yama_enabled?
359- return false unless yama_installed?
360-
361- !read_file ( '/proc/sys/kernel/yama/ptrace_scope' ) . to_s . strip . eql? '0'
379+ yama_ptrace_scope > 0
362380 rescue StandardError
363381 raise 'Could not determine Yama status'
364382 end
You can’t perform that action at this time.
0 commit comments