machines.cgi: generate fingerprints for ecdsa-sha2-nistp256 ssh keys.
[mirror/userdir-ldap-cgi.git] / machines.cgi
index d67aa3f..b80d92e 100755 (executable)
@@ -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,"");
@@ -90,9 +91,9 @@ sub wiki_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;
-       $in =~ s#\[\[-(.*?)\]\]#$1#g;
        return $in;
 }
 
@@ -106,7 +107,7 @@ sub wiki_link($) {
 sub item_uplist($) {
        my ($items) = @_;
        my $out = undef;
-       my(@tmp) = grep(!/\[\[-/, @$items);
+       my(@tmp) = @$items;
 
        if (scalar @tmp>= 1) {
                $out = "<ul>".