Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: win32 ACL problem.

by blm (Hermit)
on Sep 24, 2002 at 11:46 UTC ( [id://200337]=note: print w/replies, xml ) Need Help??


in reply to win32 ACL problem.

Firstly you will want to change.

mkdir $cart||warn $!;

to

mkdir $cart or warn $!;

or

mkdir($cart) || warn $!;

Otherwise it doesn't warn ever.

Secondly the permissions show up as blank in properties/security/ because they are applied to "This folder only" if you look at properties/security/advance/view-modify. Change the "Apply onto:" setting by hitting View/Edit in properties/security/advance/ to eg "This folder, Subfolders and files" and the properties/security/ for that access control entry.

--blm--

Update: Fix missing semicolon.

Replies are listed 'Best First'.
Re: Re: win32 ACL problem.
by Discipulus (Canon) on Sep 24, 2002 at 12:11 UTC
    thanks for the warning explication.
    for the second thing: I wont access the property "This folder, Subfolders and files" via Perl and not via mouse!
    any idea?
    Thanks in any case..
    lorenzo*

      I get the feeling that Win32::FileSecurity tries to do the inheritance stuff automagically. I use Win32::Perms for my work as it seems to expose more functionality. Doing the same script with Win32::Perms seems not to have the same problems as the code you posted. Here is my Win32::Perms version:

      use Win32::Perms; $cart='TestingFolder'; mkdir $cart || warn $!; # Create a new Security Descriptor and auto import permissions # from the directory $Dir = new Win32::Perms( $cart ) || die; my @perms; my $perm; $Dir->Get(\@perms); my $index = 0; $Dir->Dump; do { $perm = $perms[$index]; } while ($perm->{'Account'} ne 'Everyone') and (++$index); # One of three ways to remove an ACE print ($Dir->Remove($index)); $Dir->Set(); $Dir->Dump;
      --blm--

      ps you may notice that I don't use $Dir->Remove('Everyone'), This is because I could not get it to delete any ACEs. So I compute the index of the ACE in the ACL and delete based on that. I will investigate this further.

        I made mistakes in this script. On line 4 it should read

        mkdir $cart or warn $!;

        (I should listen to my own advice)

        Also it fails if there is no ACE with everyone as the account. So I rejigged it as follows.

        use Win32::Perms; ### # # get_index_of($account_name, $ace) # # Return an array of positions of ACEs # with trustee of $account_name or if called # in scalar context the index of the first matching ACE # ### sub get_index_of { my ($account_name, $ace) = @_; my $index = -1; my @positions; do { $index++; print "$index"; $perm = $$ace[$index]; print $perm; if ($perm->{'Account'} eq $account_name) { push @positions, $i +ndex }; } while ($index < $#$ace); wantscalar and return $positions[0]; return @positions; } $cart='TestingFolder'; mkdir $cart or warn $!; # Create a new Security Descriptor and auto import permissions # from the directory my @perms; my $perm; my $Dir = new Win32::Perms( $cart ) or die; $Dir->Get(\@perms) or die; #Get permissions $Dir->Dump; my $acl_index = get_index_of('Everyone', \@perms); print "Returned ", $acl_index; print $perm->{'Account'}; if (defined $acl_index) { $Dir->Remove($acl_index) or die $!; $Dir->Set() or die$!; } $Dir->Dump;

        If you --me can you let me know so I can learn?

        --blm--

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://200337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found