File tree 1 file changed +21
-3
lines changed
1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,26 @@ def selinux_enforcing?
334
334
raise 'Could not determine SELinux status'
335
335
end
336
336
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
+
337
357
#
338
358
# Returns true if Yama is installed
339
359
#
@@ -356,9 +376,7 @@ def yama_installed?
356
376
# @raise [RuntimeError] If execution fails.
357
377
#
358
378
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
362
380
rescue StandardError
363
381
raise 'Could not determine Yama status'
364
382
end
You can’t perform that action at this time.
0 commit comments