Class: OsCtld::Assets::CgroupDeviceList
- Includes:
- OsCtl::Lib::Utils::Log, OsCtl::Lib::Utils::System
- Defined in:
- lib/osctld/assets/cgroup_device_list.rb
Overview
Check cgroupv1 devices.list
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(cgroup_path, opts) ⇒ CgroupDeviceList
constructor
A new instance of CgroupDeviceList.
- #validate(_run) ⇒ Object protected
Methods inherited from Base
#add_error, #prefetch_zfs, register, #run_validation, #state, #type, #valid?, #validate?, #validate_block
Constructor Details
#initialize(cgroup_path, opts) ⇒ CgroupDeviceList
Returns a new instance of CgroupDeviceList.
13 14 15 |
# File 'lib/osctld/assets/cgroup_device_list.rb', line 13 def initialize(cgroup_path, opts) # rubocop:disable all super end |
Instance Method Details
#validate(_run) ⇒ Object (protected)
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/osctld/assets/cgroup_device_list.rb', line 19 def validate(_run) begin devices_list = File.read(File.join(path, 'devices.list')) rescue Errno::ENOENT add_error("devices.list not found in cgroup #{path.inspect}") end cgroup_devices = devices_list.strip.split("\n") allowed_devices = opts[:devices].map(&:to_s) allowed_devices.delete_if do |dev| if cgroup_devices.delete(dev) true else add_error("device #{dev.inspect} not allowed") false end end cgroup_devices.each do |dev| add_error("device #{dev.inspect} allowed, but not configured") end end |