Hello community, here is the log from the commit of package suseRegister checked in at Thu Apr 20 17:56:19 CEST 2006. -------- --- suseRegister/suseRegister.changes 2006-04-07 17:32:12.000000000 +0200 +++ STABLE/suseRegister/suseRegister.changes 2006-04-20 17:09:34.000000000 +0200 @@ -1,0 +2,6 @@ +Thu Apr 20 17:07:08 CEST 2006 - mc@suse.de + +- switch back to curl to provide correct https proxy support + [fix part of #165891] + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ suseRegister.spec ++++++ --- /var/tmp/diff_new_pack.7DGdbh/_old 2006-04-20 17:55:56.000000000 +0200 +++ /var/tmp/diff_new_pack.7DGdbh/_new 2006-04-20 17:55:56.000000000 +0200 @@ -13,16 +13,15 @@ Name: suseRegister BuildRequires: mono-core Version: 1.0 -Release: 41 +Release: 45 Summary: Registration tool Group: Productivity/Other License: GPL Source: %{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-build +Requires: curl Requires: perl-XML-Parser Requires: perl-XML-Writer -Requires: perl-libwww-perl -Requires: perl-IO-Socket-SSL Requires: mono-core Requires: coreutils Requires: sysconfig @@ -61,6 +60,9 @@ /usr/lib/suseRegister/bin/* %changelog -n suseRegister +* Thu Apr 20 2006 - mc@suse.de +- switch back to curl to provide correct https proxy support + [fix part of #165891] * Fri Apr 07 2006 - mc@suse.de - print update urls on success to STDERR * Wed Apr 05 2006 - mc@suse.de ++++++ suseRegister-1.0.tar.bz2 ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/suseRegister-1.0/suse_register new/suseRegister-1.0/suse_register --- old/suseRegister-1.0/suse_register 2006-04-07 17:30:37.000000000 +0200 +++ new/suseRegister-1.0/suse_register 2006-04-20 15:15:50.000000000 +0200 @@ -14,15 +14,10 @@ use Sys::Syslog; use IPC::Open3; use URI; -use LWP::UserAgent; -use HTTP::Request::Common; -require IO::Socket::SSL; -require Net::HTTPS; - -#use LWP::Debug qw(+); -#$ENV{'HTTPS_DEBUG'} = 1; -#$IO::Socket::SSL::DEBUG = 1; +use Time::HiRes qw(gettimeofday tv_interval); +my $time = 0; +my $programStartTime = [gettimeofday]; my $version = "1.0"; @@ -56,8 +51,6 @@ my $browser = undef; my $forceZmdConfiguration = 0; my $noproxy = 0; -my $proxyuser = undef; -my $proxypassword = undef; my $help = 0; my $debug = 0; my $yastcall = 0; @@ -71,7 +64,9 @@ my @serverKnownProducts = (); my @installedProducts = (); my $products = []; - + +my @extraCurlOption = (); + my $hostGUID = undef; my $zmdConfig = {}; @@ -89,6 +84,8 @@ my $uname = "/bin/uname"; my $hwinfo = "/usr/sbin/hwinfo"; my $zmdInit = "/etc/init.d/novell-zmd"; +my $curl = "/usr/bin/curl"; + #my $xenstoreread = "/usr/bin/xenstore-read"; #my $xenstorewrite = "/usr/bin/xenstore-write"; @@ -101,83 +98,6 @@ my $rugzmdInstalled = 0; -push(@LWP::Protocol::http::EXTRA_SOCK_OPTS, 'SSL_ca_path', $CA_PATH); -push(@LWP::Protocol::http::EXTRA_SOCK_OPTS, 'SSL_ca_file', undef); -push(@LWP::Protocol::http::EXTRA_SOCK_OPTS, 'SSL_verify_mode', 0x01 | 0x02 | 0x04); -push(@LWP::Protocol::http::EXTRA_SOCK_OPTS, 'SSL_error_trap', \&ssl_error); -$ENV{'HTTPS_CA_DIR'} = $CA_PATH; -$ENV{'HTTPS_CA_FILE'} = ""; - -############################################################################################### - -# We make our own specialization of LWP::UserAgent that fetches -# user/password for proxies. -{ - package RegisterAgent; - @RegisterAgent::ISA = qw(LWP::UserAgent); - - use English; - - sub new - { - my($class, $puser, $ppass, %cnf) = @_; - - my $self = $class->SUPER::new(%cnf); - - bless { - puser => $puser, - ppass => $ppass - }, $class; - } - - sub get_basic_credentials - { - my($self, $realm, $uri, $proxy) = @_; - - my $user = undef; - my $pass = undef; - - if($proxy) - { - if(defined $self->puser && defined $self->ppass) - { - $user = $self->puser; - $pass = $self->ppass; - } - elsif($UID == 0 && -e "/root/.curlrc") - { - # read /root/.curlrc - open(RC, "< /root/.curlrc") or return (undef,undef); - while(<RC>) - { - if($_ =~ /^\s*proxy-user\s*=\s*"(.+)"\s*$/ && defined $1 && $1 ne "") - { - ($user, $pass) = split(":", $1, 2); - } - } - close RC; - } - elsif($UID != 0 && - exists $ENV{HOME} && defined $ENV{HOME} && - $ENV{HOME} ne "" && -e "$ENV{HOME}/.curlrc") - { - # read ~/.curlrc - open(RC, "< $ENV{HOME}/.curlrc") or return (undef,undef); - while(<RC>) - { - if($_ =~ /^\s*proxy-user\s*=\s*"(.+)"\s*$/ && defined $1 && $1 ne "") - { - ($user, $pass) = split(":", $1, 2); - } - } - close RC; - } - } - return ($user, $pass); - } -} - -############################################################################################### sub logPrintExit { @@ -204,18 +124,12 @@ closelog; close $LOGDESCR if(defined $LOGDESCR); + + print STDERR "total time: ".(tv_interval($programStartTime))."\n" if($time); + exit $code; } -sub ssl_error -{ - my $sock = shift; - my $errstr = shift; - - $sock->close(); - - logPrintExit($errstr, 16); -} sub intersection { @@ -280,6 +194,8 @@ sub readSystemValues { + my $t0 = [gettimeofday] if($time); + ############### read the config ################### if(-e "$configFile") { @@ -404,6 +320,8 @@ chomp($args{processor}); chomp($args{platform}); + + print STDERR "readSystemValues: ".(tv_interval($t0))."\n" if($time); } @@ -883,16 +801,24 @@ { my $url = shift || undef; my $data = shift || undef; - + + my $t0 = [gettimeofday] if($time); + + my $curlErr = 0; my $res = ""; + my $err = ""; + my %header = (); my $code = ""; my $mess = ""; - my $cont = ""; if (! defined $url) { logPrintExit("Cannot send data. Missing URL.\n", 14); } + if($url =~ /^-/) + { + logPrintExit("Wrong protocol($url).\n", 15); + } my $uri = URI->new($url); @@ -900,49 +826,127 @@ { logPrintExit("Wrong URL($url).\n", 15); } + if(!defined $uri->scheme || $uri->scheme ne "https") + { + logPrintExit("Wrong protocol($url).\n", 15); + } $url = $uri->as_string; if (! defined $data) { logPrintExit("Cannot send data. Missing data.\n", 14); } - - my $ua = RegisterAgent->new($proxyuser, $proxypassword, "keep_alive" => 1); - $ua->protocols_allowed(['https']); - $ua->max_redirect(10); - - if(!$noproxy) + my @cmdArgs = ( "--capath", $CA_PATH); + + my $fh = new File::Temp(TEMPLATE => 'dataXXXXX', + SUFFIX => '.xml', + DIR => '/tmp/'); + print $fh $data; + + push @cmdArgs, "--data", "@".$fh->filename(); + push @cmdArgs, "-i"; + push @cmdArgs, "--max-time", "20"; + + foreach my $extraOpt (@extraCurlOption) { - $ua->env_proxy(); + if($extraOpt =~ /^([\w-]+)[\s=]*(.*)/) + { + if(defined $1 && $1 ne "") + { + push @cmdArgs, $1; + + if(defined $2 && $2 ne "") + { + push @cmdArgs, $2; + } + } + } } + + push @cmdArgs, "$url"; - my $request = HTTP::Request::Common::POST($url, - Content_Type => "text/xml;charset=UTF-8", - Content => $data - ); - + print STDERR "Call $curl ".join(" ", @cmdArgs)."\n" if($debug >= 2); print STDERR "SEND DATA to URI: $url:\n" if($debug >= 2); - print STDERR $request->as_string."\n" if($debug >= 2); + print STDERR "$data\n" if($debug >= 2); print $LOGDESCR "\nSEND DATA to URI: $url:\n" if(defined $LOGDESCR); - print $LOGDESCR $request->as_string if(defined $LOGDESCR); + print $LOGDESCR "$data\n" if(defined $LOGDESCR); - $res = $ua->request($request); - $code = $res->code; - $mess = $res->message; - $cont = $res->content; - + if($noproxy) + { + delete $ENV{'http_proxy'}; + delete $ENV{'HTTP_PROXY'}; + delete $ENV{'https_proxy'}; + delete $ENV{'HTTPS_PROXY'}; + delete $ENV{'ALL_PROXY'}; + delete $ENV{'all_proxy'}; + } + $ENV{'PATH'} = '/bin:/usr/bin:/sbin:/usr/sbin:/opt/kde3/bin/:/opt/gnome/bin/'; + + my $pid = open3(\*IN, \*OUT, \*ERR, $curl, @cmdArgs) or do { + logPrintExit("Cannot execute $curl ".join(" ", @cmdArgs).": $!\n",13); + }; + + my $foundBody = 0; + while (<OUT>) + { + $res = "" if(! defined $res); + if ($foundBody) + { + $res .= "$_"; + } + elsif ($_ =~ /^HTTP\/\d\.\d\s(\d+)\s(.*)$/) + { + if (defined $1 && $1 ne "") + { + $code = $1; + } + if (defined $2 && $2 ne "") + { + $mess = $2; + } + } + elsif ($_ =~ /^[\w-]+:\s/) + { + my ($key, $val) = split(": ", $_, 2); + $header{$key} = $val; + } + elsif ($_ =~ /^\s*) + { + $foundBody = 1; + $res .= "$_"; + } + } + while (<ERR>) + { + $err .= "$_"; + } + close OUT; + close ERR; + close IN; + waitpid $pid, 0; + + $curlErr = ($?>>8); + + print STDERR "CURL RETURN WITH: $curlErr\n" if($debug >= 2); print STDERR "\nRECEIVED DATA:\n" if($debug >= 2); print STDERR "CODE: $code MESSAGE: $mess\n" if($debug >= 2); - print STDERR "BODY: ".$res->as_string."\n" if($debug >= 2); - - print $LOGDESCR "\n\nRECEIVED DATA:\n" if(defined $LOGDESCR); + print STDERR "HEADER: ".Data::Dumper->Dump([\%header])."\n" if($debug >= 2); + print STDERR "BODY: $res\n" if($debug >= 2); + + print $LOGDESCR "\nRECEIVED DATA:\n" if(defined $LOGDESCR); + print $LOGDESCR "CURL RETURN WITH: $curlErr\n" if(defined $LOGDESCR); print $LOGDESCR "CODE: $code MESSAGE: $mess\n" if(defined $LOGDESCR); - print $LOGDESCR "BODY: ".$res->as_string."\n" if(defined $LOGDESCR); + print $LOGDESCR "HEADER: ".Data::Dumper->Dump([\%header])."\n" if(defined $LOGDESCR); + print $LOGDESCR "BODY: $res\n" if(defined $LOGDESCR); - if ($res->is_redirect && - defined $res->header('Location') && $res->header('Location') ne "") + if ($curlErr != 0) + { + logPrintExit("Execute curl command failed with '$curlErr': $err", 4); + } + + if ($code >= 300 && exists $header{Location} && defined $header{Location}) { if ($redirects > 5) { @@ -950,15 +954,17 @@ } $redirects++; - my $loc = $res->header('Location'); + my $loc = $header{Location}; local $/ = "\r\n"; chomp($loc); local $/ = "\n"; - - $cont = sendData($loc, $data); + + print STDERR "sendData(redirect): ".(tv_interval($t0))."\n" if($time); + + $res = sendData($loc, $data); } - elsif($res->is_error) + elsif($code < 200 || $code >= 300) { my $b = ""; my @c = (); @@ -975,19 +981,19 @@ } open(LYNXIN, "|-", "$b", @c) or do { - logPrintExit("Cannot execute $b: $!\n.".$res->as_string."\n", 13); + logPrintExit("Cannot execute $b: $!\n$res\n", 13); }; - print LYNXIN $cont; + print LYNXIN $res; close LYNXIN; logPrintExit("ERROR: $code: $mess\n", 2); } - elsif($res->is_info) + else { - logPrintExit("ERROR: $code: $mess\n", 2); + print STDERR "sendData(final): ".(tv_interval($t0))."\n" if($time); } - return $cont; + return $res; } sub listParams @@ -1154,6 +1160,8 @@ my $msg = ""; my $code = 1; + my $t0 = [gettimeofday] if($time); + if($rugzmdInstalled) { $msg = `$zmdInit status 2>&1`; @@ -1183,6 +1191,7 @@ logPrintExit("Cannot start zmd: ".($msg?$msg:"").($msg2?$msg2."($code)":"($code)"), 7); } } + print "rugStart: ".(tv_interval($t0))."\n" if($time); return $code; } else @@ -1207,6 +1216,7 @@ print STDERR "GUID created: $guid\n" if($debug); } } + print "rugStart: ".(tv_interval($t0))."\n" if($time); return 0; } @@ -1277,6 +1287,8 @@ sub rugProducts { + my $t0 = [gettimeofday] if($time); + print STDERR "query pool command: $querypool products \@system \n" if($debug >= 1); my $result = `$querypool products \@system`; @@ -1330,6 +1342,9 @@ print STDERR "Query products failed($code): $result\n" if($debug && $code != 0); print STDERR "installed products: ".Data::Dumper->Dump([\@installedProducts])."\n" if($debug); + + print STDERR "rugProducts: ".(tv_interval($t0))."\n" if($time); + } @@ -1582,6 +1597,7 @@ sub configureZMD { my $tree = shift || undef; + my $t0 = [gettimeofday] if($time); if (!defined $tree) { @@ -1620,6 +1636,8 @@ { # If rug/zmd are not installed we are done here. syslog("info", "rug/zmd are not installed. finish."); + + print STDERR "configureZMD(no zmd): ".(tv_interval($t0))."\n" if($time); return 0; } @@ -1724,11 +1742,14 @@ # do not touch catalogs here } } + print STDERR "configureZMD: ".(tv_interval($t0))."\n" if($time); return 0; } sub register { + my $t0 = [gettimeofday] if($time); + my $output = buildXML(); $redirects = 0; @@ -1757,6 +1778,9 @@ { $recursion++; $acceptmand = 1; + + print STDERR "register(auto needinfo): ".(tv_interval($t0))."\n" if($time); + return register(); } else # no automatic args. Search for interactive args @@ -1764,6 +1788,9 @@ if ($xmlout) { print "$res\n"; + + print STDERR "register(xmlout): ".(tv_interval($t0))."\n" if($time); + return 1; } elsif (!$interactive) @@ -1813,6 +1840,7 @@ print STDERR join("", @registerReadableText)."\n"; + print STDERR "register(manual needinfo): ".(tv_interval($t0))."\n" if($time); return 1; } else @@ -1886,6 +1914,8 @@ } else { + print STDERR "register(browser): ".(tv_interval($t0))."\n" if($time); + logPrintExit("If you have finished your registration, ". "please start suse_register\n". "again to get the current configuration for ". @@ -1932,6 +1962,8 @@ $nooptional = 1; $recursion++; + print STDERR "register(browser needinfo): ".(tv_interval($t0))."\n" if($time); + register(); } } @@ -1961,11 +1993,14 @@ { logPrintExit("Unknown reponse format.\n", 11); } + print STDERR "register(zmdconfig): ".(tv_interval($t0))."\n" if($time); return 0; } sub listProducts { + my $t0 = [gettimeofday] if($time); + my $output = "\n"; my $writer = new XML::Writer(OUTPUT => \$output); @@ -2012,6 +2047,7 @@ } } print STDERR "Server Known Products:".Data::Dumper->Dump([\@serverKnownProducts])."\n" if($debug >= 2); + print STDERR "listProducts: ".(tv_interval($t0))."\n" if($time); return 0; } @@ -2042,9 +2078,6 @@ print STDERR " --xml-output print XML output\n"; print STDERR " -L [--log] <file> log all networktraffic to <file>\n"; print STDERR " [--no-proxy] do not use proxie's\n"; - print STDERR " [--proxy-user] username for proxy authentication if required\n"; - print STDERR " [--proxy-password] password for proxy authentication if required\n"; - print STDERR " Better write 'proxy-user = \"<user>:<pass>\"' in ~/.curlrc\n"; print STDERR " --locale=<locale> define a locale e.g. en-US.utf-8\n\n"; print STDERR "Example:\n\n"; @@ -2072,12 +2105,12 @@ "browser|b=s" => \$browser, "forceZmdConfiguration" => \$forceZmdConfiguration, "no-proxy" => \$noproxy, - "proxy-user=s" => \$proxyuser, - "proxy-password=s" => \$proxypassword, "yast|y" => \$yastcall, "help|?|h" => \$help, "debug|d=i" => \$debug, - "arg|a=s" => \%args); + "arg|a=s" => \%args, + "extra-curl-options=s" => \@extraCurlOption, + "t" => \$time); if ($help) { @@ -2097,7 +2130,7 @@ if(!-e $querypool) { - logPrintExit("query-pool not found", 12); + logPrintExit("query-pool not found\n", 12); } } @@ -2151,10 +2184,9 @@ print STDERR "browser: ".(($browser)?$browser:"undef")."\n" if($debug); print STDERR "forceZmdConfiguration: $forceZmdConfiguration\n" if($debug); print STDERR "no-proxy: $noproxy\n" if($debug); -print STDERR "proxyuser: ".(($proxyuser)?$proxyuser:"undef")."\n" if($debug); -print STDERR "proxypassword: ".(($proxypassword)?$proxypassword:"undef")."\n" if($debug); print STDERR "yastcall: $yastcall\n" if($debug); print STDERR "arg: ".Data::Dumper->Dump([{%args}])."\n" if($debug); +print STDERR "extra-curl-option:".Data::Dumper->Dump([@extraCurlOption])."\n" if($debug); print STDERR "URL: $URL\n" if($debug); print STDERR "listParams: $URLlistParams\n" if($debug); @@ -2241,5 +2273,7 @@ } } +print STDERR "total time: ".(tv_interval($programStartTime))."\n" if($time); + exit $ret; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun...
participants (1)
-
root@suse.de