[ale] Base64 encoding in Perl

Christopher Fowler cfowler at outpostsentinel.com
Mon Feb 14 13:38:40 EST 2005


On Mon, 2005-02-14 at 13:24, Fletch wrote:

> Hrmm.  I'd put the upgrade file available by (password protected) HTTP
> and then send the client the URL (and maybe even credentials) and have
> it pull the upgrade via curl/wget/LWP::Simple::getstore.  But that's
> just me . . .

Yep.  Unfortunately XML-RPC has no authentication specs.  WTF?  So I
wrote my perl program to log into the device via a login form and then I
had to modify the Frontier::Client constructor to accept a
LEP::UserAgent object.  This way I'm able to do this with
authentication.  My device also supports ACL's so a non-admin may be
able to execute some procedures but not one that pushes a software
upgrade.

-----------------------------------------------------------------
Here is how:use Frontier::Client;
use HTTP::Request;
use LWP::UserAgent;
use strict;
                                                                                                                             
my $ua = LWP::UserAgent->new();
$ua->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });
my $response = $ua->post("https://192.168.2.120/cgi-bin/login",
        { 'user' => "root", 'pass' => "password" });
                                                                                                                             
my $server = Frontier::Client->new( debug => 0, url =>
'https://192.168.2.120/cgi-bin/xml-rpc',ua => $ua );
my $result = $server->call('exec', ("/sbin/flash -qu
http://192.168.2.8/tftpboot/package"));
                                                                                                                             
foreach my $k (sort keys %{$result}) {
 print "$k:\n";
 print "$result->{$k}\n";
}


-----------------------------------------------------------------

The exec procedure returns the exit code and STDOUT of the program to be
executed.  This one simply sent the command to flash the unit via a URL.





More information about the Ale mailing list