#! C:\Perl\bin\perl.exe -w use strict; use File::Find (); use vars qw/*name *dir *prune/; *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; use Win32::FileSecurity qw(Get Set MakeMask); sub wanted; my %dhash; my %fhash; die "Usage: $0 \n" unless (@ARGV); die "Need dmask.txt file\n" unless (-r "C:\\dmask.txt"); die "Need fmask.txt file\n" unless (-r "C:\\fmask.txt"); open(IN,"<", 'c:\dmask.txt') || die "dmask.txt: $!\n"; while () { chomp; my ($id,@mask) = split(/\t/); $dhash{$id} = MakeMask(@mask); } close(IN); open(IN,"<", 'c:\fmask.txt') || die "fmask.txt: $!\n"; while () { chomp; my ($id,@mask) = split(/\t/); $fhash{$id} = MakeMask(@mask); } close(IN); # Traverse desired filesystems File::Find::find({wanted => \&wanted}, $ARGV[0]); exit; sub wanted { my %hash; if (-d $name) { if ( Get( $name, \%hash ) ) { my $fix = 0; foreach my $id (keys %dhash) { if ((! exists($hash{$id})) or ($hash{$id} != $dh ash{$id})) { $hash{$id} = $dhash{$id}; $fix = 1; } } if ($fix != 0) { Set( $name, \%hash); } } else { print( "Error #", int( $! ), ": $!" ) ; } } elsif (-f $name) { if ( Get( $name, \%hash ) ) { my $fix = 0; foreach my $id (keys %fhash) { if ((! exists($hash{$id})) or ($hash{$id} != $fh ash{$id})) { $hash{$id} = $fhash{$id}; $fix = 1; } } if ($fix != 0) { Set( $name, \%hash); } } else { print( "Error #", int( $! ), ": $!" ) ; } } }