[ Avaa Bypassed ]




Upload:

Command:

www-data@18.216.248.35: ~ $
#!/usr/bin/perl
# run.cgi
# Actually run the command on all servers and show the output

require './cluster-shell-lib.pl';
&ReadParse();
&error_setup($text{'run_err'});

if ($in{'clear'}) {
	# Just clearing history
	&lock_file($commands_file);
	unlink($commands_file);
	&unlock_file($commands_file);
	&webmin_log("clear");
	&redirect("");
	exit;
	}

$in{'cmd'} ||= $in{'old'};
$in{'cmd'} =~ /\S/ || &error($text{'run_ecmd'});

# Build the list of servers
@servers = &servers::list_servers();
@sel = split(/\0/, $in{'server'});
foreach $s (@sel) {
	if ($s eq "ALL") {
		push(@run, grep { $_->{'user'} } @servers);
		}
	elsif ($s =~ /^group_(.*)$/) {
		# All members of a group
		($group) = grep { $_->{'name'} eq $1 }
				&servers::list_all_groups(\@servers);
		foreach $m (@{$group->{'members'}}) {
			push(@run, grep { $_->{'host'} eq $m && $_->{'user'} }
					@servers);
			}
		}
	elsif ($s eq '*') {
		# This server
		push(@run, ( { 'desc' => $text{'index_this'} } ));
		}
	else {
		# A single remote server
		push(@run, grep { $_->{'host'} eq $s } @servers);
		}
	}
@run = grep { !$done{$_->{'id'}}++ } @run;
@run || &error($text{'run_enone'});

&ui_print_header(undef, $text{'run_title'}, "");

# Setup error handler for down hosts
sub inst_error
{
$inst_error_msg = join("", @_);
}
&remote_error_setup(\&inst_error);

# Run one each one in parallel and display the output
$p = 0;
foreach $s (@run) {
	local ($rh = "READ$p", $wh = "WRITE$p");
	pipe($rh, $wh);
	select($wh); $| = 1; select(STDOUT);
	if (!fork()) {
		# Run the command in a subprocess
		close($rh);

		&remote_foreign_require($s->{'host'}, "webmin",
					"webmin-lib.pl");
		if ($inst_error_msg) {
			# Failed to contact host ..
			print $wh &serialise_variable([ 0, $inst_error_msg ]);
			exit;
			}

		# Run the command and capture output
		local $q = quotemeta($in{'cmd'});
		local $rv = &remote_eval($s->{'host'}, "webmin",
					 "\$x=`($q) </dev/null 2>&1`");

		print $wh &serialise_variable([ 1, $rv ]);
		close($wh);
		exit;
		}
	close($wh);
	$p++;
	}

# Get back all the results
$p = 0;
foreach $s (@run) {
	local $rh = "READ$p";
	local $line = <$rh>;
	close($rh);
	local $rv = &unserialise_variable($line);

	local $d = $s->{'host'}.($s->{'desc'} ? " (".$s->{'desc'}.")" : "");

	if (!$line) {
		# Comms error with subprocess
		print "<b>",&text('run_failed', $d, "Unknown reason"),
		      "</b><p>\n";
		}
	elsif (!$rv->[0]) {
		# Error with remote server
		print "<b>",&text('run_failed', $d, $rv->[1]),"</b><p>\n";
		}
	else {
		# Done - show output
		print "<b>",&text('run_success', $d),"</b>\n";
		print "<ul><pre>".&html_escape($rv->[1])."</pre></ul><p>\n";
		}
	$p++;
	}

# Save command and server
&open_lock_tempfile(COMMANDS, ">>$commands_file");
&print_tempfile(COMMANDS, $in{'cmd'},"\n");
&close_tempfile(COMMANDS);
$config{'server'} = join(" ", @sel);
&save_module_config();

&webmin_log("run", undef, undef, { 'cmd' => $in{'cmd'},
				   'run' => [ map { $_->{'host'} } @run ] });

&ui_print_footer("", $text{'index_return'});


Filemanager

Name Type Size Permission Actions
help Folder 0755
images Folder 0755
lang Folder 0755
cluster-shell-lib.pl File 229 B 0755
index.cgi File 1.49 KB 0755
log_parser.pl File 684 B 0755
module.info File 124 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 89 B 0644
module.info.ar File 0 B 0644
module.info.ar.auto File 141 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 158 B 0644
module.info.bg File 0 B 0644
module.info.bg.auto File 164 B 0644
module.info.ca File 91 B 0644
module.info.cs File 34 B 0644
module.info.cs.auto File 64 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 93 B 0644
module.info.de File 98 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 184 B 0644
module.info.es File 39 B 0644
module.info.es.auto File 60 B 0644
module.info.eu File 0 B 0644
module.info.eu.auto File 96 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 156 B 0644
module.info.fi File 0 B 0644
module.info.fi.auto File 92 B 0644
module.info.fr File 36 B 0644
module.info.fr.auto File 71 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 114 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 95 B 0644
module.info.hu File 32 B 0644
module.info.hu.auto File 65 B 0644
module.info.it File 0 B 0644
module.info.it.auto File 92 B 0644
module.info.ja File 0 B 0644
module.info.ja.auto File 124 B 0644
module.info.ko File 0 B 0644
module.info.ko.auto File 105 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 101 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 101 B 0644
module.info.ms File 92 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 93 B 0644
module.info.nl File 35 B 0644
module.info.nl.auto File 68 B 0644
module.info.no File 34 B 0644
module.info.no.auto File 57 B 0644
module.info.pl File 113 B 0644
module.info.pt File 0 B 0644
module.info.pt.auto File 104 B 0644
module.info.pt_BR File 0 B 0644
module.info.pt_BR.auto File 110 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 94 B 0644
module.info.ru File 0 B 0644
module.info.ru.auto File 176 B 0644
module.info.sk File 0 B 0644
module.info.sk.auto File 100 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 84 B 0644
module.info.sv File 0 B 0644
module.info.sv.auto File 88 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 205 B 0644
module.info.tr File 0 B 0644
module.info.tr.auto File 105 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 166 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 132 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 101 B 0644
module.info.zh File 0 B 0644
module.info.zh.auto File 82 B 0644
module.info.zh_TW File 0 B 0644
module.info.zh_TW.auto File 88 B 0644
run.cgi File 2.95 KB 0755