]>
git.proxmox.com Git - pve-manager.git/blob - PVE/APLInfo.pm
9 use POSIX
qw(strftime);
11 my $logfile = "/var/log/pveam.log";
13 # Default list of GPG keys allowed to sign aplinfo
15 #pub 1024D/5CAC72FE 2004-06-24
16 # Key fingerprint = 9ABD 7E02 AD24 3AD3 C2FB BCCC B0C1 CC22 5CAC 72FE
17 #uid Proxmox Support Team <support@proxmox.com>
20 '9ABD7E02AD243AD3C2FBBCCCB0C1CC225CAC72FE' => 1, # fingerprint support@proxmox.com
21 '25CAC72FE' => 1, # keyid support@proxmox.com
26 my $keyfile = '/usr/share/doc/pve-manager/support@proxmox.com.pubkey';
28 return system ("/usr/bin/gpg --batch --no-tty --status-fd=1 -q " .
29 "--logger-fd=1 --import $keyfile >>$logfile");
33 my ($logfd, $msg) = @_;
37 my $tstr = strftime
("%b %d %H:%M:%S", localtime);
39 foreach my $line (split (/\n/, $msg)) {
40 print $logfd "$tstr $line\n";
45 my ($ua, $url, $file, $logfh) = @_;
47 my $req = HTTP
::Request-
>new(GET
=> $url);
49 logmsg
($logfh, "start download $url");
50 my $res = $ua->request($req, $file);
52 if ($res->is_success) {
53 logmsg
($logfh, "download finished: " . $res->status_line);
57 logmsg
($logfh, "download failed: " . $res->status_line);
65 my $aplurl = "http://download.proxmox.com/appliances";
66 my $aplsrcurl = "$aplurl/aplinfo.dat.gz";
67 my $aplsigurl = "$aplurl/aplinfo.dat.asc";
70 if (($size = (-s
$logfile) || 0) > (1024*50)) {
71 system ("mv $logfile $logfile.0");
73 my $logfd = IO
::File-
>new (">>$logfile");
74 logmsg
($logfd, "starting update");
78 my $tmp = "/tmp/pveam.tmp.$$";
79 my $tmpgz = "$tmp.gz";
80 my $sigfn = "$tmp.asc";
82 # this code works for ftp and http
83 # always use passive ftp
84 local $ENV{FTP_PASSIVE
} = 1;
85 my $ua = LWP
::UserAgent-
>new;
86 $ua->agent("PVE/1.0");
89 $ua->proxy(['http'], $proxy);
95 if (url_get
($ua, $aplsigurl, $sigfn, $logfd) != 0) {
96 die "update failed - no signature\n";
99 if (url_get
($ua, $aplsrcurl, $tmpgz, $logfd) != 0) {
100 die "update failed - no data\n";
103 if (system ("zcat -f $tmpgz >$tmp 2>/dev/null") != 0) {
104 die "update failed: unable to unpack '$tmpgz'\n";
109 my $cmd = "/usr/bin/gpg --verify --batch --no-tty --status-fd=1 -q " .
110 "--logger-fd=1 $sigfn $tmp";
112 open (CMD
, "$cmd|") ||
113 die "unable to execute '$cmd': $!\n";
117 while (defined ($line = <CMD
>)) {
119 logmsg
($logfd, $line);
121 # code borrowed from SA
122 next if $line !~ /^\Q[GNUPG:]\E (?:VALID|GOOD)SIG (\S{8,40})/;
125 # we want either a keyid (8) or a fingerprint (40)
126 if (length $key > 8 && length $key < 40) {
127 substr($key, 8) = '';
129 # use the longest match we can find
130 $signer = $key if (length $key > length $signer) && $valid_keys->{$key};
135 die "unable to verify signature\n" if !$signer;
137 logmsg
($logfd, "signature valid: $signer");
141 my $fh = IO
::File-
>new ("<$tmp") ||
142 die "unable to open file '$tmp' - $!\n";
143 PVE
::Config
::read_aplinfo
($tmp, $fh, 1);
146 die "update failed: $@" if $@;
148 if (system ("mv $tmp /var/lib/pve-manager/apl-available 2>/dev/null") != 0) {
149 die "update failed: unable to store data\n";
152 logmsg
($logfd, "update sucessful");
162 logmsg
($logfd, $err);
175 my $filename = "/var/lib/pve-manager/apl-available";
177 if (! -f
$filename) {
178 system ("cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-available");
181 return PVE
::Config
::read_file
('aplinfo');
187 my $templates = load_data
();
189 return $template if !$templates;
191 my $d = $templates->{'all'}->{$template};
193 $template =~ s/\.tar\.gz$//;
194 $template =~ s/_i386$//;
196 return $template if !$d;
198 return "$d->{package}_$d->{version}";
204 my $templates = load_data
();
206 return undef if !$templates;
208 my $d = $templates->{'all'}->{$template};
216 my $templates = load_data
();
220 $html .= __
("<b>Welcome</b> to the Proxmox Virtual Environment!");
222 $html .= __
("For more information please visit our homepage at");
223 $html .= " <a href='http://www.proxmox.com' target='_blank'>www.proxmox.com</a>.";
225 return $html if !$templates;
227 # my $d = $templates->{'all'}->{"pve-web-news-$lang"} ||
228 my $d = $templates->{all
}->{'pve-web-news'};
232 return $d->{description
};