Update (9/13/2): As BrowserUk mentions, I was unaware of the larger picture here, therefore creating a long-winded post that unfortunately has the rather large drawback of not working (or to be more accurate - not doing what it should). Apparently I have a rather long way to go to reach true enlightenment. So this update is a warning to all of you who may stumble across this later on - don't use it!
There appear to be two questions here:
The first is in regards to what the various labels are for the various permissions. You know what 'FULL' is, but the others aren't as clear. Unfortunately, I can't help you with this.
The second question has to do with the Tk code. In checking this out, I ran into something strange. In my test, I'm printing out what is being passed to the sub-routine and getting some strange results, due to the use of the '|' in the call.
This makes me wonder what you are using '|' for. Is it being used in its normal Perl way as a bitwise OR? Or are you trying to choose between two options (i.e., the parameter could be the $folder_ace_var OR the $subfolder_ace_var)? Or is supposed to be part of the parameters being passed (i.e., a literal '|')?
First off, a bitwise OR does very strange stuff to the strings when they are passed to the sub-routine, so I'm pretty sure that is NOT what you are trying to do.
Using '||' instead of '|' does what it is expected (choose between two options), but the way you have it written, you will always get OBJECT_INHERIT_ACE, regardless of which permission was set. And I'm confused on the order of the parameters - you pass $folder_ace_var before $subfolder_ace_var, but pass OBJECT_INHERIT_ACE before CONTAINER_INHERIT_ACT (it would seem that the OBJECT (the sub-folder or file) would be in the CONTAINER (the folder), not the other way around, but then rules don't have to make sense). Also, I get warnings on using the barewords ACCESS_ALLOWED_ACE_TYPE, OBJECT_INHERIT_ACE, and CONTAINER_INHERIT_ACE. Quoting these values would get rid of these errors. Your call would now look like this:
$perms->Add("$account",
"$folder_ace_var" || "$subfolder_ace_var",
"ACCESS_ALLOWED_ACE_TYPE",
"CONTAINER_INHERIT_ACE" || "OBJECT_INHERIT_ACE");
If this is what you are trying to do, then a better way to do this would be:
if ( $folder_ace_var )
{
$perms->Add("$account",
"$folder_ace_var",
"ACCESS_ALLOWED_ACE_TYPE",
"OBJECT_INHERIT_ACE");
}
else
{
$perms->Add("$account",
"$subfolder_ace_var",
"ACCESS_ALLOWED_ACE_TYPE",
"CONTAINER_INHERIT_ACE");
}
That leaves us with the third choice - that the '|' is part of the string being passed. If so, then we need to put quotes around the parameters to get the '|' to pass to the sub-routine correctly. For this option, the call would look like this:
$perms->Add("$account",
"$folder_ace_var | $subfolder_ace_var",
"ACCESS_ALLOWED_ACE_TYPE",
"CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE");
The test program below shows how the various choices will affect the results. This is getting a mite long-winded (which, unfortunately, is a curse of mine), so I'll just end with I hope this has been helpful.
And without further ado, the code:
#!/opt/local/bin/perl -w
use strict;
use Tk;
my $mw = MainWindow->new;
$mw->geometry("400x300+20+20");
$mw->title( "Tk Testing" );
my $account = 'Me';
my $folder_ace_var = '';
my $subfolder_ace_var = '';
my $bottom_frame = $mw->Frame()->pack(-side => 'bottom');
my $left_frame = $mw->Frame()->pack(-side => 'left');
my $right_frame = $mw->Frame()->pack(-side => 'right');
foreach my $p ('NO_ACCESS', 'FULL','READ', 'WRITE' ,'CHANGE','GENERIC_
+ALL')
{
$left_frame->Radiobutton(-text => "ACE : $p",
-variable => \$folder_ace_var,
-relief => 'flat',
-value => $p,
)->pack(-side => 'top',
-in => $left_frame,
-anchor => 'w',
#-fill => 'x',
#-expand => 1,
#-padx => 5,
#-pady => 1,
);
}
foreach my $p ('NO_ACCESS', 'FULL','READ', 'WRITE' ,'CHANGE','GENERIC_
+ALL')
{
$right_frame->Radiobutton(-text => "ACE : $p",
-variable => \$subfolder_ace_var,
-relief => 'flat',
-value => $p,
)->pack(-side => 'top',
-in => $right_frame,
-anchor => 'w',
# -fill => 'x',
#-expand => 1,
#-padx => 5,
#-pady => 1,
);
}
$mw->Button(-text => "Bitwise OR",
-width => 10,
-command => sub{ Check_Variables(
"$account",
"$folder_ace_var" | "$subfolder_ace_va
+r",
"ACCESS_ALLOWED_ACE_TYPE",
"OBJECT_INHERIT_ACE" | "CONTAINER_INHE
+RIT_ACE" );
},
)->pack(-side => 'left',
-in => $bottom_frame,
-anchor => 'w',
-fill => 'none',
-expand => 0,
-padx => 5,
);
$mw->Button(-text => "Literal |",
-width => 10,
-command => sub{ Check_Variables(
"$account",
"$folder_ace_var | $subfolder_ace_var"
+,
"ACCESS_ALLOWED_ACE_TYPE",
"OBJECT_INHERIT_ACE | CONTAINER_INHERI
+T_ACE" );
},
)->pack(-side => 'left',
-in => $bottom_frame,
-anchor => 'w',
-fill => 'none',
-expand => 0,
-padx => 5,
);
$mw->Button(-text => "Regular OR",
-width => 10,
-command => sub{ Check_Variables(
"$account",
"$folder_ace_var" || "$subfolder_ace_v
+ar",
"ACCESS_ALLOWED_ACE_TYPE",
"OBJECT_INHERIT_ACE" || "CONTAINER_INH
+ERIT_ACE" );
},
)->pack(-side => 'left',
-in => $bottom_frame,
-anchor => 'w',
-fill => 'none',
-expand => 0,
-padx => 5,
);
MainLoop;
sub Check_Variables
{
print "-----------------------------------------------\n";
foreach my $entry ( @_ )
{
print "$entry\n";
}
print "-----------------------------------------------\n";
}
exit 0;
#
# end of code
#
Pat |