Handle hostnames with upper-case letters
[webmin.git] / file / save.cgi
1 #!/usr/local/bin/perl
2 # save.cgi
3 # Write data to a file
4
5 require './file-lib.pl';
6 $disallowed_buttons{'edit'} && &error($text{'ebutton'});
7 $p = $ENV{'PATH_INFO'};
8 &webmin_log("save", undef, $p) if ($access{'uid'});
9 &switch_acl_uid_and_chroot();
10 print "Content-type: text/plain\n\n";
11
12 # Read posted data
13 $clen = $ENV{'CONTENT_LENGTH'};
14 &read_fully(STDIN, \$buf, $clen) == $clen ||
15         &error("Failed to read POST input : $!");
16
17 if (defined($in{'length'}) && length($buf) != $in{'length'}) {
18         print &text('edit_elength'),"\n";
19         }
20 else {
21         &lock_file($p);
22         if ($access{'ro'} || !&can_access($p)) {
23                 print &text('edit_eaccess', $p),"\n";
24                 }
25         elsif (-l $p && !&must_follow($p)) {
26                 print &text('edit_efollow', $p),"\n";
27                 }
28         elsif (!&open_tempfile(FILE, ">$p", 1)) {
29                 print "$!\n";
30                 }
31         else {
32                 &print_tempfile(FILE, $buf);
33                 &close_tempfile(FILE);
34                 &unlock_file($p);
35                 print "\n";
36                 print &file_info_line($p),"\n";
37                 &webmin_log("save", undef, $p) if (!$access{'uid'});
38                 }
39         }