1 |
Douglas Thrift |
150 |
#!/usr/bin/perl |
2 |
|
|
# |
3 |
|
|
# Host SSH |
4 |
|
|
# |
5 |
|
|
# Douglas Thrift |
6 |
|
|
# |
7 |
|
|
# $Id$ |
8 |
|
|
|
9 |
|
|
use strict; |
10 |
|
|
use LWP::UserAgent; |
11 |
|
|
use POSIX; |
12 |
|
|
use MIME::Base64 qw(encode_base64); |
13 |
|
|
|
14 |
|
|
my $agent = LWP::UserAgent->new; |
15 |
|
|
my ($sysname, $nodename, $release, $version, $machine) = uname(); |
16 |
|
|
my $host = $ARGV[0]; |
17 |
|
|
|
18 |
|
|
if ($host eq "") |
19 |
|
|
{ |
20 |
|
|
die "$0: no host"; |
21 |
|
|
} |
22 |
|
|
elsif (!($host =~ /\./)) |
23 |
|
|
{ |
24 |
|
|
$host .= ".local.douglasthrift.net"; |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
$agent->agent("Host SSH/1.0 ($sysname $release $machine) "); |
28 |
|
|
|
29 |
|
|
my $response = $agent->get("http://topsecret.douglasthrift.net/auth/hostupdate" |
30 |
|
|
. ".cgi?host=$host&mode=n", Authorization => "Basic " . encode_base64("Hos" |
31 |
|
|
. "tUpdate:frell2003")); |
32 |
|
|
my $content = $response->content; |
33 |
|
|
|
34 |
|
|
if ($content =~ /^name=(.+)$/) |
35 |
|
|
{ |
36 |
|
|
system ("ssh -L 8080:localhost:80 -R 8080:localhost:80 -L 5900:localhost:5" |
37 |
|
|
. "900 Douglas\\ Thrift\@$1"); |
38 |
|
|
} |