Method: PasswdParser#parse_passwd_line

Defined in:
lib/inspec/utils/parser.rb

#parse_passwd_line(line) ⇒ Hash

Parse a line of /etc/passwd

Parameters:

  • line (String)

    a line of /etc/passwd

Returns:

  • (Hash)

    Map of entries in this line



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/inspec/utils/parser.rb', line 20

def parse_passwd_line(line)
  x = line.split(":")
  {
    "user" => x.at(0),
    "password" => x.at(1),
    "uid" => x.at(2),
    "gid" => x.at(3),
    "desc" => x.at(4),
    "home" => x.at(5),
    "shell" => x.at(6),
  }
end