Handle hostnames with upper-case letters
[webmin.git] / file / mount.cgi
1 #!/usr/local/bin/perl
2 # mount.cgi
3 # Mount or un-mount some filesystem
4 # XXX need way to detect current status?
5 # XXX should return result
6 # XXX client must force refresh:
7 # XXX can only deal with stuff in /etc/fstab
8
9 require './file-lib.pl';
10 $disallowed_buttons{'mount'} && &error($text{'ebutton'});
11 &ReadParse();
12 print "Content-type: text/plain\n\n";
13 if ($access{'ro'} || $access{'uid'}) {
14         # User is not allowed to mount
15         print "$text{'mount_eaccess'}\n";
16         exit;
17         }
18
19 # Get current status
20 $dir = &unmake_chroot($in{'dir'});
21 &foreign_require("mount", "mount-lib.pl");
22 @fstab = &mount::list_mounts();
23 @mtab = &mount::list_mounted();
24 ($fstab) = grep { $_->[0] eq $dir } @fstab;
25 if (!$fstab) {
26         # Doesn't exist!
27         print "$text{'mount_efstab'}\n";
28         exit;
29         }
30 ($mtab) = grep { $_->[0] eq $dir } @mtab;
31
32 if ($mtab) {
33         # Attempt to un-mount now
34         $err = &mount::unmount_dir(@$mtab);
35         }
36 else {
37         # Attempt to mount now
38         $err = &mount::mount_dir(@$fstab);
39         }
40 if ($err) {
41         $err =~ s/<[^>]*>//g;
42         $err =~ s/\n/ /g;
43         print $err,"\n";
44         }
45 else {
46         print "\n";
47         }
48