Class: Inspec::Resources::Passwd

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PasswdParser

#parse_passwd, #parse_passwd_line

Constructor Details

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

Returns a new instance of Passwd.



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

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

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



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

def content
  @content
end

#linesObject (readonly)

Returns the value of attribute lines.



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

def lines
  @lines
end

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

Instance Method Details

#to_sObject



92
93
94
# File 'lib/resources/passwd.rb', line 92

def to_s
  '/etc/passwd'
end

#uid(x) ⇒ Object



85
86
87
88
# File 'lib/resources/passwd.rb', line 85

def uid(x)
  warn '[DEPRECATION] `passwd.uid(arg)` is deprecated. Please use `passwd.uids(arg)` instead. It will be removed in the next major version.'
  uids(x)
end