NAME

CfgTie::TieUser -- an associative array of user names and ids to information

SYNOPSIS

makes the user database available as a regular hash

tie %user,'CfgTie::TieUser'
print "randym's full name: ", $user{'randym'}->{gcos}, "\n";

DESCRIPTION

This is a straight forward HASH tie that allows us to access the user database sanely.

It cross ties with the groups packages and the mail packages

Ties

There are two ties available for programers:

tie %user,'CfgTie::TieUser'

$user{$name} will return a HASH reference of the named user information

tie %user_id,'CfgTie::TieUser_id'

$user_id{$id} will return a HASH reference for the specified user.

Structure of hash

Any given user entry has the following information assoicated with it (the keys are case insensitive):

Name

Login name

GroupId
Id

The user id number that they have been assigned. It is possible for many different user names to given the same id. However, changing the Id for the user (ie, setting it to a new one), has one of two effects. If user'Chg_FS is set 1, then all the files in the system owned by that id will changed to the new id in addition to changing the id in the system table. Otherwise, only the system table will be modified.

Quota
Comment
Home

The users home folder

LOGIN_Last

This is the information from the last time the user logged in. It is an array reference to data like:

[$time, $line, $from_host]
Shell

The users shell

AuthMethod

The authentication method if other than the default

ExpireDate

The date the account expires on

Inactive

The number of days after a password expires.s...

Priority

The scheduling priority for that user.

Plus two (probably) obsolete fields:

Password

This is the encrypted password, but will probably be obsolete

GCOS

General Electric Comprehensive Operating System or General Comprehensive Operating System field

This is now the users full name under many Unix's, incl. LINUX.

Each of these entries can be modified (even deleted), and they will be reflected into the overall system. Additionally, the programmer can set any other associated key, but this information will only available to running PERL script.

Configuration Variables

Additional Routines

&CfgTie::TieUser'status()
&CfgTie::TieUser_id'status()

Will return stat information on the user database.

Adding or overiding methods for user records

Lets say you wanted to change the default HTML handling to a different method. To do this you need only include code like the following:

package CfgTie::TieUser_rec;
sub HTML($)
{
   my $self=shift;
   "<h1>".$Self->{name}."</h1>\n".
   "<table border=0><tr><th align=right>\n".
     join("</td></tr>\n<tr><th align=right>",
       map {$_."</th><td>".$self->{$_}} (sort keys %{$self})
    </td></tr><lt></table>C<\n>";
}

Miscellaneous

$CfgTie::TieUser_rec'usermod contains the path to the program usermod. This can be modified as required.

$CfgTie::TieUser_rec'useradd contains the path to the program useradd. This can be modified as required.

$CfgTie::TieUser_rec'userdel contains the path to the program userdel. This can be modified as required.

Not all keys are supported on all systems.

This may transparently use a shadow tie in the future.

Files

/etc/passwd /etc/group /etc/shadow

See Also

Cfgfile, CfgTie::TieAliases, CfgTie::TieGeneric, CfgTie::TieGroup, CfgTie::TieHost, CfgTie::TieNamed, CfgTie::TieNet, CfgTie::TiePh, CfgTie::TieProto, CfgTie::TieServ, CfgTie::TieShadow

group(5), passwd(5), shadow(5), usermod(8), useradd(8), userdel(8)

Cavaets

The current version does cache some user information

Author

Randall Maas (randym@acm.org)