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

19 lines
577 B
Ruby
Raw Normal View History

2024-06-25 04:36:09 +02:00
require "bundler/setup"
2024-06-25 08:25:53 +02:00
require "bsd/capsicum"
2024-06-25 04:36:09 +02:00
2024-06-25 08:25:53 +02:00
print "In capability mode: ", BSD::Capsicum.in_capability_mode? ? "yes" : "no", "\n"
print "Enter capability mode: ", BSD::Capsicum.enter! ? "ok" : "error", "\n"
print "In capability mode: ", BSD::Capsicum.in_capability_mode? ? "yes" : "no", "\n"
2024-06-25 04:36:09 +02:00
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)