Handle hostnames with upper-case letters
[webmin.git] / file / irix-setfacl.pl
1 #!/usr/local/bin/perl
2 # irix-setfacl.pl
3 # Wrapper for the chacl command
4
5 while(<STDIN>) {
6         s/\r|\n//g;
7         $default = ($_ =~ s/^default://);
8         s/^(other|mask):([rwx\-]{3})$/\1::\2/g;
9         if ($default) {
10                 push(@dacl, $_);
11                 }
12         else {
13                 push(@acl, $_);
14                 }
15         }
16 $esc = quotemeta($ARGV[0]);
17 $acl = join(",", @acl);
18 $dacl = join(",", @dacl);
19 if ($acl && $dacl) {
20         $out = `chacl -b $acl $dacl $esc 2>&1`;
21         }
22 elsif ($acl) {
23         if (-d $ARGV[0]) {
24                 $out = `chacl $acl $esc 2>&1 && chacl -D $esc 2>&1`;
25                 }
26         else {
27                 $out = `chacl $acl $esc 2>&1`;
28                 }
29         }
30 elsif ($dacl) {
31         $out = `chacl -d $dacl $esc 2>&1 && chacl -R $esc 2>&1`;
32         }
33 else {
34         $out = `chacl -B $esc 2>&1`;
35         }
36 if ($?) {
37         print STDERR $out;
38         exit 1;
39         }
40