Handle hostnames with upper-case letters
[webmin.git] / file / setattrs.cgi
1 #!/usr/local/bin/perl
2 # setattrs.cgi
3 # Sets all the XFS attributes for a file
4
5 require './file-lib.pl';
6 $disallowed_buttons{'attr'} && &error($text{'ebutton'});
7 &ReadParse();
8 &webmin_log("attr", undef, $in{'file'}, \%in);
9 &switch_acl_uid_and_chroot();
10 print "Content-type: text/plain\n\n";
11 if ($access{'ro'} || !&can_access($in{'file'})) {
12         print $text{'facl_eaccess'},"\n";
13         }
14 else {
15         # Set given attribs
16         $temp = &transname();
17         for($i=0; defined($n = $in{"name$i"}); $i++) {
18                 $v = $in{"value$i"};
19                 open(TEMP, ">$temp");
20                 print TEMP $v;
21                 close(TEMP);
22                 $out = `attr -s '$n' '$in{'file'}' <$temp 2>&1`;
23                 unlink($temp);
24                 if ($?) {
25                         print $out,"\n";
26                         exit;
27                         }
28                 $set{$n}++;
29                 }
30
31         # Remove those that no longer exist
32         $out = `attr -l '$in{'file'}' 2>&1`;
33         foreach $l (split(/[\r\n]+/, $out)) {
34                 if ($l =~ /Attribute\s+"(.*)"/i && !$set{$1}) {
35                         $out = `attr -r '$1' '$in{'file'}' 2>&1`;
36                         if ($?) {
37                                 print $out,"\n";
38                                 exit;
39                                 }
40                         }
41                 }
42         print "\n";
43         }
44