class Etc::Passwd

Passwd is a placeholder Struct for user database on Unix systems.

The struct contains the following members

name

contains the short login name of the user as a String.

passwd

contains the encrypted password of the user as a String. an 'x' is returned if shadow passwords are in use. An '*' is returned if the user cannot log in using a password.

uid

contains the integer user ID (uid) of the user.

gid

contains the integer group ID (gid) of the user’s primary group.

dir

contains the path to the home directory of the user as a String.

shell

contains the path to the login shell of the user as a String.

The following members below are system-dependent

gecos

contains a longer String description of the user, such as a full name. Some Unix systems provide structured information in the gecos field, but this is system-dependent.

change

password change time(integer).

quota

quota value(integer).

age

password age(integer).

class

user access class(string).

comment

comment(string).

expire

account expiration time(integer).

Public Class Methods

Etc::Passwd.each { |struct| block } → Etc::Passwd
Etc::Passwd.each → Enumerator

Iterates for each entry in the /etc/passwd file if a block is given.

If no block is given, returns the Enumerator.

The code block is passed an Passwd struct.

See Etc.getpwent above for details.

Example:

require 'etc'

Etc::Passwd.each {|u|
  puts u.name + " = " + u.gecos
}

Etc::Passwd.collect {|u| u.gecos}
Etc::Passwd.collect {|u| u.gecos}
static VALUE
etc_each_passwd(VALUE obj)
{
#ifdef HAVE_GETPWENT
    RETURN_ENUMERATOR(obj, 0, 0);
    each_passwd();
#endif
    return obj;
}