Working on an old Darwin 8.1 box where there have been layers of ACLs applied. The only native tools supplied to work with the ACLs are extended versions of ls and chmod.
We need to move off this box so to help I'm creating a script that produces an ACL map for a given user.
To my delight I've found that the file and directory names contain lots of interesting characters I have to be able to handle.
So far this works but I'm concerned that it blows up if I encounter anything with a " character in the name.
I've been searching for a better way but I need hints.
#!/usr/bin/perl -w # trying to map acls use Getopt::Long; use File::Find; no warnings 'File::Find'; my $optuser = ''; my $findroot = ''; GetOptions('user:s' => \$optuser, 'root=s' => \$findroot); unless( $findroot ){ print<<HERE $0 --root path [--user username] perform a recursive find rooted at the given pathname producing an +ACL map. if optional username is provided, filter ACL map results to that us +ername. HERE } find(\&wanted, $findroot); sub wanted { -f && next; open RES, "ls -lde \"$_\" |"; # filespec is discarded <RES>; while (my $acl=<RES>){ if($optuser){ $acl =~ /user:$optuser\s/ && print "$File::Find::name $acl"; } else { print "$File::Find::name $acl"; } } }
I'm interested in the 3 arg version of open() but so far I've been unable to get it working for this task; the spaces and shell chars are passed to ls and it seems I'm back to square one.
open RES, "-|", "ls -lde $_";In reply to Shell characters coming back to bite me. by mull
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |