Class: Inspec::Resources::FreeBSDUser

Inherits:
UnixUser show all
Includes:
Utils::PasswdParser
Defined in:
lib/inspec/resources/users.rb

Overview

FreeBSD recommends to use the ‘pw’ command for user management @see: www.freebsd.org/doc/handbook/users-synopsis.html @see: www.freebsd.org/cgi/man.cgi?pw(8) It offers the following commands:

  • adduser(8) The recommended command-line application for adding new users.

  • rmuser(8) The recommended command-line application for removing users.

  • chpass(1) A flexible tool for changing user database information.

  • passwd(1) The command-line tool to change user passwords.

Instance Attribute Summary

Attributes inherited from UnixUser

#id_cmd, #inspec, #list_users_cmd

Attributes inherited from UserInfo

#inspec

Instance Method Summary collapse

Methods included from Utils::PasswdParser

#parse_passwd, #parse_passwd_line

Methods inherited from UnixUser

#identity, #initialize, #list_users, #parse_id_entries, #parse_value

Methods inherited from UserInfo

#collect_user_details, #credentials, #identity, #initialize, #list_users, #user_details

Methods included from Converter

#convert_to_i, to_boolean

Constructor Details

This class inherits a constructor from Inspec::Resources::UnixUser

Instance Method Details

#meta_info(username) ⇒ Object



677
678
679
680
681
682
683
684
685
686
687
# File 'lib/inspec/resources/users.rb', line 677

def meta_info(username)
  cmd = inspec.command("pw usershow #{username} -7")
  return nil if cmd.exit_status != 0

  # returns: root:*:0:0:Charlie &:/root:/bin/csh
  passwd = parse_passwd_line(cmd.stdout.chomp)
  {
    home: passwd["home"],
    shell: passwd["shell"],
  }
end