|
CfgTie::TieUser -- an associative array of user names and ids to information |
CfgTie::TieUser -- an associative array of user names and ids to information
makes the user database available as a regular hash.
tie %user,'CfgTie::TieUser'
print "randym's full name: ", $user{'randym'}->{gcos}, "\n";
This is a straightforward hash tie that allows us to access the user database sanely.
It cross ties with the groups packages and the mail packages
There are two ties available for programmers:
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.
Any given user entry has the following information associated with it (the keys are case-insensitive):
NameGroupIdIduser'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.
CommentHomeLOGIN_Last
[$time, $line, $from_host]
ShellAuthMethodExpireDateInactivePriorityBSD::Resource be installed.)
QuotaRUsageBSD::Resource be installed.
Returns a list reference of the form:
[$usertime, $systemtime, $maxrss, $ixrss, $idrss, $isrss, $minflt,
$majflt, $nswap, $inblock, $oublock, $msgsnd, $msgrcv, $nsignals,
$nvcsw, $nivcsw]
Plus two (probably) obsolete fields:
PasswordGCOSThis is now the user's full name under many Unix's, incl. Linux.
Each of these entries can be modified (even deleted), and they will be reflected in the overall system. Additionally, the programmer can set any other associated key, but this information will only be available to the running Perl script.
&CfgTie::TieUser'stat()&CfgTie::TieUser_id'stat()stat-like statistics information on the user database.
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>";
}
If, instead, you wanted to add your own keys to the user records,
CfgTie::TieUser::add_scalar($Name,$Package)
Lets you add scalar keys to user records. The Name specifies the key name
to be used; it will be made case-insensitve. The Package specifies the name
of the package to be used when tie'ing the key to a value. (The TIESCALAR
is passed the user id as a parameter).
CfgTie::TieUser::add_hash($Name,$Package)
Lets you add hash keys to user records. The Name specifies the key name
to be used; it will be made case insensitve. The Package specifies the name
of the package to be used when tie'ing the key to a value. (The TIEHASH
is passed the user id as a parameter).
$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.
/etc/passwd /etc/group /etc/shadow
the CfgTie::Cfgfile manpage, the CfgTie::TieAliases manpage, the CfgTie::TieGeneric manpage, the CfgTie::TieGroup manpage,the CfgTie::TieHost manpage, the CfgTie::TieMTab manpage, the CfgTie::TieNamed manpage,the CfgTie::TieNet manpage, the CfgTie::TiePh manpage, the CfgTie::TieProto manpage,the CfgTie::TieRCService manpage,the CfgTie::TieRsrc manpage, the CfgTie::TieServ manpage, the CfgTie::TieShadow manpage
group(5), passwd(5), shadow(5), usermod(8), useradd(8), userdel(8)
The current version does cache some user information.
Randall Maas (randym@acm.org)
|
CfgTie::TieUser -- an associative array of user names and ids to information |