[ Avaa Bypassed ]




Upload:

Command:

www-data@3.128.197.221: ~ $
# pkgadd-lib.pl
# Functions for solaris package management

&foreign_require("proc", "proc-lib.pl");

sub list_package_system_commands
{
return ("pkginfo", "pkgadd", "pkgrm");
}

# list_packages([package]*)
# Fills the array %packages with a list of all packages
sub list_packages
{
local $i = 0;
local $list = join(' ', map { quotemeta($_) } @_);
local $_;
local %indexmap;
%packages = ( );
&open_execute_command(PKGINFO, "pkginfo -x $list", 1, 1);
while(<PKGINFO>) {
	if (/^(\S+)\s*(.*)/) {
		# Package name and description
		$packages{$i,'name'} = $1;
		$packages{$i,'desc'} = $2;
		$indexmap{$1} = $i;
                $i++;
		}
	elsif (/^\s+\((\S+)\)\s*(\S+)/) {
		# Arch and version
		$packages{($i-1),'arch'} = $1;
		$packages{($i-1),'version'} = $2;
		$packages{($i-1),'shortversion'} = $2;
		$packages{($i-1),'shortversion'} =~ s/,REV=.*//;
		}
	}
close(PKGINFO);

# Call pkginfo to get classes
&open_execute_command(PKGINFO, "pkginfo $list", 1, 1);
while(<PKGINFO>) {
	last if (/The following software/i);
	if (/^(\S+)\s+(\S+)\s+(.*)$/) {
		local $idx = $indexmap{$2};
		if (defined($idx)) {
			$packages{$idx,'class'} = $1;
			}
		}
	}
close(PKGINFO);
return $i;
}

# package_info(package)
# Returns an array of package information in the order
#  name, class, description, arch, version, vendor, installtime
sub package_info
{
local($out, @rv);
local $qm = quotemeta($_[0]);
$out = &backquote_command("pkginfo -l $qm 2>&1", 1);
if ($out =~ /^ERROR:/) { return (); }
push(@rv, $_[0]);
push(@rv, $out =~ /CATEGORY:\s+(.*)\n/ ? $1 : "");
push(@rv, $out =~ /DESC:\s+(.*)\n/ ? $1 :
	  $out =~ /NAME:\s+(.*)\n/ ? $1 : $_[0]);
push(@rv, $out =~ /ARCH:\s+(.*)\n/ ? $1 : $text{'pkgadd_unknown'});
push(@rv, $out =~ /VERSION:\s+(.*)\n/ ? $1 : $text{'pkgadd_unknown'});
push(@rv, $out =~ /VENDOR:\s+(.*)\n/ ? $1 : $text{'pkgadd_unknown'});
push(@rv, $out =~ /INSTDATE:\s+(.*)\n/ ? $1 : $text{'pkgadd_unknown'});
return @rv;
}

# is_package(file)
# Tests if some file is a valid package file
sub is_package
{
local $real = &translate_filename($_[0]);
local $qm = quotemeta($_[0]);
if (-d $real && !-r "$real/pkginfo") {
	# A directory .. see if it contains any package files
	local $rv = 0;
	opendir(DIR, $real);
	foreach $f (readdir(DIR)) {
		next if ($f eq "." || $f eq "..");
		if (&is_package("$_[0]/$f")) {
			$rv = 1;
			last;
			}
		}
	closedir(DIR);
	return $rv;
	}
elsif ($real =~ /\*|\?/) {
	# a wildcard .. see what it matches
	# XXX won't work under translation
	local $f;
	foreach $f (glob($real)) {
		if (&is_package($f)) {
			$rv = 1;
			last;
			}
		}
	return $rv;
	}
else {
	# just a normal file - see if it is a package
	local $out = &backquote_command("pkginfo -d $qm 2>/dev/null");
	return !$? && $out !~ /ERROR/;
	}
}

# file_packages(file)
# Returns a list of all packages in the given file, directory or glob, as an
# array of strings in the form
#  package description
sub file_packages
{
local $real = &translate_filename($_[0]);
local $qm = quotemeta($_[0]);
if (-d $real && !-r "$real/pkgproto") {
	# Scan directory for packages
	local ($f, @rv);
	opendir(DIR, $real);
	while($f = readdir(DIR)) {
		if (&is_package("$_[0]/$f")) {
			local @pkg = &file_packages("$_[0]/$f");
			push(@rv, @pkg);
			}
		}
	closedir(DIR);
	return @rv;
	}
elsif ($real =~ /\*|\?/) {
	# Expand glob of packages
	# XXX won't work under translation
	local ($f, @rv);
	foreach $f (glob($real)) {
		local @pkg = &file_packages($f);
		push(@rv, @pkg);
		}
	return @rv;
	}
else {
	# Just one package file
	local @rv;
	&open_execute_command(OUT, "pkginfo -d $qm", 1, 1);
	while(<OUT>) {
		if (/^(\S+)\s+(\S+)\s+(\S.*)/) {
			push(@rv, "$2 $3");
			}
		}
	close(OUT);
	return @rv;
	}
}

# install_options(file, package)
# Outputs HTML for choosing install options
sub install_options
{
print &ui_table_row(&hlink($text{'pkgadd_root'}, "root"),
	&ui_textbox("root", "/", 50)." ".
	&file_chooser_button("root", 1), 3);
}

# install_package(file, package)
# Installs the package in the given file, with options from %in
sub install_package
{
local(@opts, %seen, $wf, $rv, $old_input);
local $real = &translate_filename($_[0]);
local $qm = quotemeta($_[0]);
local $in = $_[2] ? $_[2] : \%in;
local $has_postinstall = 0; #detect if contains postinstall script

if ($in->{'root'} =~ /^\/.+/) {
	if (!(-d $in->{'root'})) { &error(&text('pkgadd_eroot', $in->{'root'})); }
	push(@opts, "-R", $in->{'root'});
	}
if ($in->{'adminfile'} ne '') {
	push(@opts, "-a", $in->{'adminfile'});
	}
if (-d $real && !-r "$real/pkgproto") {
	# Install one package from a file in this directory
	local $f;
	opendir(DIR, $real);
	while($f = readdir(DIR)) {
		if (&is_package("$_[0]/$f")) {
			local @pkg = &file_packages("$_[0]/$f");
			foreach $pkg (@pkg) {
				local ($name, $desc) = split(/\s+/, $pkg);
				if ($name eq $_[1]) {
					return &install_package("$_[0]/$f", $name);
					}
				}
			}
		}
	closedir(DIR);
	return "Failed to find package $_[1]";
	}
elsif ($real =~ /\?|\*/) {
	# Install one package from a file that matches a glob
	local $f;
	foreach $f (glob($real)) {
		if (&is_package($f)) {
			local @pkg = &file_packages($f);
			foreach $pkg (@pkg) {
				local ($name, $desc) = split(/\s+/, $pkg);
				if ($name eq $_[1]) {
					return &install_package($f, $name);
					}
				}
			}
		}
	return "Failed to find package $_[1]";
	}
else {
	# Install just one package
	local ($ph, $ppid) = &foreign_call("proc", "pty_process_exec_logged",
			   "pkgadd -d $_[0] ".join(" ",@opts)." $_[1]");

	while(1) {
		$wf = &wait_for($ph, '(.*) \[\S+\]',
			     '(This package contains scripts|Executing checkinstall script)',
			     'Installation of .* failed',
			     'Installation of .* was successful',
			     'No changes were made to the system',
			     '\n\/.*\n');
		if ($wf == 0) {
			# some question which should not have appeared before
			if ($seen{$matches[1]}++ > 3) {
				$rv = "<pre>$old_input$wait_for_input</pre>";
				last;
				}
			&sysprint($ph, "y\n");
			}
		elsif ($wf == 1) {
			# This package contains scripts requiring output to
			# be sent to /dev/null.  Abort & redo.
			$rv = undef;
			$has_postinstall = 1;
			&sysprint($ph, "n\n");
			#let the next elsif catch that 'no changes were made'
			#to complete the pkgadd execution.
			}
		elsif ($wf == 2 || $wf == 4 || $wf == -1) {
			# failed for some reason.. give up
			$rv = "<pre>$old_input$wait_for_input</pre>";
			last;
			}
		elsif ($wf == 3) {
			# done ok!
			$rv = undef;
			last;
			}
		$old_input = $wait_for_input;
		}
	close($ph);

	if ($has_postinstall) {
		# Handle case where pkg has scripts that cause pkgadd to open
		# /dev/tty
		my $ret = system_logged("pkgadd -n -a pkgadd-no-ask -d $_[0] ".
					join(" ",@opts).
					" $_[1] 2>&1 > /dev/null")/256;
		#only exit values of 1 & 3 are errors (see pkgadd(1M))
		$rv = ($ret == 1 || $ret == 3)? "pkgadd returned $ret" : undef;
		}

	return $rv;
	}
}


# check_files(package)
# Fills in the %files array with information about the files belonging
# to some package. Values in %files are  path type user group mode size error
sub check_files
{
local($i, %errs, $curr, $line, %file);
undef(%files);
local $qm = quotemeta($_[0]);
$chk = &backquote_command("pkgchk -n $qm 2>&1", 1);
while($chk =~ /^(\S+): (\S+)\n((\s+.*\n)+)([\0-\177]*)$/) {
	if ($1 eq "ERROR") { $errs{$2} = $3; }
	$chk = $5;
	}

&open_execute_command(CHK, "pkgchk -l $qm 2>&1", 1, 1);
FILES: for($i=0; 1; $i++) {
	# read one package
	$curr = "";
	while(1) {
		if (!($line = <CHK>)) { last FILES; }
		if ($line =~ /Current status/) { $line = <CHK>; last; }
		$curr .= $line;
		}

	# extract information
	&parse_pkgchk($curr);
	foreach $k (keys %file) { $files{$i,$k} = $file{$k}; }
	$files{$i,'error'} = $errs{$files{$i,'path'}};
	}
close(CHK);
return $i;
}

# installed_file(file)
# Given a filename, fills %file with details of the given file and returns 1.
# If the file is not known to the package system, returns 0
# Usable values in %file are  path type user group mode size packages
sub installed_file
{
local $temp = &transname();
&open_tempfile(TEMP, ">$temp", 0, 1, 1);
print TEMP "$_[0]\n";
close(TEMP);

$out = &backquote_command("pkgchk -l -i $temp 2>&1", 1);
&unlink_file($temp);
if ($out =~ /\S/) {
	&parse_pkgchk($out);
	return 1;
	}
else { return 0; }
}

# delete_package(package)
# Totally remove some package
sub delete_package
{
local($ph, $pth, $ppid, $wf, %seen, $old_input);
local ($ph, $ppid) = &foreign_call("proc", "pty_process_exec_logged",
				   "pkgrm $_[0]");
if (&wait_for($ph, 'remove this package', 'ERROR')) {
	return "package does not exist";
	}
&sysprint($ph, "y\n");
while(1) {
	$wf = &wait_for($ph, '(.*) \[\S+\]',
			     'Removal of \S+ failed',
			     'Removal of \S+ was successful',
			     '\n\/.*\n');
	if ($wf == 0) {
		# some question which should not have appeared before
		if ($seen{$matches[1]}++) {
			$rv = "<pre>$old_input$wait_for_input</pre>";
			last;
			}
		&sysprint($ph, "y\n");
		}
	elsif ($wf == 1) {
		# failed for some reason.. give up
		$rv = "<pre>$old_input$wait_for_input</pre>";
		last;
		}
	elsif ($wf == 2) {
		# done ok!
		$rv = undef;
		last;
		}
	$old_input = $wait_for_input;
	}
close($ph);
return $rv;
}

# parse_pkgchk(output)
# Parse output about one file from pkgchk into the array %file
sub parse_pkgchk
{
undef(%file);
if ($_[0] =~ /Pathname:\s+(.*)/) { $file{'path'} = $1; }
if ($_[0] =~ /Type:\s+(.*)/) {
	$file{'type'} = $1 eq "regular file" ? 0 :
			$1 eq "directory" ? 1 :
			$1 eq "special file" ? 2 :
			$1 eq "symbolic link" ? 3 :
			$1 eq "linked file" ? 4 :
			$1 eq "volatile file" ? 5 :
			$1 eq "editted file" ? 5 :
			$1 eq "edited file" ? 5 :
			-1;
	}
if ($_[0] =~ /Source of link:\s+(\S+)/) { $file{'link'} = $1; }
if ($_[0] =~ /Expected owner:\s+(\S+)/) { $file{'user'} = $1; }
if ($_[0] =~ /Expected group:\s+(\S+)/) { $file{'group'} = $1; }
if ($_[0] =~ /Expected mode:\s+(\S+)/) { $file{'mode'} = $1; }
if ($_[0] =~ /size \(bytes\):\s+(\d+)/) { $file{'size'} = $1; }
if ($_[0] =~ /following packages:\n(((\s+.*\n)|\n)+)/)
	{ $file{'packages'} = join(' ', grep { $_ ne '' } split(/\s+/, $1)); }
}


sub package_system
{
return $text{'pkgadd_manager'};
}

sub package_help
{
return "pkgadd pkginfo pkgchk pkgrm";
}

1;


Filemanager

Name Type Size Permission Actions
help Folder 0755
images Folder 0755
lang Folder 0755
CHANGELOG File 2.82 KB 0644
aix-lib.pl File 19.2 KB 0755
apt-lib.pl File 14.09 KB 0755
apt_upgrade.cgi File 1.97 KB 0755
cgi_args.pl File 524 B 0755
close.cgi File 263 B 0755
config-aix File 30 B 0644
config-cobalt-linux File 30 B 0644
config-coherent-linux File 30 B 0644
config-corel-linux File 33 B 0644
config-cygwin File 33 B 0644
config-debian-linux File 51 B 0644
config-freebsd File 54 B 0644
config-freebsd-8.4-ALL File 52 B 0644
config-gentoo-linux File 33 B 0644
config-hpux File 31 B 0644
config-mandrake-linux File 30 B 0644
config-msc-linux File 30 B 0644
config-netbsd File 34 B 0644
config-open-linux File 30 B 0644
config-openSUSE-Linux-15.0-ALL File 30 B 0644
config-openbsd File 34 B 0644
config-openmamba-linux File 48 B 0644
config-openserver File 33 B 0644
config-redhat-linux File 48 B 0644
config-slackware-linux File 36 B 0644
config-solaris File 33 B 0644
config-suse-linux File 30 B 0644
config-syno-linux File 50 B 0644
config-trustix-linux File 30 B 0644
config-turbo-linux File 30 B 0644
config-united-linux File 30 B 0644
config-unixware File 33 B 0644
config-windows File 30 B 0644
config.info File 511 B 0644
config.info.ca File 554 B 0644
config.info.cs File 372 B 0644
config.info.de File 523 B 0644
config.info.es File 320 B 0644
config.info.fr File 135 B 0644
config.info.ja File 428 B 0644
config.info.ko File 409 B 0644
config.info.ms File 411 B 0644
config.info.nl File 415 B 0644
config.info.no File 424 B 0644
config.info.pl File 392 B 0644
config.info.ru File 175 B 0644
config.info.sv File 224 B 0644
config.info.tr File 123 B 0644
config.info.uk File 174 B 0644
config.info.zh File 122 B 0644
config.info.zh_TW File 125 B 0644
csw-lib.pl File 2.69 KB 0755
cygwin-lib.pl File 22.34 KB 0755
debian-lib.pl File 6.67 KB 0755
delete_file.cgi File 239 B 0755
delete_pack.cgi File 1.46 KB 0755
delete_packs.cgi File 1.85 KB 0755
do_install.cgi File 2.67 KB 0755
edit_pack.cgi File 1.13 KB 0755
emerge-lib.pl File 7.65 KB 0755
file_info.cgi File 2.09 KB 0755
find.cgi File 1.63 KB 0755
freebsd-lib.pl File 7.95 KB 0755
hpux-lib.pl File 8.01 KB 0755
index.cgi File 3 KB 0755
install_pack.cgi File 4.71 KB 0755
ipkg-close.cgi File 269 B 0755
ipkg-edit_pack.cgi File 1.45 KB 0755
ipkg-lib.pl File 7.78 KB 0755
ipkg-open.cgi File 243 B 0755
ipkg-tree.cgi File 4 KB 0755
ipkg_upgrade.cgi File 926 B 0755
list_pack.cgi File 1.85 KB 0755
log_parser.pl File 1.34 KB 0755
module.info File 484 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 127 B 0644
module.info.ar File 0 B 0644
module.info.ar.auto File 170 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 216 B 0644
module.info.bg File 0 B 0644
module.info.bg.auto File 214 B 0644
module.info.ca File 116 B 0644
module.info.ca.auto File 21 B 0644
module.info.cs File 30 B 0644
module.info.cs.auto File 114 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 124 B 0644
module.info.de File 106 B 0644
module.info.de.auto File 21 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 220 B 0644
module.info.es File 29 B 0644
module.info.es.auto File 106 B 0644
module.info.eu File 0 B 0644
module.info.eu.auto File 129 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 215 B 0644
module.info.fi File 0 B 0644
module.info.fi.auto File 130 B 0644
module.info.fr File 29 B 0644
module.info.fr.auto File 117 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 152 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 138 B 0644
module.info.hu File 38 B 0644
module.info.hu.auto File 108 B 0644
module.info.it File 0 B 0644
module.info.it.auto File 134 B 0644
module.info.ja File 43 B 0644
module.info.ja.auto File 157 B 0644
module.info.ko File 34 B 0644
module.info.ko.auto File 128 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 162 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 151 B 0644
module.info.ms File 104 B 0644
module.info.ms.auto File 18 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 150 B 0644
module.info.nl File 27 B 0644
module.info.nl.auto File 104 B 0644
module.info.no File 26 B 0644
module.info.no.auto File 107 B 0644
module.info.pl File 121 B 0644
module.info.pl.auto File 21 B 0644
module.info.pt File 28 B 0644
module.info.pt.auto File 102 B 0644
module.info.pt_BR File 0 B 0644
module.info.pt_BR.auto File 139 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 134 B 0644
module.info.ru File 30 B 0644
module.info.ru.auto File 205 B 0644
module.info.sk File 0 B 0644
module.info.sk.auto File 145 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 132 B 0644
module.info.sv File 21 B 0644
module.info.sv.auto File 100 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 253 B 0644
module.info.tr File 28 B 0644
module.info.tr.auto File 107 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 202 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 208 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 144 B 0644
module.info.zh File 18 B 0644
module.info.zh.auto File 91 B 0644
module.info.zh_TW File 24 B 0644
module.info.zh_TW.auto File 97 B 0644
msi-lib.pl File 8.45 KB 0755
open.cgi File 238 B 0755
openbsd-lib.pl File 4.72 KB 0755
pkg-lib.pl File 2.5 KB 0644
pkgadd-lib.pl File 9.97 KB 0755
pkgadd-no-ask File 164 B 0644
pkgsrc-lib.pl File 7.24 KB 0644
ports-lib.pl File 3.49 KB 0644
ports_upgrade.cgi File 501 B 0755
rhn-lib.pl File 3.02 KB 0755
rhn.cgi File 1.3 KB 0755
rhn_check.cgi File 1.84 KB 0755
rpm-lib.pl File 11.24 KB 0755
rpmfind.cgi File 2.11 KB 0755
search.cgi File 2.27 KB 0755
slackware-lib.pl File 6.95 KB 0755
software-lib.pl File 7.57 KB 0755
tree.cgi File 3.79 KB 0755
urpmi-lib.pl File 2.14 KB 0755
urpmi_upgrade.cgi File 839 B 0755
view.cgi File 931 B 0755
yum-lib.pl File 13.06 KB 0755
yum_upgrade.cgi File 908 B 0755