Class: Inspec::Resources::LinuxUser
- Includes:
- CommentParser, PasswdParser
- Defined in:
- lib/resources/user.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from UnixUser
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, #parse_id_entries, #parse_value
Methods inherited from UserInfo
Methods included from Converter
Constructor Details
This class inherits a constructor from Inspec::Resources::UnixUser
Instance Method Details
#credentials(username) ⇒ Object
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/resources/user.rb', line 259 def credentials(username) cmd = inspec.command("chage -l #{username}") return nil if cmd.exit_status != 0 params = SimpleConfig.new( cmd.stdout.chomp, assignment_re: /^\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
248 249 250 251 252 253 254 255 256 257 |
# File 'lib/resources/user.rb', line 248 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 |