The code I supplied above should work for you--it does for me. The significant bit is this

return unless eval{ Win32::FileSecurity::Get($_, \%users); 1 };

What that does is wrap the call that may (erroneously) die with the error you encountered in eval{ ... }.

In a nutshell, that traps the error and ignores it (and the file that caused the error to be skipped). You may like to try this version of your script.

#! perl -sw use strict; use File::Find; use Win32::FileSecurity; #determine the DACL mask for Full Access my $fullmask = Win32::FileSecurity::MakeMask('FULL'); &find(\&wanted,"\\"); my %users; sub wanted { # Win32::FileSecurity::Get does not like the paging file, skip it return if ($_ eq "pagefile.sys"); return unless -f $_; unless( eval{ Win32::FileSecurity::Get($_, \%users); 1 } ) { print "Attempt to get the ACLs for $_ failed with: \n", $@; print "Skipping ...\n"; return; } return unless defined $users{"Everyone"}; return unless $users{"Everyone"} == $fullmask; print "$File::Find::name\n"; }

An example of the errors that you might see and ignore is

Attempt to get the ACLs for drwtsn32.log failed with: Error handling error: 122, Dacl is NULL: implicit access grant at C:\t +est\junk2.pl Skipping ...

Which is saying that the file has no explicit ACL, so it is implicitly consider to be accessible by anyone. Ie. equivalent to be owned by Everyone.

You will need to interpret other errors as they arise according to the context in which you encounter them.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: Learning Perl Chap 2 Win32::FileSecurity Help by BrowserUk
in thread Learning Perl Chap 2 Win32::FileSecurity Help by punklrokk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.