Class: Inspec::Resources::FreeBSDUser

Inherits:
UnixUser show all
Includes:
PasswdParser
Defined in:
lib/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 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

Constructor Details

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

Instance Method Details

#meta_info(username) ⇒ Object



538
539
540
541
542
543
544
545
546
547
# File 'lib/resources/users.rb', line 538

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