[ Avaa Bypassed ]




Upload:

Command:

www-data@18.224.202.121: ~ $
# mount-lib.pl
# Functions for handling the /etc/[v]fstab file. Some functions are defined in
# here, and some in OS-specific files named <os_type>-lib.pl

BEGIN { push(@INC, ".."); };
use WebminCore;
&init_config();
%access = &get_module_acl();
$filesystem_users_file = "$module_config_directory/filesystem-users";
@access_fs = split(/\s+/, $access{'fs'});

# get_mount(directory|'swap', device)
# Returns the index of this mount, or -1 if not known
sub get_mount
{
local(@mlist, $p, $d, $i);
@mlist = &list_mounts();
for($i=0; $i<@mlist; $i++) {
	$p = $mlist[$i];
	if ($_[0] eq "*" && $p->[1] eq $_[1]) {
		# found by match on device
		return $i;
		}
	elsif ($_[1] eq "*" && $p->[0] eq $_[0]) {
		# found by match on directory
		return $i;
		}
	elsif ($p->[0] eq $_[0] && $p->[1] eq $_[1]) {
		# found by match on both
		return $i;
		}
	}
return -1;
}


# get_mounted(directory|'swap', device)
# Returns the index of this current mount, or -1 if not known
sub get_mounted
{
local(@mlist, $p, $d, $i);
@mlist = &list_mounted();
for($i=0; $i<@mlist; $i++) {
	$p = $mlist[$i];
	if ($_[0] eq "*" && $p->[1] eq $_[1]) {
		# found by match on device
		return $i;
		}
	elsif ($_[1] eq "*" && $p->[0] eq $_[0]) {
		# found by match on directory
		return $i;
		}
	elsif ($p->[0] eq $_[0] && $p->[1] eq $_[1]) {
		# found by match on both
		return $i;
		}
	}
return -1;
}


# parse_options(type, options)
# Convert an options string for some filesystem into the associative
# array %options
sub parse_options
{
local($_);
undef(%options);
if ($_[1] ne "-") {
	foreach (split(/,/, $_[1])) {
		if (/^([^=]+)=(.*)$/) { $options{$1} = $2; }
		else { $options{$_} = ""; }
		}
	}
return \%options;
}

# join_options(type, [&hash])
# Returns a string constructed from the %options hash
sub join_options
{
local $h = $_[1] || \%options;
local (@rv, $k);
foreach $k (keys %$h) {
	push(@rv, $h->{$k} eq "" ? $k : $k."=".$h->{$k});
	}
return @rv ? join(",", @rv) : "-";
}

# swap_form(path)
# This function should be called by os-specific code to display a form
# asking for the size of a swap file to create. The form will be submitted
# to a creation program, and then redirected back to the original mount cgi
sub swap_form
{
local ($file) = @_;
&ui_print_header(undef, "Create Swap File", "");
print &ui_form_start("create_swap.cgi");
foreach my $k (keys %in) {
	print &ui_hidden($k, $in{$k});
	}
print &ui_hidden("cswap_file", $file);
print &text('cswap_file', "<tt>$file</tt>"),"<p>\n";
print $text{'cswap_size'},"\n";
print &ui_textbox("cswap_size", undef, 6)," ",
      &ui_select("cswap_units", "m",
		 [ [ "m", "MB" ], [ "g", "GB" ], [ "t", "TB" ] ])."\n";
print &ui_form_end([ [ undef, $text{'create'} ] ]);
&ui_print_footer("", $text{'index_return'});
exit;
}

# nfs_server_chooser_button(input, [form])
sub nfs_server_chooser_button
{
local($form);
$form = @_ > 1 ? $_[1] : 0;
if ($access{'browse'}) {
	return "<input type=button onClick='ifield = document.forms[$form].$_[0]; nfs_server = window.open(\"../$module_name/nfs_server.cgi\", \"nfs_server\", \"toolbar=no,menubar=no,scrollbars=yes,width=400,height=300\"); nfs_server.ifield = ifield; window.ifield = ifield' value=\"...\">\n";
	}
return undef;
}

# nfs_export_chooser_button(serverinput, exportinput, [form])
sub nfs_export_chooser_button
{
local($form);
$form = @_ > 2 ? $_[2] : 0;
if ($access{'browse'}) {
	return "<input type=button onClick='if (document.forms[$form].$_[0].value != \"\") { ifield = document.forms[$form].$_[1]; nfs_export = window.open(\"../$module_name/nfs_export.cgi?server=\"+document.forms[$form].$_[0].value, \"nfs_export\", \"toolbar=no,menubar=no,scrollbars=yes,width=500,height=200\"); nfs_export.ifield = ifield; window.ifield = ifield }' value=\"...\">\n";
	}
return undef;
}

# smb_server_chooser_button(serverinput, [form])
sub smb_server_chooser_button
{
local($form);
$form = @_ > 1 ? $_[1] : 0;
if (&has_command($config{'smbclient_path'}) && $access{'browse'}) {
	return "<input type=button onClick='ifield = document.forms[$form].$_[0]; smb_server = window.open(\"../$module_name/smb_server.cgi\", \"smb_server\", \"toolbar=no,menubar=no,scrollbars=yes,width=400,height=300\"); smb_server.ifield = ifield; window.ifield = ifield' value=\"...\">\n";
	}
return undef;
}

# smb_share_chooser_button(serverinput, shareinput, [form])
sub smb_share_chooser_button
{
local($form);
$form = @_ > 2 ? $_[2] : 0;
if (&has_command($config{'smbclient_path'}) && $access{'browse'}) {
	return "<input type=button onClick='if (document.forms[$form].$_[0].value != \"\") { ifield = document.forms[$form].$_[1]; smb_share = window.open(\"../$module_name/smb_share.cgi?server=\"+document.forms[$form].$_[0].value, \"smb_share\", \"toolbar=no,menubar=no,scrollbars=yes,width=400,height=300\"); smb_share.ifield = ifield; window.ifield = ifield }' value=\"...\">\n";
	}
return undef;
}

# Include the correct OS-specific functions file
if ($gconfig{'os_type'} =~ /^\S+\-linux$/) {
	do "linux-lib.pl";
	}
else {
	do "$gconfig{'os_type'}-lib.pl";
	}

# can_edit_fs(dir, device, type, options, [is-new])
# Returns 1 if a filesystem can be edited, 0 otherwise
sub can_edit_fs
{
local $ok = 1;
if (@access_fs) {
	local $d;
	foreach $d (@access_fs) {
		$ok = 0 if (!&is_under_directory($d, $_[0]));
		}
	}
$ok = 0 if (!&can_fstype($_[2]));
if ($access{'user'} && !$_[4]) {
	local $users = &get_filesystem_users();
	$ok = 0 if ($users->{$_[0]} ne $remote_user);
	}
return $ok;
}

# can_fstype(type)
sub can_fstype
{
return 1 if (!$access{'types'});
local @types = split(/\s+/, $access{'types'});
return &indexof($_[0], @types) >= 0;
}

# compile_program(name, default-arch)
# Ensures that some C program is compiled and copied to /etc/webmin . Uses the
# supplied native versions if possible
sub compile_program
{
return if (-r "$module_config_directory/$_[0]" &&
   &execute_command("$module_config_directory/$_[0]", undef, undef, undef, 0, 1) == 0);
local $arch = &backquote_command("uname -m");
$arch =~ s/\r|\n//g;
local $re = $_[1];
if ($re && $arch =~ /^$re$/i && -r "$module_root_directory/$_[0]" &&
    &execute_command("$module_root_directory/$_[0]", undef, undef, undef, 0, 1) == 0) {
	# Compiled program for this architecture already exists and is working,
	# so can just copy
	&execute_command("cp $module_root_directory/$_[0] $module_config_directory/$_[0]");
	}
else {
	# Need to compile
	local ($cc) = (&has_command("gcc") || &has_command("cc") ||
		       &has_command("gcc-4.0") || &has_command("gcc-3.3"));
	$cc || &error($text{'egcc'});
	local $out = &backquote_logged("$cc -o $module_config_directory/$_[0] $module_root_directory/$_[0].c 2>&1");
	if ($?) {
		&error(&text('ecompile', "<pre>$out</pre>"));
		}
	}
&set_ownership_permissions(undef, undef, 0755,"$module_config_directory/$_[0]");
}

# get_filesystem_users()
# Returns a mapping between filesystems and their owners
sub get_filesystem_users
{
local %users;
&read_file($filesystem_users_file, \%users);
return \%users;
}

# save_filesystem_users(&usermap)
# Saves the filesystem owner mapping
sub save_filesystem_users
{
&write_file($filesystem_users_file, $_[0]);
}

# can_delete_directory(mount-point)
# Returns 1 if some directory should be deleted when un-mounting
sub can_delete_directory
{
local @dirs = split(/\s+/, $config{'delete_under'});
return 0 if (!@dirs);
return 0 if ($_[0] eq "swap");
local $d;
foreach $d (@dirs) {
	return 1 if (&is_under_directory($d, $_[0]));
	}
return 0;
}

# delete_unmounted(dir, device)
# If some directory is no longer in the permanent mount list, delete it if it
# is under the list of dirs to auto-delete
sub delete_unmounted
{
if (&can_delete_directory($_[0]) &&
    &get_mount($_[0], $_[1]) < 0) {
	&system_logged("rmdir ".quotemeta($_[0]));
	}
}

# remount_dir(directory, device, type, options)
# Adjusts the options for some mounted filesystem
sub remount_dir
{
if (defined(&os_remount_dir)) {
	return &os_remount_dir(@_);
	}
else {
	local $err = &unmount_dir(@_);
	return $err if ($err);
	return &mount_dir(@_);
	}
}

# filesystem_for_dir(dir)
# Give a directory, returns the details filesystem it is on (dir, device,
# type, options)
sub filesystem_for_dir
{
local @stdir = stat($_[0]);
foreach my $m (&list_mounted()) {
	local @stm = stat($m->[0]);
	if ($stm[0] == $stdir[0]) {
		# Save device number!
		return @$m;
		}
	}
return ( );
}

# local_disk_space([&always-count])
# Returns the total local and free disk space on the system, plus a list of
# per-filesystem total and free
sub local_disk_space
{
my ($always) = @_;
my ($total, $free) = (0, 0);
my @fs;
my @mounted = &mount::list_mounted();
my %donezone;
my %donevzfs;
my %donedevice;
my %donedevno;

# Get list of zone pools
my %zpools = ( 'zones' => 1, 'zroot' => 1 );
if (&has_command("zpool")) {
	foreach my $flag ("-P", "-p") {
		my @out = &backquote_command("zpool list $flag 2>/dev/null");
		foreach my $l (@out) {
			if (/^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)/) {
				$zpools{$1} = [ $2 / 1024, $4 / 1024 ];
				}
			}
		}
	}

# Add up all local filesystems
foreach my $m (@mounted) {
	if ($m->[2] =~ /^ext/ ||
	    $m->[2] eq "reiserfs" || $m->[2] eq "ufs" || $m->[2] eq "f2fs" ||
	    $m->[2] eq "zfs" || $m->[2] eq "simfs" || $m->[2] eq "vzfs" ||
	    $m->[2] eq "xfs" || $m->[2] eq "jfs" || $m->[2] eq "btrfs" ||
	    $m->[1] =~ /^\/dev\// ||
	    &indexof($m->[1], @$always) >= 0) {
		my $zp;
		if ($m->[1] =~ /^([^\/]+)(\/(\S+))?/ &&
                    $m->[2] eq "zfs" && $zpools{$1}) {
			# Don't double-count maps from the same zone pool
			next if ($donezone{$1}++);
			$zp = $zpools{$1};
			}
		if ($donedevice{$m->[0]}++ ||
		    $donedevice{$m->[1]}++) {
			# Don't double-count mounts from the same device, or
			# on the same directory.
			next;
			}
		my @st = stat($m->[0]);
		if (@st && $donedevno{$st[0]}++) {
			# Don't double-count same filesystem by device number
			next;
			}
		if ($m->[1] eq "/dev/fuse") {
			# Skip fuse user-space filesystem mounts
			next;
			}
		if ($m->[2] eq "swap") {
			# Skip virtual memory
			next;
			}
		if ($m->[2] eq "squashfs") {
			# Skip /snap mounts
			next;
			}
		if ($m->[1] =~ /^\/dev\/sr/) {
			# Skip CDs
			next;
			}
		# Get the size - for ZFS mounts, this comes from the underlying
		# total pool size and free
		my ($t, $f);
		if ($zp) {
			($t, $f) = @$zp;
			}
		else {
			($t, $f, $u, $p) = &disk_space($m->[2], $m->[0]);
			}
		if (($m->[2] eq "simfs" || $m->[2] eq "vzfs" ||
		     $m->[0] eq "/dev/vzfs" ||
		     $m->[0] eq "/dev/simfs") &&
		    $donevzfs{$t,$f}++) {
			# Don't double-count VPS filesystems
			next;
			}
		$total += $t*1024;
		$free += $f*1024;
		my ($it, $if);
		if (defined(&inode_space)) {
			($it, $if, $iu, $ip) = &inode_space($m->[2], $m->[0]);
			}
		push(@fs, { 'total' => $t*1024,
			    'free' => $f*1024,
			    'used' => $u*1024,
			    'used_percent' => $p,
			    'itotal' => $it,
			    'ifree' => $if,
			    'iused' => $iu,
			    'iused_percent' => $ip,
			    'dir' => $m->[0],
			    'device' => $m->[1],
			    'type' => $m->[2] });
		}
	}
return ($total, $free, \@fs);
}

1;


Filemanager

Name Type Size Permission Actions
help Folder 0755
images Folder 0755
lang Folder 0755
CHANGELOG File 1.73 KB 0644
acl_security.pl File 1.59 KB 0755
backup_config.pl File 686 B 0755
cgi_args.pl File 325 B 0755
config-cobalt-linux File 132 B 0644
config-coherent-linux File 186 B 0644
config-corel-linux File 160 B 0644
config-debian-linux File 206 B 0644
config-freebsd File 172 B 0644
config-generic-linux File 133 B 0644
config-gentoo-linux File 169 B 0644
config-hpux File 172 B 0644
config-lfs-linux File 154 B 0644
config-macos File 150 B 0644
config-mandrake-linux File 186 B 0644
config-msc-linux File 186 B 0644
config-netbsd File 172 B 0644
config-open-linux File 158 B 0644
config-open-linux-3.1e File 177 B 0644
config-openSUSE-Linux-15.0-ALL File 162 B 0644
config-openbsd File 172 B 0644
config-openmamba-linux File 162 B 0644
config-osf1 File 230 B 0644
config-pardus-linux File 133 B 0644
config-redhat-linux File 162 B 0644
config-redhat-linux-5.0-6.0 File 191 B 0644
config-redhat-linux-6.1-ALL File 186 B 0644
config-slackware-linux File 133 B 0644
config-sol-linux File 292 B 0644
config-solaris File 205 B 0644
config-suse-linux File 162 B 0644
config-syno-linux File 133 B 0644
config-trustix-linux File 186 B 0644
config-turbo-linux File 191 B 0644
config-turbo-linux-4.0 File 191 B 0644
config-united-linux File 162 B 0644
config.info File 800 B 0644
config.info.ca File 1 KB 0644
config.info.cs File 747 B 0644
config.info.de File 959 B 0644
config.info.es File 431 B 0644
config.info.fa File 1010 B 0644
config.info.fr File 400 B 0644
config.info.ja File 760 B 0644
config.info.ko File 565 B 0644
config.info.nl File 654 B 0644
config.info.no File 668 B 0644
config.info.pl File 475 B 0644
config.info.pt_BR File 701 B 0644
config.info.ru File 736 B 0644
config.info.sv File 369 B 0644
config.info.tr File 579 B 0644
config.info.uk File 741 B 0644
config.info.zh File 347 B 0644
config.info.zh_TW File 403 B 0644
create_swap.cgi File 466 B 0755
defaultacl File 60 B 0644
edit_mount.cgi File 4.11 KB 0755
freebsd-lib.pl File 33.48 KB 0755
hpux-lib.pl File 35.81 KB 0755
index.cgi File 4.31 KB 0755
linux-lib.pl File 72.08 KB 0755
log_parser.pl File 626 B 0755
macos-lib.pl File 3.95 KB 0755
module.info File 292 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 168 B 0644
module.info.ar File 190 B 0644
module.info.ar.auto File 28 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 286 B 0644
module.info.bg File 0 B 0644
module.info.bg.auto File 281 B 0644
module.info.ca File 161 B 0644
module.info.ca.auto File 25 B 0644
module.info.cs File 48 B 0644
module.info.cs.auto File 142 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 162 B 0644
module.info.de File 162 B 0644
module.info.de.auto File 28 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 322 B 0644
module.info.es File 43 B 0644
module.info.es.auto File 151 B 0644
module.info.eu File 0 B 0644
module.info.eu.auto File 169 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 203 B 0644
module.info.fi File 0 B 0644
module.info.fi.auto File 191 B 0644
module.info.fr File 37 B 0644
module.info.fr.auto File 161 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 213 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 192 B 0644
module.info.hu File 35 B 0644
module.info.hu.auto File 139 B 0644
module.info.it File 22 B 0644
module.info.it.auto File 126 B 0644
module.info.ja File 75 B 0644
module.info.ja.auto File 202 B 0644
module.info.ko File 51 B 0644
module.info.ko.auto File 170 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 180 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 192 B 0644
module.info.ms File 144 B 0644
module.info.ms.auto File 24 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 177 B 0644
module.info.nl File 41 B 0644
module.info.nl.auto File 129 B 0644
module.info.no File 39 B 0644
module.info.no.auto File 120 B 0644
module.info.pl File 44 B 0644
module.info.pl.auto File 131 B 0644
module.info.pt File 45 B 0644
module.info.pt.auto File 143 B 0644
module.info.pt_BR File 47 B 0644
module.info.pt_BR.auto File 149 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 188 B 0644
module.info.ru File 40 B 0644
module.info.ru.auto File 211 B 0644
module.info.sk File 0 B 0644
module.info.sk.auto File 207 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 192 B 0644
module.info.sv File 43 B 0644
module.info.sv.auto File 124 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 305 B 0644
module.info.tr File 34 B 0644
module.info.tr.auto File 146 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 291 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 249 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 208 B 0644
module.info.zh File 36 B 0644
module.info.zh.auto File 126 B 0644
module.info.zh_TW File 39 B 0644
module.info.zh_TW.auto File 132 B 0644
mount-lib.pl File 10.79 KB 0755
mount.cgi File 465 B 0755
netbsd-lib.pl File 24.64 KB 0755
netbsd-mounts-2.c File 1.04 KB 0644
netbsd-mounts-3.c File 1.09 KB 0644
netbsd-mounts.c File 1.08 KB 0644
nfs_export.cgi File 1.13 KB 0755
nfs_server.cgi File 1.79 KB 0755
openbsd-lib.pl File 24.37 KB 0755
osf1-lib.pl File 11.34 KB 0755
prefs.info File 49 B 0644
rbac-mapping File 135 B 0644
save_mount.cgi File 13.23 KB 0755
smb_server.cgi File 1.94 KB 0755
smb_share.cgi File 1.29 KB 0755
solaris-lib.pl File 56.62 KB 0755
system_info.pl File 3.96 KB 0644
unmount.cgi File 503 B 0755