Class: Inspec::Resources::Passwd

Inherits:
Object
  • Object
show all
Includes:
FileReader, Utils::PasswdParser
Defined in:
lib/inspec/resources/passwd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FileReader

#read_file_content

Methods included from Utils::PasswdParser

#parse_passwd, #parse_passwd_line

Constructor Details

#initialize(path = nil, opts = nil) ⇒ Passwd

Returns a new instance of Passwd.



43
44
45
46
47
48
49
# File 'lib/inspec/resources/passwd.rb', line 43

def initialize(path = nil, opts = nil)
  opts ||= {}
  @path = path || "/etc/passwd"
  @content = opts[:content] || read_file_content(@path, allow_empty: true)
  @lines = @content.to_s.split("\n")
  @params = parse_passwd(@content)
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



40
41
42
# File 'lib/inspec/resources/passwd.rb', line 40

def content
  @content
end

#linesObject (readonly)

Returns the value of attribute lines.



41
42
43
# File 'lib/inspec/resources/passwd.rb', line 41

def lines
  @lines
end

#paramsObject (readonly)

Returns the value of attribute params.



39
40
41
# File 'lib/inspec/resources/passwd.rb', line 39

def params
  @params
end

Instance Method Details

#to_sObject



69
70
71
# File 'lib/inspec/resources/passwd.rb', line 69

def to_s
  "/etc/passwd"
end