[ Avaa Bypassed ]




Upload:

Command:

www-data@18.218.26.136: ~ $
#!/usr/bin/perl
# Create, update or delete a target

use strict;
use warnings;
no warnings 'redefine';
no warnings 'uninitialized';
require './iscsi-tgtd-lib.pl';
our (%text, %in, %config);
&ReadParse();
&error_setup($text{'target_err'});
my $conf = &get_tgtd_config();

# Get the target
my $target;
my $addfile;
if ($in{'new'}) {
	$target = { 'name' => 'target',
		    'type' => 1,
		    'members' => [ ] };
	if (-d $config{'add_file'}) {
		$addfile = $config{'add_file'}."/".$in{'name'}.".conf";
		}
	elsif ($config{'add_file'}) {
		$addfile = $config{'add_file'};
		}
	}
else {
	($target) = grep { $_->{'value'} eq $in{'oldname'} }
			 &find($conf, "Target");
	$target || &error($text{'target_egone'});
	}
my $lockfile = $target->{'file'} || $addfile;
&lock_file($lockfile);

if ($in{'delete'}) {
	# Delete the target
	&save_directive($conf, $target, undef);
	&delete_if_empty($target->{'file'});
	}
else {
	# Validate and save directives, starting with target name
	my $host;
	if ($in{'new'}) {
		$host = &find_host_name($conf) || &generate_host_name();
		}
	else {
		($host) = split(/:/, $target->{'value'});
		}
	$in{'name'} =~ /^[a-z0-9\.\_\-]+$/i || &error($text{'target_ename'});
	$target->{'value'} = $host.":".$in{'name'};

	# Validate logical units
	my @luns = (&find($target->{'members'}, "backing-store"),
		    &find($target->{'members'}, "direct-store"));
	@luns = sort { $a->{'file'} <=> $b->{'file'} } @luns;
	my (@backluns, @directluns);
	for(my $i=0; defined($in{"mode".$i}); $i++) {
		my $path;
		if ($in{"mode".$i} eq "none") {
			# Nothing to do
			next;
			}
		elsif ($in{"mode".$i} eq "part") {
			# Regular partition
			$path = $in{"part".$i};
			}
		elsif ($in{"mode".$i} eq "raid") {
			# RAID device
			$path = $in{"raid".$i};
			}
		elsif ($in{"mode".$i} eq "lvm") {
			# LVM logical volume
			$path = $in{"lvm".$i};
			}
		elsif ($in{"mode".$i} eq "other") {
			# Some other file
			$in{"other".$i} =~ /^\/\S+$/ && -r $in{"other".$i} ||
				&error(&text('target_eother', $i+1));
			$path = $in{"other".$i};
			}
		my $newlun = $i >= @luns ? { } : $luns[$i];
		$newlun->{'name'} = $in{"type".$i};
		$newlun->{'value'} = $path;
		my $cache = $in{"cache".$i} ? { 'name' => 'write-cache',
						'value' => $in{"cache".$i} }
					    : undef;
		&save_directive($conf, "write-cache", $cache, $newlun);
		if ($newlun->{'name'} eq "backing-store") {
			push(@backluns, $newlun);
			}
		else {
			push(@directluns, $newlun);
			}
		}
	&save_multiple_directives($conf, "backing-store", \@backluns, $target);
	&save_multiple_directives($conf, "direct-store", \@directluns,$target);

	# Validate incoming user(s)
	my @iusers;
	if (!$in{"iuser_def"}) {
		for(my $i=0; defined($in{"uname_$i"}); $i++) {
			next if (!$in{"uname_$i"});
			$in{"uname_$i"} =~ /^\S+$/ ||
				&error(&text('target_eiuser', $i+1));
			$in{"upass_$i"} =~ /^\S+$/ ||
				&error(&text('target_eipass', $i+1));
			push(@iusers,
			    { 'name' => 'incominguser',
			      'value' => $in{"uname_$i"}." ".$in{"upass_$i"} });
			}
		@iusers || &error($text{'target_eiusernone'});
		}
	&save_multiple_directives($conf, "incominguser", \@iusers, $target);

	# Validate outgoing user(s)
	if (!$in{"ouser_def"}) {
                $in{"ouser"} =~ /^\S+$/ || &error($text{'target_eouser'});
                $in{"opass"} =~ /^\S+$/ || &error($text{'target_eopass'});
		my $ouser = { 'name' => "outgoinguser",
			      'value' => $in{"ouser"}." ".$in{"opass"} };
		&save_directive($conf, "outgoinguser", $ouser, $target);
		}
	else {
		&save_directive($conf, "outgoinguser", undef, $target);
		}

	# Save allowed IPs
	my @addrs;
	if (!$in{"iaddress_def"}) {
		foreach my $a (split(/\s+/, $in{"iaddress"})) {
			&check_ipaddress($a) || &error($text{'target_eaddr'});
			push(@addrs, { 'name' => "initiator-address",
				       'value' => $a });
			}
		}
	&save_multiple_directives($conf, "initiator-address", \@addrs, $target);

	# Save allowed initiators
	my @names;
	if (!$in{"iname_def"}) {
		foreach my $a (split(/\s+/, $in{"iname"})) {
			$a =~ /^[:a-z0-9\.\_\-]+$/i ||
				&error($text{'target_eaname'});
			push(@names, { 'name' => "initiator-name",
				       'value' => $a });
			}
		}
	&save_multiple_directives($conf, "initiator-name", \@names, $target);

	# Save the target
	if ($in{'new'}) {
		&save_directive($conf, undef, $target, undef, $addfile);
		}
	else {
		&save_directive($conf, $target, $target);
		}
	}

&flush_file_lines();
&unlock_file($lockfile);
&webmin_log($in{'delete'} ? 'delete' : $in{'new'} ? 'create' : 'modify',
	    'target', $target->{'value'});
&redirect("");

Filemanager

Name Type Size Permission Actions
images Folder 0755
lang Folder 0755
CHANGELOG File 127 B 0644
atboot.cgi File 711 B 0755
config File 70 B 0644
config-AlmaLinux-7.0-ALL File 184 B 0644
config-Amazon-Linux-2-ALL File 184 B 0644
config-CentOS-Linux-7.0-ALL File 184 B 0644
config-CentOS-Stream-Linux-8.0-ALL File 184 B 0644
config-CloudLinux-8.0-ALL File 184 B 0644
config-Oracle-Linux-8.0-ALL File 184 B 0644
config-Redhat-Enterprise-Linux-7.0-ALL File 184 B 0644
config-Rocky-Linux-7.0-ALL File 184 B 0644
config-Scientific-Linux-7.0-ALL File 184 B 0644
config-debian-linux File 92 B 0644
config-redhat-linux File 128 B 0644
config-syno-linux File 70 B 0644
config.info File 421 B 0644
config.info.ca File 492 B 0644
config.info.de File 496 B 0644
config.info.no File 445 B 0644
delete_targets.cgi File 980 B 0755
edit_manual.cgi File 1.05 KB 0755
edit_target.cgi File 5.41 KB 0755
index.cgi File 2.75 KB 0755
install_check.pl File 346 B 0755
iscsi-tgtd-lib.pl File 11.66 KB 0644
log_parser.pl File 457 B 0755
module.info File 196 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 121 B 0644
module.info.ar File 0 B 0644
module.info.ar.auto File 146 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 190 B 0644
module.info.bg File 0 B 0644
module.info.bg.auto File 175 B 0644
module.info.ca File 137 B 0644
module.info.cs File 0 B 0644
module.info.cs.auto File 113 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 112 B 0644
module.info.de File 115 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 216 B 0644
module.info.es File 0 B 0644
module.info.es.auto File 133 B 0644
module.info.eu File 0 B 0644
module.info.eu.auto File 102 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 175 B 0644
module.info.fi File 0 B 0644
module.info.fi.auto File 108 B 0644
module.info.fr File 0 B 0644
module.info.fr.auto File 136 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 138 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 114 B 0644
module.info.hu File 0 B 0644
module.info.hu.auto File 142 B 0644
module.info.it File 0 B 0644
module.info.it.auto File 135 B 0644
module.info.ja File 0 B 0644
module.info.ja.auto File 164 B 0644
module.info.ko File 0 B 0644
module.info.ko.auto File 150 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 129 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 119 B 0644
module.info.ms File 0 B 0644
module.info.ms.auto File 119 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 119 B 0644
module.info.nl File 0 B 0644
module.info.nl.auto File 123 B 0644
module.info.no File 0 B 0644
module.info.no.auto File 111 B 0644
module.info.pl File 0 B 0644
module.info.pl.auto File 117 B 0644
module.info.pt File 0 B 0644
module.info.pt.auto File 119 B 0644
module.info.pt_BR File 0 B 0644
module.info.pt_BR.auto File 125 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 120 B 0644
module.info.ru File 0 B 0644
module.info.ru.auto File 208 B 0644
module.info.sk File 0 B 0644
module.info.sk.auto File 111 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 102 B 0644
module.info.sv File 0 B 0644
module.info.sv.auto File 105 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 224 B 0644
module.info.tr File 0 B 0644
module.info.tr.auto File 123 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 177 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 243 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 120 B 0644
module.info.zh File 0 B 0644
module.info.zh.auto File 104 B 0644
module.info.zh_TW File 0 B 0644
module.info.zh_TW.auto File 110 B 0644
restart.cgi File 351 B 0755
save_manual.cgi File 684 B 0755
save_target.cgi File 4.47 KB 0755
start.cgi File 328 B 0755
stop.cgi File 303 B 0755