[ Avaa Bypassed ]




Upload:

Command:

www-data@3.144.134.101: ~ $
# updown-lib.pl

BEGIN { push(@INC, ".."); };
use WebminCore;
&init_config();

if ($module_info{'usermin'}) {
	# Running under Usermin
	&switch_to_remote_user();
	&create_user_config_dirs();
	$downloads_dir = "$user_module_config_directory/downloads";
	$atjob_cmd = "$user_module_config_directory/download.pl";

	$can_upload = $config{'upload'};
	$can_download = $config{'download'};
	$can_fetch = $config{'fetch'};
	$can_schedule = $config{'background'} && &foreign_check("at");
	$can_background = $config{'background'};
	if ($config{'home_only'}) {
		@can_dirs = ( &resolve_links($remote_user_info[7]),
			      split(/\s+/, $config{'root'}) );
		}
	else {
		@can_dirs = ( "/" );
		}
	@can_dirs = &expand_root_variables(@can_dirs);
	$can_mode = 3;

	$download_dir = $userconfig{'ddir'};
	$download_dir = $remote_user_info[7] if ($download_dir eq "~");
	$upload_dir = $userconfig{'dir'};
	$upload_dir = $remote_user_info[7] if ($upload_dir eq "~");
	$upload_max = $config{'max'};
	$fetch_file = $userconfig{'fetch'};
	$fetch_show = $userconfig{'show'} || 0;
	}
else {
	# Running under Webmin
	$downloads_dir = "$module_config_directory/downloads";
	$atjob_cmd = "$module_config_directory/download.pl";

	%access = &get_module_acl();
	$can_upload = $access{'upload'};
	$can_download = $access{'download'};
	$can_fetch = $access{'fetch'} && !&is_readonly_mode();
	if ($access{'download'} != 2) {
		$can_schedule = &foreign_check("at");
		$can_background = 1;
		}
	if (&supports_users()) {
		$can_mode = $access{'mode'};
		}
	else {
		$can_mode = 3;
		}
	@can_users = split(/\s+/, $access{'users'});
	@can_dirs = split(/\s+/, $access{'dirs'});
	if ($access{'home'}) {
		local @uinfo = getpwnam($remote_user);
		push(@can_dirs, $uinfo[7]) if ($uinfo[7]);
		}

	$download_dir = $config{'ddir_'.$remote_user} || $config{'ddir'};
	$upload_dir = $config{'dir_'.$remote_user} || $config{'dir'};
	$upload_user = $config{'user_'.$remote_user} || $config{'user'};
	$upload_group = $config{'group_'.$remote_group} || $config{'group'};
	$upload_max = $access{'max'};
	$download_user = $config{'duser_'.$remote_user} || $config{'duser'};
	$download_group = $config{'dgroup_'.$remote_group} || $config{'dgroup'};
	$fetch_file = $config{'fetch_'.$remote_user};
	$fetch_show = $config{'show_'.$remote_user} || 0;
	}

# list_downloads()
# Returns a list of downloads currently in progress
sub list_downloads
{
local (@rv, $f);
opendir(DIR, $downloads_dir);
foreach $f (readdir(DIR)) {
	next if ($f !~ /^(\S+)\.down$/);
	local $down = &get_download("$1");
	push(@rv, $down) if ($down);
	}
closedir(DIR);
return @rv;
}

# get_download(id)
sub get_download
{
local %down;
&read_file("$downloads_dir/$_[0].down", \%down) || return undef;
$down{'user'} = getpwuid($down{'uid'});
return \%down;
}

# save_download(&download)
sub save_download
{
$_[0]->{'id'} = time().$$ if (!$_[0]->{'id'});
&lock_file($downloads_dir);
mkdir($downloads_dir, 0755);
&unlock_file($downloads_dir);
&lock_file("$downloads_dir/$_[0]->{'id'}.down");
&write_file("$downloads_dir/$_[0]->{'id'}.down", $_[0]);
&unlock_file("$downloads_dir/$_[0]->{'id'}.down");
}

# delete_download(&download)
sub delete_download
{
&lock_file("$downloads_dir/$_[0]->{'id'}.down");
unlink("$downloads_dir/$_[0]->{'id'}.down");
&unlock_file("$downloads_dir/$_[0]->{'id'}.down");
}

# do_download(&download, &callback, &dests)
# Actually download one or more files, and return undef or any error message
sub do_download
{
local ($i, $error, $msg);
for($i=0; $_[0]->{"url_$i"}; $i++) {
	$error = undef;
	$progress_callback_url = $_[0]->{"url_$i"};
	$progress_callback_count = $i;
	local $path;
	if (-d $_[0]->{'dir'}) {
		local $page = $_[0]->{"page_$i"};
		$page =~ s/\?.*$//;
		if ($page =~ /([^\/]+)$/) {
			$path = "$_[0]->{'dir'}/$1";
			}
		else {
			$path = "$_[0]->{'dir'}/index.html";
			}
		}
	else {
		$path = $_[0]->{'dir'};
		}
	&switch_uid_to($_[0]->{'uid'}, $_[0]->{'gid'});
	$down->{'upto'} = $progress_callback_count;
	if ($_[0]->{"proto_$i"} eq "http" || $_[0]->{"proto_$i"} eq "https") {
		&http_download($_[0]->{"host_$i"},
			       $_[0]->{"port_$i"},
			       $_[0]->{"page_$i"},
			       $path,
			       \$error,
			       $_[1],
			       $_[0]->{"ssl_$i"},
			       $_[0]->{"user_$i"},
			       $_[0]->{"pass_$i"});
		}
	else {
		&ftp_download($_[0]->{"host_$i"},
			      $_[0]->{"page_$i"},
			       $path,
			       \$error,
			       $_[1],
			       $_[0]->{"user_$i"},
			       $_[0]->{"pass_$i"});
		}
	unlink($path) if ($error);
	&switch_uid_back();

	# Add to email message
	$msg .= &text('email_downurl', $_[0]->{"url_$i"})."\n";
	if ($error) {
		$msg .= &text('email_downerr', $error)."\n";
		}
	else {
		local @st = stat($path);
		$msg .= &text('email_downpath', $path)."\n";
		$msg .= &text('email_downsize',&nice_size($st[7]))."\n";
		}
	$msg .= "\n";

	last if ($error);
	push(@{$_[2]}, $path);
	}

# Send status email
if ($down->{'email'}) {
	# Send email when done
	$msg = $text{'email_downmsg'}."\n\n".$msg;
	&send_email_notification(
                        $down->{'email'}, $text{'email_subjectd'}, $msg);
	}

return $error;
}

# can_write_file(file)
# Returns 1 if some path can be written to, 0 if not
sub can_write_file
{
local $d;
foreach $d (@can_dirs) {
	return 1 if (&is_under_directory($d, $_[0]));
	}
return 0;
}

# can_as_user(username)
# Returns 1 if uploading or downloading can be done as some user
sub can_as_user
{
if ($can_mode == 0) {
	return 1;
	}
elsif ($can_mode == 1) {
	return &indexof($_[0], @can_users) != -1;
	}
elsif ($can_mode == 2) {
	return &indexof($_[0], @can_users) == -1;
	}
elsif ($can_mode == 3) {
	return $_[0] eq $remote_user;
	}
else {
	return 0;	# shouldn't happen
	}
}

# in_group(&uinfo, &ginfo)
sub in_group
{
return 1 if ($_[0]->[3] == $_[1]->[2]);
foreach $s (&other_groups($_[0]->[0])) {
	return 1 if ($s eq $_[1]->[2]);
	}
return 0;
}

# switch_uid_to(uid, gid)
# Temporarily sets the effective UID and GID, if appropriate
sub switch_uid_to
{
if ($< == 0 && ($_[0] || $_[1]) && &supports_users()) {
	$old_uid = $>;
	$old_gid = $);
	$) = "$_[1] $_[1]";
	$> = $_[0];
	}
}

# switch_uid_back()
# Undo the switch made by switch_uid_to
sub switch_uid_back
{
if (defined($old_uid)) {
	$> = $old_uid;
	$) = $old_gid;
	$old_uid = $old_gid = undef;
	}
}

# send_email_notification(address, subject, message)
# Send email when some download or upload is complete
sub send_email_notification
{
local ($to, $subject, $msg) = @_;
if ($module_info{'usermin'}) {
	&foreign_require("mailbox", "mailbox-lib.pl");
	local $from = &mailbox::get_preferred_from_address();
	&mailbox::send_text_mail($from, $to, undef, $subject, $msg);
	}
else {
	&foreign_require("mailboxes", "mailboxes-lib.pl");
	local $from = &mailboxes::get_from_address();
	&mailboxes::send_text_mail($from, $to, undef, $subject, $msg);
	}
}

# webmin_command_as_user(user, env, command)
# Return a command as some user with su if this is webmin, or un-changed for
# usermin
sub webmin_command_as_user
{
my ($user, $env, @args) = @_;
if ($module_info{'usermin'}) {
	return join(" ", @args);
	}
else {
	return &command_as_user($user, $env, @args);
	}
}

# expand_root_variables(dir, ...)
# Replaces $USER and $HOME in a list of dirs
sub expand_root_variables
{
local @rv;
local %hash = ( 'user' => $remote_user_info[0],
                'home' => $remote_user_info[7],
                'uid' => $remote_user_info[2],
                'gid' => $remote_user_info[3] );
my @ginfo = getgrgid($remote_user_info[3]);
$hash{'group'} = $ginfo[0];
foreach my $dir (@_) {
        push(@rv, &substitute_template($dir, \%hash));
        }
return @rv;
}

1;


Filemanager

Name Type Size Permission Actions
images Folder 0755
lang Folder 0755
CHANGELOG File 876 B 0644
acl_security.pl File 1.74 KB 0755
cancel.cgi File 850 B 0755
config File 34 B 0644
config.info.ca File 376 B 0644
config.info.cz File 0 B 0644
defaultacl File 42 B 0644
download.cgi File 4.58 KB 0755
download.pl File 1.39 KB 0755
fetch.cgi File 3.1 KB 0755
index.cgi File 7.05 KB 0755
log_parser.pl File 986 B 0755
module.info File 210 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 179 B 0644
module.info.ar File 0 B 0644
module.info.ar.auto File 250 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 289 B 0644
module.info.bg File 0 B 0644
module.info.bg.auto File 293 B 0644
module.info.ca File 168 B 0644
module.info.ca.auto File 20 B 0644
module.info.cs File 30 B 0644
module.info.cs.auto File 144 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 183 B 0644
module.info.de File 174 B 0644
module.info.de.auto File 19 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 334 B 0644
module.info.es File 27 B 0644
module.info.es.auto File 152 B 0644
module.info.eu File 0 B 0644
module.info.eu.auto File 180 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 267 B 0644
module.info.fi File 27 B 0644
module.info.fi.auto File 137 B 0644
module.info.fr File 38 B 0644
module.info.fr.auto File 166 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 207 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 165 B 0644
module.info.hu File 32 B 0644
module.info.hu.auto File 159 B 0644
module.info.it File 26 B 0644
module.info.it.auto File 130 B 0644
module.info.ja File 48 B 0644
module.info.ja.auto File 217 B 0644
module.info.ko File 31 B 0644
module.info.ko.auto File 170 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 167 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 214 B 0644
module.info.ms File 191 B 0644
module.info.ms.auto File 19 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 169 B 0644
module.info.nl File 31 B 0644
module.info.nl.auto File 155 B 0644
module.info.no File 33 B 0644
module.info.no.auto File 158 B 0644
module.info.pl File 147 B 0644
module.info.pl.auto File 20 B 0644
module.info.pt File 0 B 0644
module.info.pt.auto File 176 B 0644
module.info.pt_BR File 0 B 0644
module.info.pt_BR.auto File 185 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 191 B 0644
module.info.ru File 49 B 0644
module.info.ru.auto File 256 B 0644
module.info.sk File 26 B 0644
module.info.sk.auto File 145 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 159 B 0644
module.info.sv File 0 B 0644
module.info.sv.auto File 190 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 372 B 0644
module.info.tr File 29 B 0644
module.info.tr.auto File 144 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 317 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 299 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 211 B 0644
module.info.zh File 0 B 0644
module.info.zh.auto File 142 B 0644
module.info.zh_TW File 27 B 0644
module.info.zh_TW.auto File 127 B 0644
safeacl File 28 B 0644
uninstall.pl File 340 B 0755
updown-lib.pl File 7.44 KB 0755
upload.cgi File 6.42 KB 0755