123456789_123456789_123456789_123456789_123456789_

Class: Etc::Passwd

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Enumerable, ::Struct
Instance Chain:
self, ::Struct
Inherits: Struct
Defined in: ext/etc/etc.c

Overview

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).

Class Method Summary

Class Method Details

.each {|struct| ... } ⇒ Passwd .eachEnumerator

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}
[ GitHub ]

  
# File 'ext/etc/etc.c', line 372

static VALUE
etc_each_passwd(VALUE obj)
{
#ifdef HAVE_GETPWENT
    RETURN_ENUMERATOR(obj, 0, 0);
    each_passwd();
#endif
    return obj;
}