[yast-commit] r62436 - in /branches/SuSE-Code-11-SP1-Branch/registration: VERSION package/yast2-registration.changes src/modules/Register.ycp src/modules/YSR.pm
Author: jdsn Date: Sat Aug 28 00:50:16 2010 New Revision: 62436 URL: http://svn.opensuse.org/viewcvs/yast?rev=62436&view=rev Log: fix registration status detection, common flag file (bnc#634026) fix proxy settings for WebYaST registrations (bnc#626965) 2.17.35 Modified: branches/SuSE-Code-11-SP1-Branch/registration/VERSION branches/SuSE-Code-11-SP1-Branch/registration/package/yast2-registration.changes branches/SuSE-Code-11-SP1-Branch/registration/src/modules/Register.ycp branches/SuSE-Code-11-SP1-Branch/registration/src/modules/YSR.pm Modified: branches/SuSE-Code-11-SP1-Branch/registration/VERSION URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/registration/VERSION?rev=62436&r1=62435&r2=62436&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/registration/VERSION (original) +++ branches/SuSE-Code-11-SP1-Branch/registration/VERSION Sat Aug 28 00:50:16 2010 @@ -1 +1 @@ -2.17.34 +2.17.35 Modified: branches/SuSE-Code-11-SP1-Branch/registration/package/yast2-registration.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/registration/package/yast2-registration.changes?rev=62436&r1=62435&r2=62436&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/registration/package/yast2-registration.changes (original) +++ branches/SuSE-Code-11-SP1-Branch/registration/package/yast2-registration.changes Sat Aug 28 00:50:16 2010 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Fri Aug 27 20:33:46 CEST 2010 - jdsn@suse.de + +- fix registration status detection, common flag file (bnc#634026) +- fix proxy settings for WebYaST registrations (bnc#626965) +- 2.17.35 + +------------------------------------------------------------------- Fri Aug 20 18:01:17 CEST 2010 - jdsn@suse.de - use correct error code for backend init errors (bnc#633183) Modified: branches/SuSE-Code-11-SP1-Branch/registration/src/modules/Register.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/registration/src/modules/Register.ycp?rev=62436&r1=62435&r2=62436&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/registration/src/modules/Register.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/registration/src/modules/Register.ycp Sat Aug 28 00:50:16 2010 @@ -1540,8 +1540,9 @@ if ( initialSRstatus == 0 ) { y2milestone("SuseRegister returned with status: %1", initialSRstatus); - // touch webyast flag file to show in webyast that this machine is already registered - SCR::Execute(.target.bash, sformat(" [ -d /var/lib/yastws ] && touch /var/lib/yastws/enable_SLM_webyast_registration_workaround ")); + // touch webyast flag file to show in webyast that this machine is already registered (bnc#634026) + SCR::Execute(.target.bash, " [ -d /var/lib/yastws ] && date +%s > /var/lib/yastws/registration_successful " ); + SCR::Execute(.target.bash, " [ -d /var/lib/suseRegister ] && date +%s > /var/lib/suseRegister/y2_registration_successful " ); } Modified: branches/SuSE-Code-11-SP1-Branch/registration/src/modules/YSR.pm URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/registration/src/modules/YSR.pm?rev=62436&r1=62435&r2=62436&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/registration/src/modules/YSR.pm (original) +++ branches/SuSE-Code-11-SP1-Branch/registration/src/modules/YSR.pm Sat Aug 28 00:50:16 2010 @@ -20,6 +20,12 @@ my $global_ctx = {}; +# flag files for registration status +my $FFwebyast_dir = '/var/lib/yastws'; +my $FFwebyast = $FFwebyast_dir.'/registration_successful'; +my $FFgeneric_dir = '/var/lib/suseRegister'; +my $FFgeneric = $FFgeneric_dir.'/y2_registration_successful'; + # set the PATH in the perl environment (bnc#621914) # otherwise it is empty in system calls $ENV{PATH}="/usr/bin:/sbin:/usr/sbin:/bin"; @@ -185,6 +191,13 @@ } } +BEGIN { $TYPEINFO{unset_proxy} = ["function", "void"]; } +sub unset_proxy +{ + my $self = shift; + delete $ENV{http_proxy}; + delete $ENV{https_proxy}; +} BEGIN { $TYPEINFO{statelessregister} = ["function", [ "map", "string", "any"], ["map", "string", "any"], ["map", "string", "any"]]; } sub statelessregister @@ -192,7 +205,6 @@ my $self = shift; my $ctx = shift; my $arguments = shift; - my $SRregisterFlagFile = '/var/lib/yastws/registration_successful'; unless ( defined $ctx && ref($ctx) eq "HASH" ) { @@ -200,32 +212,30 @@ 'contexterror' => '1' }; } - # check if the system is still initialized - otherwise run init_ctx again - unless ( defined $global_ctx && ref($global_ctx) eq "HASH" && exists $global_ctx->{debug} ) - { - # not initialized - need to reinitialize - - # 1. proxy - if ( exists $ctx->{'proxy'} && ref($ctx->{'proxy'}) eq "HASH" ) - { - my $http = $ctx->{'proxy'}{'http_proxy'} || undef; - my $https = $ctx->{'proxy'}{'https_proxy'} || undef; - $self->set_proxy($http, $https); - } - - # 2. registration context - $self->init_ctx($ctx); - my $init_err = $self->get_errorcode(); - - unless ($init_err == 0) - { - # init failed - return { 'error' => 'The initialization of the registration failed.' - ,'initerror' => $init_err - ,'errorcode' => 199 - }; + # always do a fresh init of proxy and context - otherwise old cached wrong data may be used + # 1. proxy - fixed proxy settings (bnc#626965) + $self->unset_proxy(); + if ( exists $ctx->{'proxy-http_proxy'} || exists $ctx->{'proxy-https_proxy'} ) + { + my $http_proxy = $ctx->{'proxy-http_proxy'} || undef; + my $https_proxy = $ctx->{'proxy-https_proxy'} || undef; + $self->set_proxy($http_proxy, $https_proxy); + delete $ctx->{'proxy-http_proxy'}; + delete $ctx->{'proxy-https_proxy'}; + } + + # 2. registration context + $self->init_ctx($ctx); + my $init_err = $self->get_errorcode(); + + unless ($init_err == 0) + { + # init failed + return { 'error' => 'The initialization of the registration failed.' + ,'initerror' => $init_err + ,'errorcode' => 199 + }; } - } # set arguments # must be set one for one, otherwise other data would be overwritten @@ -262,6 +272,9 @@ ,'manualurl' => $manualurl }; + # we had a new registration process - so we reset the flag files + $self->removeregisteredflag(); + if ( $exitcode == 0 ) { # successful registration, so we need to save the last ZMD config @@ -294,9 +307,7 @@ ${$regret}{'tasklist'} = XMLout( {'item' => $tasklist}, rootname => 'tasklist', KeyAttr => { item => "+ALIAS", catalog => "+ALIAS" }, NoAttr => 1); # write flagfile for successful registration - open(FLAGFILE, "> $SRregisterFlagFile"); - print FLAGFILE localtime(); - close FLAGFILE; + $self->setregisteredflag(1); # to be on the safe side for a following registration request, we need to delete the context data $self->del_ctx(); @@ -348,7 +359,6 @@ my $SRconf = '/etc/suseRegister.conf'; my $SRcert = '/etc/ssl/certs/registration-server.pem'; my $SRcredentials = '/etc/zypp/credentials.d/NCCcredentials'; - my $SRregisterFlagFile = '/var/lib/yastws/registration_successful'; my $url = undef; my $cert = undef; @@ -384,7 +394,7 @@ } # read the guid - if ( -e $SRcredentials && -e $SRregisterFlagFile ) + if ( -e $SRcredentials && $self->getregisteredflag() ) { if (open(CRED, "< $SRcredentials") ) { @@ -404,7 +414,7 @@ $guid = '' unless defined $guid; # delete a flagfile that might be still there if no guid is found - unlink($SRregisterFlagFile) if $guid eq ''; + $self->removeregisteredflag() if $guid eq ''; return { "regserverurl" => $url, "regserverca" => $cert, @@ -493,6 +503,87 @@ return $success; } + +# +# setregisteredflag +# +# Write flagfile to identify a successful registration +# Note: this is only a good guess, only the registration server knows about the status +# (bnc#634026) +# +sub setregisteredflag() +{ + my $self = shift; + my $status = shift; + my $written = 0; + + my $status_str = time(); + $status_str = '' unless defined $status; + + + # write flagfile for successful registration + if ( -d $FFgeneric_dir ) + { + if ( ! -e $FFgeneric || defined $status ) + { + open( FFG, "> $FFgeneric" ); + print FFG "$status_str"; + close FFG; + } + $written = 1; + } + + # this is the old location - will be obsoleted in follwing releases + if ( -d $FFwebyast_dir ) + { + if ( ! -e $FFwebyast || defined $status ) + { + open( FFW, "> $FFwebyast" ); + print FFW "$status_str"; + close FFW; + } + $written = 1; + } + + return $written; +} + +# +# remove both registration flag files +# +# Remove flagfiles that identify a successful registration +# Note: this is only a good guess, only the registration server knows about the status +# (bnc#634026) +# +sub removeregisteredflag() +{ + my $self = shift; + unlink($FFgeneric); + unlink($FFwebyast); +} + +# +# getregisteredflag status +# +# +# Get flagfile status to identify a successful registration +# Note: this is only a good guess, only the registration server knows about the status +# (bnc#634026) +# +sub getregisteredflag() +{ + my $self = shift; + + if ( -e $FFgeneric || -e $FFwebyast ) + { + # write them if only one is found + $self->setregisteredflag(undef); + return 1; + } + return 0; +} + + # # check catalogs # -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
jdsn@svn2.opensuse.org