X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;ds=sidebyside;f=machines.cgi;h=e8670987a80fcd0c357da7aa8481fca8032cab39;hb=f6529c2ecdc28d6b192138fb26e22dd3699121c9;hp=c50c4cbc6dc38b25e984e5f41e9f7f5f7162fa31;hpb=322919654cd45c61089c40679cf8eb5bce85b2a2;p=mirror%2Fuserdir-ldap-cgi.git
diff --git a/machines.cgi b/machines.cgi
index c50c4cb..e867098 100755
--- a/machines.cgi
+++ b/machines.cgi
@@ -11,13 +11,13 @@ use strict vars;
#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;
use Digest::MD5 qw(md5_hex);
-my (%attrs, @attrorder, %summaryattrs, @summaryorder);
+my (%attrs, @attrorder, %summaryattrs, @summaryorder, %summarylistitems);
# This defines the description of the fields, and which fields are retrieved
%attrs = ('hostname' => 'Host name',
@@ -35,7 +35,6 @@ my (%attrs, @attrorder, %summaryattrs, @summaryorder);
'status' => 'Status',
'notes' => 'Notes',
'sshrsahostkey' => 'SSH host key',
- 'sshrsahostfprint' => 'SSH host fingerprint',
'description' => 'Description',
'purpose' => 'purposes of this server',
# 'createtimestamp' => 'Entry created',
@@ -50,13 +49,15 @@ my (%attrs, @attrorder, %summaryattrs, @summaryorder);
# ditto for summary
%summaryattrs = ('hostname' => 'Host name',
- 'host' => 'just for a link',
- 'architecture' => 'Architecture',
- 'distribution' => 'Distribution',
+ 'host' => 'just for a link',
+ 'description' => 'Description',
+ 'architecture' => 'Architecture',
'status' => 'Status',
- 'access' => 'Access');
-
-@summaryorder = ('hostname', 'architecture', 'distribution', 'status', 'access');
+ 'access' => 'Access',
+ 'sponsor' => 'Sponsor',
+ 'purpose' => 'Purpose');
+@summaryorder = qw{hostname description architecture sponsor purpose status access};
+%summarylistitems = map {$_=>1} qw{purpose sponsor};
# Global settings...
my %config = &Util::ReadConfigFile;
@@ -66,46 +67,49 @@ sub DieHandler {
$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) = @_;
+ # [[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#\[\[\*?(.*?)\|(.*?)\]\]#$2#g;
+ $in =~ s#\[\[\*?(.*?)\]\]#$1#g;
+ return $in;
}
-sub purposes_uplist($) {
- my ($purposes) = @_;
+# 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 @$purposes >= 1) {
+ if (scalar @tmp>= 1) {
$out = "