CfgTie
view release on metacpan or search on metacpan
lib/CfgTie/TieShadow.pm view on Meta::CPAN
inactive=> '-f',
name => '-l',
shell => '-s',
group1 => '-g',
groups => '-G',
id => '-u',
};
my $shadowmod_opt2 =
{
id => '-o',
};
my $shadowmod = '/usr/sbin/shadowmod'; #Hard path to shadowmod
my $shadowdel = '/usr/sbin/shadowdel'; #Hard path to shadowdel
sub STORE
{
# Changes a setting for the specified shadow... we basically call shadowmod
my ($self,$key,$val) = @_;
my $lkey = lc($key);
if ($lkey eq 'groups')
{
#Handle the groups thing...
#$val is a list reference....
my ($i,@g) = @{$val};
system "$shadowmod $self->{name} -g $i -G ". join(',', @g);
}
elsif (exists $shadowmod_opt->{$lkey})
{
#This is something for shadow mod!
my ($FSUp, @FSet)=(0);
if (defined $CfgTie::TieShadow'Chg_FS && $shadow'Chg_FS == 1 &&
$lkey eq 'id')
{
#We are supposed to change all of the files in the system to
#have the new new one.
#We have a race condition: someone else may change soemthing in
#the file system, so we may not get everything, but we try to
#be reasonable
# Now we need to identify all of the files.. this may take a
# long time
@FSet= &CfgTie::filever'find_by_user ('/', $self->{id});
if (@FSet && scalar @FSet) {$FSUp = 1;}
}
my $X = $shadowmod_opt2->{$lkey};
if (!defined $X) {$X='';}
#Change the system tables
system "$shadowmod ".$shadowmod_opt->{$lkey}." $val $X ".$self->{name}.
"\n";
#If bad things should throw exception
if ($FSUp) {chown $val,-1, @FSet;}
$self->{$lkey} = $val;
}
else
{
#Extra setting that will be lost... 8(
$self->{$lkey}=$val;
}
}
sub DELETE
{
#Deletes a shadow setting
my ($self, $key) = @_;
my $lkey=lc($key);
if ($key eq 'authmethod')
{
system "$shadowmod -A DEFAULT ".$self->{name};
}
elsif (exists $shadowmod_opt->{$key})
{
#This is something for shadow mod!
system "$shadowmod ".$shadowmod_opt->{$lkey}." ".$self->{name};
}
else
{
#Just remove our local copy
delete $self->{$lkey};
}
}
( run in 2.988 seconds using v1.01-cache-2.11-cpan-364913b4093 )