CfgTie

 view release on metacpan or  search on metacpan

lib/CfgTie/TieUser.pm  view on Meta::CPAN

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.

=head2 Configuration Variables

=head2 Additional Routines

=over 1

=item C<&CfgTie::TieUser'stat()>

=item C<&CfgTie::TieUser_id'stat()>

Will return C<stat>-like statistics information on the user database.

=back

=head2 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>";
   }

If, instead, you wanted to add your own keys to the user records, 
C<CfgTie::TieUser::add_scalar(>I<$Name>,I<$Package>C<)>
Lets you add scalar keys to user records.  The I<Name> specifies the key name
to be used; it will be made case-insensitve.  The I<Package> specifies the name
of the package to be used when tie'ing the key to a value.  (The C<TIESCALAR>
is passed the user id as a parameter).

C<CfgTie::TieUser::add_hash(>I<$Name>,I<$Package>C<)>
Lets you add hash keys to user records.  The I<Name> specifies the key name
to be used; it will be made case insensitve.  The I<Package> specifies the name
of the package to be used when tie'ing the key to a value.  (The C<TIEHASH>
is passed the user id as a parameter).

=head2 Miscellaneous

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

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

C<$CfgTie::TieUser_rec'userdel> contains the path to the program F<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.

=head2 When the changes are reflected to /etc/passwd

=head1 Files

F</etc/passwd>
F</etc/group>
F</etc/shadow>

=head1 See Also

L<CfgTie::Cfgfile>, L<CfgTie::TieAliases>,  L<CfgTie::TieGeneric>,
L<CfgTie::TieGroup>,L<CfgTie::TieHost>,     L<CfgTie::TieMTab>,
L<CfgTie::TieNamed>,L<CfgTie::TieNet>,      L<CfgTie::TiePh>,
L<CfgTie::TieProto>,L<CfgTie::TieRCService>,L<CfgTie::TieRsrc>,
L<CfgTie::TieServ>, L<CfgTie::TieShadow>

L<group(5)>,
L<passwd(5)>,
L<shadow(5)>,
L<usermod(8)>,
L<useradd(8)>,
L<userdel(8)>

=head1 Caveats

The current version does cache some user information.

=head1 Author

Randall Maas (L<randym@acm.org>)

=cut

my $Chg_FS = 1; #By default we want to update the file system when the user
# Id changes

sub stat($)
{
  # the information for the /etc/passwd file
  stat '/etc/passwd';
}

sub TIEHASH
{
   my $self = shift;
   my $node = {};
   return bless $node, $self;
}

sub FIRSTKEY
{
   my $self = shift;

   #Rewind outselves to the beginning.
   setpwent;

   &NEXTKEY($self);
}



( run in 4.192 seconds using v1.01-cache-2.11-cpan-9789f410c06 )