download_message does not handle authentication properly

Bug #778692 reported by Steve Gaarder
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OCS Inventory: Unified Unix Agent
Fix Released
Low
mortheres

Bug Description

When using a server that requires authentication and deploying a package, the package is downloaded and installed ok, but the success message never arrives because the routine download_message does not present the configured user name and password. Instead, it just retries forever, getting a 401 error each time. It appears that the problem is in this line:

$ua->credentials( $context->{'OCS_AGENT_SERVER_NAME'},

because when I replace the variable with the hard-coded name and port of my server, it works.

Revision history for this message
Steve Gaarder (gaarder1-math) wrote :

One way to fix this is to add this subroutine:

sub getnetloc{

# extract from the server URL a name of the form hostname:port

    my $serverurl = shift;

    my $s = "";
    if ($serverurl =~ m!https*://([\w\-\.]+):(\d+)/!) {
        $s = "${1}:$2";
    } elsif ($serverurl =~ m!http://([\w\-\.]+)/!) {
        $s = "${1}:80";
    } elsif ($serverurl =~ m!https://([\w\-\.]+)/!) {
        $s = "${1}:443";
    }
    return $s;
}

And then change the offending line above to:

       $ua->credentials( &getnetloc($context->{servername}),

mortheres (mortheres)
Changed in ocsinventory-unix-agent:
assignee: nobody → mortheres (mortheres)
Revision history for this message
mortheres (mortheres) wrote :

Hi Steve,

Thanks a lot for your report and your proposal. A better way it to use $network object (from Network.pm) because it contains the Useragent settings ($ua) and the credentials you set in your ocsinventory-agent.cfg or in command line. When Download.pm uses $network instead of creating a new LWP object, it fix the problem.

The bug has been correct in revision 1047 of the stable-2.0 branch of the OCS Unix agent: http://bazaar.launchpad.net/~ocsinventory-dev/ocsinventory-unix-agent/stable-2.0/revision/1047 . This fix will be released in the final OCS 2.0 release :) :).

Kind regards,

Guillaume

Changed in ocsinventory-unix-agent:
milestone: none → 2.0
importance: Undecided → Low
status: New → Fix Committed
mortheres (mortheres)
Changed in ocsinventory-unix-agent:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.