Manpage of FileSecurity::FileSecurity
use Win32::FileSecurity;
DELETE, 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
# 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( $! ), ": $!" ) ;
}
}
# 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 ) ;
}
MakeMask( qw( FULL ) ); # for files
MakeMask( qw( READ GENERIC_READ GENERIC_EXECUTE ) ); # for directories
MakeMask( qw( CHANGE ) ); # for files
MakeMask( qw( CHANGE GENERIC_WRITE GENERIC_READ GENERIC_EXECUTE ) ); # for directories
MakeMask( qw( ADD GENERIC_READ GENERIC_EXECUTE ) ); # for directories only!
MakeMask( qw( FULL ) ); # for files
MakeMask( qw( FULL GENERIC_ALL ) ); # for directories
(thanks to Guert Schimmel at Sybase for turning me on to this one)
Fix unitialized vars on unknown ACLs <jmk@exc.bybyte.de>
May need to rethink...
Added ISA exporter, and @EXPORT_OK
Added F, FULL, R, READ, C, CHANGE as composite pre-built mask names.
Added server\ to keys returned in hash from Get
Made constants and MakeMask case insensitive (I don't know why I did that)
Fixed mask comparison in ListDacl and Enumerate Rights from simple & mask to exact bit match ! ( ( x & y ) ^ x ) makes sure all bits in x are set in y
Fixed some ``wild'' pointers
Included ListDacl.exe in bundle for debugging
Added ``intuitive'' inheritance for directories, basically functions like FM triggered by presence of GENERIC_ rights this may need to change
see EXAMPLE2
Changed from AddAccessAllowedAce to AddAce for control over inheritance
Using AddAccessAllowedAce
Suitable for file permissions