Class: Inspec::Resources::LinuxUser
- Includes:
- CommentParser, PasswdParser
- Defined in:
- lib/resources/users.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from UnixUser
#id_cmd, #inspec, #list_users_cmd
Attributes inherited from UserInfo
Instance Method Summary collapse
Methods included from CommentParser
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, #identity, #initialize, #list_users, #user_details
Methods included from Converter
Constructor Details
This class inherits a constructor from Inspec::Resources::UnixUser
Instance Method Details
#credentials(username) ⇒ Object
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/resources/users.rb', line 412 def credentials(username) cmd = inspec.command("chage -l #{username}") return nil if cmd.exit_status != 0 params = SimpleConfig.new( cmd.stdout.chomp, assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/, group_re: nil, multiple_values: false, ).params { mindays: convert_to_i(params['Minimum number of days between password change']), maxdays: convert_to_i(params['Maximum number of days between password change']), warndays: convert_to_i(params['Number of days of warning before password expires']), } end |
#meta_info(username) ⇒ Object
401 402 403 404 405 406 407 408 409 410 |
# File 'lib/resources/users.rb', line 401 def (username) cmd = inspec.command("getent passwd #{username}") return nil if cmd.exit_status != 0 # returns: root:x:0:0:root:/root:/bin/bash passwd = parse_passwd_line(cmd.stdout.chomp) { home: passwd['home'], shell: passwd['shell'], } end |