Class: Passwd

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ContentParser

#parse_comment_line, #parse_passwd, #parse_passwd_line

Constructor Details

#initialize(path = nil) ⇒ Passwd

Returns a new instance of Passwd.



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

def initialize(path = nil)
  @path = path || '/etc/passwd'
  @content = inspec.file(@path).content
  @parsed = parse_passwd(@content)
end

Instance Attribute Details

#parsedObject (readonly)

Returns the value of attribute parsed.



36
37
38
# File 'lib/resources/passwd.rb', line 36

def parsed
  @parsed
end

#uid(uid) ⇒ Object (readonly)

call passwd().uid(0) returns a seperate object with reference to this object



46
47
48
# File 'lib/resources/passwd.rb', line 46

def uid
  @uid
end

Instance Method Details

#gidsObject



62
63
64
# File 'lib/resources/passwd.rb', line 62

def gids
  map_data('gid')
end

#passwordsObject



54
55
56
# File 'lib/resources/passwd.rb', line 54

def passwords
  map_data('password')
end

#to_sObject



66
67
68
# File 'lib/resources/passwd.rb', line 66

def to_s
  '/etc/passwd'
end

#uidsObject



58
59
60
# File 'lib/resources/passwd.rb', line 58

def uids
  map_data('uid')
end

#usernamesObject



50
51
52
# File 'lib/resources/passwd.rb', line 50

def usernames
  map_data('name')
end