bsdcapsicum.rb/share/ruby-capsicum/examples/1_capability_mode_example.rb

19 lines
558 B
Ruby
Raw Normal View History

2024-06-25 04:36:09 +02:00
require "bundler/setup"
require "capsicum"
print "In capability mode: ", Capsicum.in_capability_mode? ? "yes" : "no", "\n"
print "Enter capability mode: ", Capsicum.enter! ? "ok" : "error", "\n"
print "In capability mode: ", Capsicum.in_capability_mode? ? "yes" : "no", "\n"
begin
File.new(File::NULL)
rescue Errno::ECAPMODE => ex
print "Error: #{ex.message} (#{ex.class})", "\n"
end
##
# In capability mode: no
# Enter capability mode: ok
# In capability mode: yes
# Error: Not permitted in capability mode @ rb_sysopen - /dev/null (Errno::ECAPMODE)