class Inspec::Resources::EtcFstab

Attributes

params[R]

Public Class Methods

new(fstab_path = nil) click to toggle source
# File lib/inspec/resources/etc_fstab.rb, line 31
def initialize(fstab_path = nil)
  @conf_path      = fstab_path || "/etc/fstab"
  @files_contents = {}
  @content        = nil
  @params         = nil
  read_content
end

Public Instance Methods

home_mount_options() click to toggle source
# File lib/inspec/resources/etc_fstab.rb, line 54
def home_mount_options
  return nil unless where { mount_point == "/home" }.configured?

  where { mount_point == "/home" }.entries[0].mount_options
end
nfs_file_systems() click to toggle source
# File lib/inspec/resources/etc_fstab.rb, line 50
def nfs_file_systems
  where { file_system_type.match(/nfs/) }
end
to_s() click to toggle source
# File lib/inspec/resources/etc_fstab.rb, line 60
def to_s
  "File System Table File (fstab)"
end

Private Instance Methods

parse_conf(content) click to toggle source
# File lib/inspec/resources/etc_fstab.rb, line 73
def parse_conf(content)
  content.map do |line|
    data, = parse_comment_line(line, comment_char: "#", standalone_comments: false)
    parse_line(data) unless data == ""
  end.compact
end
parse_line(line) click to toggle source
# File lib/inspec/resources/etc_fstab.rb, line 80
def parse_line(line)
  attributes = line.split
  {
    "device_name" => attributes[0],
    "mount_point" => attributes[1],
    "file_system_type" => attributes[2],
    "mount_options" => attributes[3].split(","),
    "dump_options" => attributes[4].to_i,
    "file_system_options" => attributes[5].to_i,
  }
end
read_content() click to toggle source
# File lib/inspec/resources/etc_fstab.rb, line 66
def read_content
  @content = ""
  @params  = {}
  @content = read_file(@conf_path)
  @params  = parse_conf(@content)
end
read_file(conf_path = @conf_path) click to toggle source
# File lib/inspec/resources/etc_fstab.rb, line 92
def read_file(conf_path = @conf_path)
  read_file_content(conf_path).lines
end