Handle hostnames with upper-case letters
[webmin.git] / file / getattrs.cgi
1 #!/usr/local/bin/perl
2 # getattrs.cgi
3 # Returns a list in URL-encode name=value format of attributes on some file
4
5 require './file-lib.pl';
6 &ReadParse();
7 &switch_acl_uid_and_chroot();
8 print "Content-type: text/plain\n\n";
9 if (!&can_access($in{'file'})) {
10         print $text{'facl_eaccess'},"\n";
11         }
12 else {
13         $out = `attr -l '$in{'file'}' 2>&1`;
14         if ($?) {
15                 print $out,"\n";
16                 }
17         else {
18                 foreach $l (split(/[\r\n]+/, $out)) {
19                         if ($l =~ /Attribute\s+"(.*)"/i) {
20                                 # Get the valid for this attribute
21                                 local $name = $1;
22                                 $got = `attr -g '$name' '$in{'file'}' 2>&1`;
23                                 if ($? || $got !~ /^(.*)\n([\0-\377]*)\n$/) {
24                                         print $got,"\n";
25                                         exit;
26                                         }
27                                 push(@rv, [ $name, $2 ] );
28                                 }
29                         }
30                 print "\n";
31                 foreach $r (@rv) {
32                         print &urlize($r->[0]),"=",&urlize($r->[1]),"\n";
33                         }
34                 }
35         }
36