Win32::FileSecurity doesn't show all perms?

From: perl coder (perlcdr_at_mail.rumania)
Date: 04/02/04


Date: Fri, 02 Apr 2004 03:23:08 GMT

I'm trying to use Win32::FileSecurity to view file permissions on a
Windows XP machine. Here's my code:

use Win32::FileSecurity;
use Data::Dumper;

$file = shift @ARGV or die "Usage: $0 <filename>\n";

%perms = ();
Win32::FileSecurity::Get($file, \%perms) or die $!;
print "NTFS DACLS:\n";
print Dumper(\%perms);
foreach $user (keys %perms) {
        @rights = ();
        Win32::FileSecurity::EnumerateRights($perms{$user}, \@rights);
        print " *** $user : ", join(' ', @rights), "\n";
}

The script runs without errors, but it only shows permissions for 3
users. It doesn't show any perms for 'Everyone' and 'Power Users'. I
have no idea why... Here's some sample output:

NTFS DACLS:
$VAR1 = {
          'BUILTIN\\Administrators' => 2032127,
          'NT AUTHORITY\\SYSTEM' => 2032127,
          'CRASHME\\mm' => 2032127
        };
 *** BUILTIN\Administrators : DELETE READ_CONTROL WRITE_DAC WRITE_OWNER
 SYNCHRONIZE STANDARD_RIGHTS_REQUIRED STANDARD_RIGHTS_READ
 STANDARD_RIGHTS_WRITE STANDARD_RIGHTS_EXECUTE STANDARD_RIGHTS_ALL
 READ CHANGE ADD FULL
 *** NT AUTHORITY\SYSTEM : DELETE READ_CONTROL WRITE_DAC WRITE_OWNER
 SYNCHRONIZE STANDARD_RIGHTS_REQUIRED STANDARD_RIGHTS_READ
 STANDARD_RIGHTS_WRITE STANDARD_RIGHTS_EXECUTE STANDARD_RIGHTS_ALL READ
 CHANGE ADD FULL
 *** CRASHME\mm : DELETE READ_CONTROL WRITE_DAC WRITE_OWNER SYNCHRONIZE
 STANDARD_RIGHTS_REQUIRED STANDARD_RIGHTS_READ STANDARD_RIGHTS_WRITE
 STANDARD_RIGHTS_EXECUTE STANDARD_RIGHTS_ALL READ CHANGE ADD FULL

Ultimately I want to use this code to find out if a given user has read
access to a given file. For instance, I may wish to know if user 'fred'
can read the file "C:\Documents and Settings\joe\my_precious.txt", and
with the above code I won't be able to know because 'fred' would fall in
the 'Everyone' group, which isn't listed. :-(

Oh, one last question, while I'm on a roll. ;-) I'm very new to the
Windows world, and have almost zero understanding of the ACL system.
I've tried reading various docs and googling around but haven't found
much good info. But what I understand so far is that if someone has
READ access to a file, they can view the data inside. Is this correct?
Or do they also need GENERIC_READ access as well?

-- 
No crazy stuff in my email. ;-)


Relevant Pages

  • Re: Prevent Word Pad from saving docs?
    ... a FAT partition and later converted to NTFS, the file permissions are not ... but the same thing could possibly be true if Windows 2000 ... was installed on a pre-existing NTFS partition such as if Windows NT or 2000 ... it's worth noting that when you do a clean install ...
    (microsoft.public.win2000.security)
  • Re: Restrict access to external drive
    ... Is the External Drive formatted as NTFS? ... boot into Safe Mode to set NTFS file permissions but I am not sure if the ... How to set, view, change, or remove file and folder permissions in Windows ... default user folders. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Alternate data Streams
    ... Search For Hidden Or System Files In Windows XP ... NTFS formatted, and all retain the ADS when files are copied between ... Alternate Data Streams are pieces of info hidden as metadata on ...
    (microsoft.public.windowsxp.general)
  • Re: RosAsm - right click
    ... (about HPFS but NTFS is an "evolved" version of HPFS) ... reduce the distance the read / writes heads have to travel...but ... But it's the most stable Windows there is...note, ... etc....much like a very simple assembler ...
    (alt.lang.asm)
  • Re: msblast virus
    ... time malware goes active on the PC. ... firewall switched on (which may bonk your LAN connectivity, ... > Windows partitions, then create a new partition, then format the primary ... Reconsider that "preferably NTFS" bit. ...
    (microsoft.public.windowsxp.security_admin)