Type:
Module
Constants:
Passwd : Define-const

Passwd

Passwd is a Struct that 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 optional, and must be compiled with special flags:

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. must be compiled with HAVE_ST_PW_GECOS

change

password change time(integer) must be compiled with HAVE_ST_PW_CHANGE

quota

quota value(integer) must be compiled with HAVE_ST_PW_QUOTA

age

password age(integer) must be compiled with HAVE_ST_PW_AGE

class

user access class(string) must be compiled with HAVE_ST_PW_CLASS

comment

comment(string) must be compiled with HAVE_ST_PW_COMMENT

expire

account expiration time(integer) must be compiled with HAVE_ST_PW_EXPIRE

Group : Define-const

Group

Group is a Struct that is only available when compiled with HAVE_GETGRENT.

The struct contains the following members:

name

contains the name of the group as a String.

passwd

contains the encrypted password as a String. An 'x' is returned if password access to the group is not available; an empty string is returned if no password is needed to obtain membership of the group.

Must be compiled with HAVE_ST_GR_PASSWD.

gid

contains the group's numeric ID as an integer.

mem

is an Array of Strings containing the short login names of the members of the group.

The Etc module provides access to information typically stored in files in the /etc directory on Unix systems.

The information accessible consists of the information found in the /etc/passwd and /etc/group files, plus information about the system's temporary directory (/tmp) and configuration directory (/etc).

The Etc module provides a more reliable way to access information about the logged in user than environment variables such as +$USER+.

Example:

require 'etc'

login = Etc.getlogin
info = Etc.getpwnam(login)
username = info.gecos.split(/,/).first
puts "Hello #{username}, I see your login name is #{login}"

Note that the methods provided by this module are not always secure. It should be used for informational purposes, and not for security.

All operations defined in this module are class methods, so that you can include the Etc module into your class.

getgrent

getgrent() Class Public methods Returns an entry from the /etc/group file.

2015-04-05 12:06:23
getpwuid

getpwuid(uid) â Passwd Class Public methods Returns the /etc/passwd

2015-04-05 12:35:23
getlogin

getlogin â String Class Public methods Returns the short user name of

2015-04-05 12:24:16
group

group() Class Public methods Provides a convenient Ruby iterator which executes

2015-04-05 12:41:34
endpwent

endpwent() Class Public methods Ends the process of scanning through the /etc/passwd

2015-04-05 12:05:01
getpwnam

getpwnam(name) â Passwd Class Public methods Returns the /etc/passwd

2015-04-05 12:29:49
setpwent

setpwent() Class Public methods Resets the process of reading the /etc/passwd

2015-04-05 12:53:35
getgrgid

getgrgid(group_id) â Group Class Public methods Returns information

2015-04-05 12:13:49
getpwent

getpwent() Class Public methods Returns an entry from the /etc/passwd file.

2015-04-05 12:25:31
passwd

Etc.passwd { |struct| block } â PasswdEtc.passwd â Passwd Class Public methods

2015-04-05 12:42:55