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