ActivePerl Documentation
|
NAMEWin32::FileSecurity - manage FileSecurity Discretionary Access Control Lists in perl
SUPPORTED PLATFORMS
SYNOPSIS
use Win32::FileSecurity;
DESCRIPTIONThis module offers control over the administration of system FileSecurity DACLs. You may want to use Get and EnumerateRights to get an idea of what mask values correspond to what rights as viewed from File Manager.
CONSTANTSDELETE, READ_CONTROL, WRITE_DAC, WRITE_OWNER, SYNCHRONIZE, STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_READ, STANDARD_RIGHTS_WRITE, STANDARD_RIGHTS_EXECUTE, STANDARD_RIGHTS_ALL, SPECIFIC_RIGHTS_ALL, ACCESS_SYSTEM_SECURITY, MAXIMUM_ALLOWED, GENERIC_READ, GENERIC_WRITE, GENERIC_EXECUTE, GENERIC_ALL, F, FULL, R, READ, C, CHANGE
FUNCTIONS
NOTE:All of the functions return FALSE (0) if they fail, unless otherwise noted.
Errors returned via $! containing both Win32
%permisshashEntries take the form $permisshash{USERNAME} = $mask ;
EXAMPLE1
# Gets the rights for all files listed on the command line.
use Win32::FileSecurity qw(Get EnumerateRights);
foreach( @ARGV ) {
next unless -e $_ ;
if ( Get( $_, \%hash ) ) {
while( ($name, $mask) = each %hash ) {
print "$name:\n\t";
EnumerateRights( $mask, \@happy ) ;
print join( "\n\t", @happy ), "\n";
}
}
else {
print( "Error #", int( $! ), ": $!" ) ;
}
}
EXAMPLE2
# Gets existing DACL and modifies Administrator rights
use Win32::FileSecurity qw(MakeMask Get Set);
# These masks show up as Full Control in File Manager
$file = MakeMask( qw( FULL ) );
$dir = MakeMask( qw(
FULL
GENERIC_ALL
) );
foreach( @ARGV ) {
s/\\$//;
next unless -e;
Get( $_, \%hash ) ;
$hash{Administrator} = ( -d ) ? $dir : $file ;
Set( $_, \%hash ) ;
}
COMMON MASKS FROM CACLS AND WINFILE
READ
MakeMask( qw( FULL ) ); # for files
MakeMask( qw( READ GENERIC_READ GENERIC_EXECUTE ) ); # for directories
CHANGE
MakeMask( qw( CHANGE ) ); # for files
MakeMask( qw( CHANGE GENERIC_WRITE GENERIC_READ GENERIC_EXECUTE ) ); # for directories
ADD & READ
MakeMask( qw( ADD GENERIC_READ GENERIC_EXECUTE ) ); # for directories only!
FULL
MakeMask( qw( FULL ) ); # for files
MakeMask( qw( FULL GENERIC_ALL ) ); # for directories
RESOURCES
(thanks to Guert Schimmel at Sybase for turning me on to this one)
VERSION1.03 ALPHA 97-12-14
REVISION NOTES
KNOWN ISSUES / BUGS
|