Handle hostnames with upper-case letters
[webmin.git] / webmin / update.cgi
1 #!/usr/local/bin/perl
2 # update.cgi
3 # Find and install modules that need updating
4
5 require './webmin-lib.pl';
6 &ReadParse();
7 &error_setup($text{'update_err'});
8
9 # Display the results and maybe take action
10 $| = 1;
11 $theme_no_table = 1;
12 &ui_print_header(undef, $text{'update_title'}, "");
13
14 print "<b>",&text('update_info'),"</b><p>\n";
15
16 # Fetch updates
17 @urls = $in{'source'} == 0 ? ( $update_url ) : split(/\r?\n/, $in{'other'});
18 $count = 0;
19 foreach $url (@urls) {
20         # Get updates from this URL, and filter to those for this system
21         $checksig = $in{'checksig'} ? 2 : $url eq $update_url ? 2 : 1;
22         ($updates, $host, $port, $page, $ssl) =
23                 &fetch_updates($url, $in{'upuser'}, $in{'uppass'}, $checksig);
24         $updates = &filter_updates($updates, undef,
25                                    $in{'third'}, $in{'missing'});
26         $count += scalar(@$updates);
27         foreach $u (@$updates) {
28                 # Get module or theme's details
29                 my %minfo = &get_module_info($u->[0]);
30                 my %tinfo = &get_theme_info($u->[0]);
31                 my %info = %minfo ? %minfo : %tinfo;
32
33                 if ($in{'show'}) {
34                         # Just tell the user what would be done
35                         print &text('update_mshow', "<b>$u->[0]</b>", "<b>$u->[1]</b>"),
36                               "<br>\n";
37                         print "&nbsp;" x 10;
38                         print "$text{'update_fixes'} : " if ($info{'longdesc'});
39                         print $u->[4],"<p>\n";
40                         $donemodule{$u->[0]} = 1;
41                         }
42                 else {
43                         # Actually do the update ..
44                         my (@mdescs, @mdirs, @msizes);
45                         print &text('update_mok', "<b>$u->[0]</b>", "<b>$u->[1]</b>"),
46                               "<br>\n";
47                         print "&nbsp;" x 10;
48                         print "$text{'update_fixes'} : " if ($info{'longdesc'});
49                         print $u->[4],"<br>\n";
50                         ($mhost, $mport, $mpage, $mssl) =
51                                 &parse_http_url($u->[2], $host, $port, $page, $ssl);
52                         ($mfile = $mpage) =~ s/^(.*)\///;
53                         $mtemp = &transname($mfile);
54                         $progress_callback_url = $u->[2];
55                         $progress_callback_prefix = "&nbsp;" x 10;
56                         &http_download($mhost, $mport, $mpage, $mtemp, undef,
57                                        \&progress_callback, $mssl,
58                                        $in{'upuser'}, $in{'uppass'});
59                         $irv = &check_update_signature($mhost, $mport, $mpage,
60                                         $mssl, $in{'upuser'}, $in{'uppass'},
61                                         $mtemp, $checksig);
62                         $irv ||= &install_webmin_module($mtemp, 1, 0,
63                                               [ $base_remote_user ]);
64                         print "&nbsp;" x 10;
65                         if (!ref($irv)) {
66                                 print &text('update_failed', $irv),"<p>\n";
67                                 }
68                         else {
69                                 print &text('update_mdesc', "<b>$irv->[0]->[0]</b>",
70                                             "<b>$irv->[2]->[0]</b>"),"<p>\n";
71                                 $donemodule{$irv->[0]->[0]} = 1;
72                                 }
73                         }
74                 }
75         }
76 print &text('update_none'),"<br>\n" if (!$count);
77
78 # Check if a new version of webmin itself is available
79 $version = &get_latest_webmin_version();
80 if ($version > &get_webmin_version()) {
81         print "<b>",&text('update_version', $version),"</b><p>\n";
82         }
83
84 &ui_print_footer("", $text{'index_return'});
85