#use Apache::Registry;
use CGI;
use Util;
-use Net::LDAP qw(:all);
+use Net::LDAP qw(LDAP_SUCCESS LDAP_PROTOCOL_ERROR);
use Fcntl;
use POSIX;
use MIME::Base64;
'status' => 'Status',
'notes' => 'Notes',
'sshrsahostkey' => 'SSH host key',
- 'sshrsahostfprint' => 'SSH host fingerprint',
'description' => 'Description',
'purpose' => 'purposes of this server',
# 'createtimestamp' => 'Entry created',
# ditto for summary
%summaryattrs = ('hostname' => 'Host name',
'host' => 'just for a link',
+ 'description' => 'Description',
'architecture' => 'Architecture',
'status' => 'Status',
'access' => 'Access',
'sponsor' => 'Sponsor',
'purpose' => 'Purpose');
-@summaryorder = qw{hostname architecture sponsor purpose status access};
+@summaryorder = qw{hostname description architecture sponsor purpose status access};
%summarylistitems = map {$_=>1} qw{purpose sponsor};
# Global settings...
$ldap->unbind if (defined($ldap));
}
-# human readable fingerprint
-sub sshfingerprint {
- my $key = shift;
-
- return '' if (!$key);
-
- my @field = split(/ /, $key);
- return '' if $field[0] ne 'ssh-dss' and $field[0] ne 'ssh-rsa';
- return '' if !$field[1];
- my $fpr = md5_hex(decode_base64($field[1]));
- my $hrfpr = $field[0] . " " . substr($fpr,0,2,"");
- while (length $fpr > 0) {
- $hrfpr .= ':' . substr($fpr,0,2,"");
- }
- return $hrfpr;
-}
-
sub wiki_link($) {
my ($in) = @_;
- $in =~ s#\[\[(.*?)\|(.*?)\]\]#<a href="http://$1">$2</a>#g;
- $in =~ s#\[\[(.*?)\]\]#<a href="http://$1">$1</a>#g;
+ # [[hostname|text]] makes a link
+ # [[hostname]] makes a link too
+ # if you add a * after [[ it's still the same, only not used for ssh_known_hosts in ud-generate
+ # [[-hostname]] are not links, but get added to known_hosts. we should drop the [[- ]] tho
+ $in =~ s#\[\[-(.*?)\]\]#$1#g;
+ $in =~ s#\[\[\*?(.*?)\|(.*?)\]\]#<a href="http://$1">$2</a>#g;
+ $in =~ s#\[\[\*?(.*?)\]\]#<a href="http://$1">$1</a>#g;
return $in;
}
+# in the purpose field [[host|some other text]] (where some other text is optional)
+# makes a hyperlink on the web thing. we now also add these hosts to the ssh known_hosts
+# file. But so that we don't have to add everything we link we can add an asterisk
+# and say [[*... to ignore it. In order to be able to add stuff to ssh without
+# http linking it we also support [[-hostname]] entries.
+#
+# sponsors are also wikified like purpose. maybe others as well
sub item_uplist($) {
my ($items) = @_;
my $out = undef;
+ my(@tmp) = @$items;
- if (scalar @$items >= 1) {
+ if (scalar @tmp>= 1) {
$out = "<ul>".
join("", map {
"<li>".wiki_link($_)."</li>\n";
- } sort {my $A=$a; my $B=$b; $A =~ s/[\[\]]//g; $B =~ s/[\[\]]//g; $A cmp $B} @{$items}
+ } sort {my $A=$a; my $B=$b; $A =~ s/[\[\]\*]//g; $B =~ s/[\[\]\*]//g; $A cmp $B} @tmp
).
"</ul>";
}
return $out;
}
-$SIG{__DIE__} = \&DieHandler;
+#$SIG{__DIE__} = \&DieHandler;
my $query = new CGI;
my $host = lc($query->param('host'));
my $sortby = lc($query->param('sortby')) || "host";
my $sortorder = lc($query->param('sortorder')) || "asc";
+
&Util::HTMLSendHeader;
$ldap = Net::LDAP->new($config{ldaphost}) || &Util::HTMLError($!);
&Util::UpgradeConnection($ldap) unless $config{usessl} eq 'False';
$output{sshrsahostkey} .= $key . "<br>";
}
- foreach $key (@{$data->{sshrsahostkey}}) {
- $output{sshrsahostfprint} .= sshfingerprint($key) . "<br>";
- }
-
my $sponsor = item_uplist($data->{sponsor});
$output{sponsor} = $sponsor if defined $sponsor;
my $purpose = item_uplist($data->{purpose});
$hostdetails .= "<ul>\n";
foreach $key (@attrorder) {
if ($output{$key}) {
- $hostdetails .= "<li><b>$attrs{$key}:</b>$output{$key}\n";
+ $hostdetails .= "<li><b>$attrs{$key}</b>: $output{$key}\n";
}
}
$hostdetails .= "</ul>\n";
} else {
# display summary info
$hostdetails = "<h1>Summary</h1>\n";
- $hostdetails .= "<table border=\"1\" width=\"90%\">\n<tr>";
+ $hostdetails .= "<table id=\"machines\" class=\"tablesorter\" border=\"1\" cellpadding=\"0\" cellspacing=\"1\">\n<thead>\n<tr>";
foreach $key (@summaryorder) {
if ($sortby ne $key) {
- $hostdetails .= "<th><a href=\"machines.cgi?sortby=$key&sortorder=asc\">$summaryattrs{$key}</a></th>";
+ $hostdetails .= "<th><a class=\"sort\" href=\"machines.cgi?sortby=$key&sortorder=asc\">$summaryattrs{$key}</a></th>";
} else {
if ($sortorder ne "dsc") {
- $hostdetails .= "<th><a href=\"machines.cgi?sortby=$key&sortorder=dsc\">$summaryattrs{$key}</a></th>";
+ $hostdetails .= "<th><a class=\"sort\" href=\"machines.cgi?sortby=$key&sortorder=dsc\">$summaryattrs{$key}</a></th>";
} else {
- $hostdetails .= "<th><a href=\"machines.cgi?sortby=$key&sortorder=asc\">$summaryattrs{$key}</a></th>";
+ $hostdetails .= "<th><a class=\"sort\" href=\"machines.cgi?sortby=$key&sortorder=asc\">$summaryattrs{$key}</a></th>";
}
}
}
- $hostdetails .= "</tr>\n";
+ $hostdetails .= "</tr>\n</thead>\n<tbody>\n";
my @sorted;
if ($sortorder eq "asc") {
}
$hostdetails .= "</tr>\n";
}
- $hostdetails .= "</table>\n";
+ $hostdetails .= "</tbody>\n</table>\n";
}
# Finally, we can write the output... yuck...