#!/usr/local/bin/perl # # DESCRIPTION # # $Id:$ # # Copyright (C) 1997-2003 Kees Cook # kees@outflux.net, http://outflux.net/ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # http://www.gnu.org/copyleft/gpl.html # $|=1; require "cgi-lib.pl"; &ReadParse; print "Content-type: text/html HPUX Patches

Available Patches from Hewlett Packard

This takes a short bit of time. Please be patient.
Loading recommended list...
\n"; # for POST debugging #foreach $key (keys %in) { # print "${key}='${in{$key}}'
\n"; #} $installed = " "; foreach (grep(/^..PH[A-Z]{2}_\d+/,`/usr/sbin/swlist`)) { /^..(PH[A-Z]{2}_\d+)\s+/; $installed .= "$1 "; } $sortby = $in{'sortby'}; $sortby = "recommended patches" if (!defined($sortby)); $howmatch = $in{'howmatch'}; $howmatch = "" if (!defined($howmatch)); $matching = $in{'matching'}; $matching = "" if (!defined($matching)); $tomatch = ".*"; $tomatch = $matching if ($matching ne ""); print "Loading patch list...
\n"; open(DB,") { ($key,@rest) = split(/\n/,$_); ($patches{$key}{'name'}, $patches{$key}{'path'}, $patches{$key}{'size'}, $patches{$key}{'critical'}, $patches{$key}{'reboot'}, $patches{$key}{'description'}, $patches{$key}{'super'} ) = ($key,@rest); $patches{$key}{'date'} = (lstat($patches{$key}{'path'}))[9]; $patches{$key}{'recommended patches'} = 2; $patches{$key}{'recommended patches'} = 1 if ($installed =~ / $key /); @words=split(/\s+/,$patches{$key}{'super'}); $patches{$key}{'super'} = ""; while (@words) { $patches{$key}{'super'} .= " " . shift(@words) . " " . shift(@words) . " " . shift(@words) . " " . shift(@words) . " " . shift(@words) . " " . shift(@words) . "\n" } } close(DB); #print "This tool is still being developed. Not all the searches work correctly yet.
\n"; print "

For text matching, patch name and patch description will be searched.
\n"; print "For description file matching, patch description file will be searched.
\n"; print "All searches use standard regular expression matching.
\n"; printf "

Sort the patches using ", $sortby eq "name" ? " selected" : "", $sortby eq "size" ? " selected" : "", $sortby eq "description" ? " selected" : "", $sortby eq "reboot" ? " selected" : "", $sortby eq "critical" ? " selected" : "", $sortby eq "date" ? " selected" : "", $sortby eq "recommended patches" ? " selected" : "" ; printf " ", $howmatch =~ /with text matching/ ? " selected" : "", $howmatch =~ /with contents of description file matching/ ? " selected" : ""; printf "

"; print " Patches denoted with a star (*) are recommended patches.
  Patch Name   Size     Critical Reboot Post Date
  ------------ -------- ---      ---    -----------
";

$buff = "%s %s%s %8d %-3s      %-3s    %s
               %s
%s\n";

foreach $patch (sort MySort keys %patches) {
	$posted = scalar(localtime($patches{$patch}{'date'}));
	$posted =~ s/^\S+\s+(\S+) (..)\s+\S+\s+(\S+)$/\1 \2 \3/i;

        printf($buff,
	$patches{$patch}{'recommended patches'} == 1 ? "*" : " ",
	$patches{$patch}{'path'},
	$patches{$patch}{'name'},
	&Filler(12-length($patch)),
	$patches{$patch}{'size'},
	$patches{$patch}{'critical'} == 1 ? "Yes" : "No",
	$patches{$patch}{'reboot'} == 1 ? "Yes" : "No",
	$posted,
	$patches{$patch}{'path'} . ".txt",
	$patches{$patch}{'description'},
	$patches{$patch}{'super'}
	)
		if (&Match($patch));

}

print 
"  ------------ -------- ---      ---   ----------- 
  Patch Name   Size     Critical Reboot Post Date
"; dbmclose(%record); sub Match { local($patch) = @_; local($result); return 1 if (!$tomatch || $tomatch =~ /^\.\*$/ || $tomatch =~ /^$/); if ($howmatch =~ /text/) { if ($patches{$patch}{'description'} =~ /($tomatch)/i) { $patches{$patch}{'description'} = $` . "" . $1 . "" . $'; return 1; } if ($patches{$patch}{'name'} =~ /($tomatch)/i) { $patches{$patch}{'name'} = $` . "" . $1 . "" . $'; return 1; } if ($patches{$patch}{'super'} =~ /($tomatch)/i) { $patches{$patch}{'super'} = $` . "" . $1 . "" . $'; return 1; } } elsif ($howmatch =~ /file/) { $result=0; open(FILE,"<$patches{$patch}{'path'}.txt"); $result=grep(/$tomatch/i,); close(FILE); return $result>0; } return undef; } sub Filler { local($howmuch) = @_; sprintf("%${howmuch}s",""); } sub MySort { if ($patches{$a}{$sortby} > 0 && $patches{$b}{$sortby} > 0) { $patches{$a}{$sortby} <=> $patches{$b}{$sortby}; } else { $patches{$a}{$sortby} cmp $patches{$b}{$sortby}; } }