App-Slaughter
view release on metacpan or search on metacpan
lib/Slaughter/API/generic.pm view on Meta::CPAN
return -2 if ( !defined($uid) );
$::verbose && print "Owner:$owner -> UID:$uid\n";
}
# invalid group?
if ( defined($group) )
{
$gid = getgrnam($group);
return -2 if ( !defined($gid) );
$::verbose && print "Group:$group -> GID:$gid\n";
}
my $changed = 0;
if ( $params{ 'Owner' } )
{
#
# Find the current UID/GID of the file, so we
# can change just the owner.
#
my ( $dev, $ino, $mode, $nlink, $orig_uid,
$orig_gid, $rdev, $size, $atime, $mtime,
$ctime, $blksize, $blocks
)
= stat($file);
$::verbose && print "\tSetting owner to $owner/$uid\n";
chown( $uid, $orig_gid, $file );
$changed += 1;
}
if ( $params{ 'Group' } )
{
#
# Find the current UID/GID of the file, so we
# can change just the group.
#
my ( $dev, $ino, $mode, $nlink, $orig_uid,
$orig_gid, $rdev, $size, $atime, $mtime,
$ctime, $blksize, $blocks
)
= stat($file);
$::verbose && print "\tSetting group to $group/$gid\n";
chown( $orig_uid, $gid, $file );
$changed += 1;
}
if ( $params{ 'Mode' } )
{
$::verbose && print "\tSetting mode to $mode\n";
my $mode = $params{ 'Mode' };
if ( $mode !~ /^0/ )
{
$mode = oct("0$mode");
$::verbose && print "\tOctal mode is now $mode\n";
}
chmod( $mode, $file );
$changed += 1;
}
return ($changed);
}
=head2 UserDetails
This primitive will return a hash of data about the local Unix user
specified, if it exists.
=for example begin
if ( UserExists( User => "skx" ) )
{
my %data = UserDetails( User => "skx" );
}
=for example end
The following parameters are available:
=over
=item User [mandatory]
The unix username to retrieve details of.
=back
The return value of this function is a hash of data conprising of the
following Keys/Values
=over
=item Home
The user's home directory
=item UID
The user's UID
=item GID
The user's GID
=item Quota
The user's quota.
=item Comment
The user's comment
=item Shell
The user's login shell.
( run in 0.636 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )