Class: 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) ⇒ Passwd

Returns a new instance of Passwd.



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

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.



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

def parsed
  @parsed
end

#uid(uid) ⇒ Object (readonly)

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



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

def uid
  @uid
end

Instance Method Details

#gidsObject



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

def gids
  map_data('gid')
end

#passwordsObject



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

def passwords
  map_data('password')
end

#to_sObject



73
74
75
# File 'lib/resources/passwd.rb', line 73

def to_s
  '/etc/passwd'
end

#uidsObject



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

def uids
  map_data('uid')
end

#usernamesObject



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

def usernames
  map_data('name')
end