Module: Inspec::Utils::PasswdParser
- Included in:
- Resources::FreeBSDUser, Resources::LinuxUser, Resources::Passwd
- Defined in:
- lib/inspec/utils/parser.rb
Instance Method Summary collapse
-
#parse_passwd(content) ⇒ Array
Parse /etc/passwd files.
-
#parse_passwd_line(line) ⇒ Hash
Parse a line of /etc/passwd.
Instance Method Details
#parse_passwd(content) ⇒ Array
Parse /etc/passwd files.
10 11 12 13 14 15 16 |
# File 'lib/inspec/utils/parser.rb', line 10 def parse_passwd(content) content.to_s.split("\n").map do |line| next if line[0] == "#" parse_passwd_line(line) end.compact end |
#parse_passwd_line(line) ⇒ Hash
Parse a line of /etc/passwd
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/inspec/utils/parser.rb', line 22 def parse_passwd_line(line) x = line.split(":") { # rubocop:disable Layout/AlignHash "user" => x[0], "password" => x[1], "uid" => x[2], "gid" => x[3], "desc" => x[4], "home" => x[5], "shell" => x[6], } end |