X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=machines.cgi;h=ba84f18232e745d554af1011a3591f031de9738a;hb=9b394648f35965c5b6e18a8ff12af25d73866f7a;hp=fc84b304e4f332185ec1231478f75b5353ce02c1;hpb=0bc65a517646eb7a80b2b69ee7a2ffe3e4664d3f;p=mirror%2Fuserdir-ldap-cgi.git diff --git a/machines.cgi b/machines.cgi index fc84b30..ba84f18 100755 --- a/machines.cgi +++ b/machines.cgi @@ -11,7 +11,7 @@ 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; @@ -74,7 +74,8 @@ sub sshfingerprint { return '' if (!$key); my @field = split(/ /, $key); - return '' if $field[0] ne 'ssh-dss' and $field[0] ne 'ssh-rsa'; + my %keytypes = map {$_=>1} (qw{ssh-dss ssh-rsa ecdsa-sha2-nistp256}); + return '' unless $keytypes{$field[0]}; return '' if !$field[1]; my $fpr = md5_hex(decode_base64($field[1])); my $hrfpr = $field[0] . " " . substr($fpr,0,2,""); @@ -86,20 +87,33 @@ sub sshfingerprint { sub wiki_link($) { my ($in) = @_; - $in =~ s#\[\[(.*?)\|(.*?)\]\]#$2#g; - $in =~ s#\[\[(.*?)\]\]#$1#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#\[\[\*?(.*?)\|(.*?)\]\]#$2#g; + $in =~ s#\[\[\*?(.*?)\]\]#$1#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 = ""; } @@ -166,7 +180,7 @@ foreach $dn (sort {$entries->{$a}->{host}->[0] cmp $entries->{$b}->{host}->[0]} $selected = " selected "; } - $hostlist .= "