On Tue, Dec 16, 2003 at 02:47:42PM +0100, Tim Dijkstra wrote:
> On Mon, 15 Dec 2003 17:06:32 -0500
> Clint Adams <[EMAIL PROTECTED]> wrote:
> 
> > > I couldn't find any way to authenticate db.debian.org when using
> > > direct LDAP(TLS doesn't seem to be supported), but nonetheless this
> > > is damn convenient.
> > > 
> > > (requires python-ldap)
> > 
> > Or, for people who don't want python installed.
> > 
> 
> [debian-known-hosts  text/plain (437 bytes)]
> #!/bin/zsh
> for i in ${(M)${(ps:\n\n:)${"$(ldapsearc ....
> 
> Now what do I do if I want neither python nor zsh installed ;)

You don't have a choice about having perl-base installed. Still need
ldap-utils, though; I figure that's less onerous than libnet-ldap-perl

(This is written for clarity. It can be written considerably shorter
if you don't make making it ugly. If you feel like doing so, please do
something worthwhile instead)

(MIT/X11 license)

-- 
  .''`.  ** Debian GNU/Linux ** | Andrew Suffield
 : :' :  http://www.debian.org/ |
 `. `'                          |
   `-             -><-          |
#!/usr/bin/perl

use strict;
use warnings;

open LDAPSEARCH, "-|", "ldapsearch -LLL -x -h db.debian.org -b dc=debian,dc=org 
-s sub objectClass=debianServer hostname sshRSAHostKey";
my $hostname;
while (<LDAPSEARCH>)
  {
    chomp;
    next if /^#/;
    if (/^dn:/)
      {
        $hostname = undef;
      }
    elsif (/^hostname: (\S+)$/)
      {
        $hostname = $1;
      }
    elsif (/^sshRSAHostKey: (.+)$/)
      {
        my $key = $1;
        while (<LDAPSEARCH>)
          {
            chomp;
            if (/^ (.+)$/)
              {
                $key .= $1;
              }
            elsif (/^sshRSAHostKey: (.+)$/)
              {
                print "$hostname $key\n" if defined $hostname;
                $key = $1;
              }
            else
              {
                last;
              }
          }
        print "$hostname $key\n" if defined $hostname;
      }
  }
close LDAPSEARCH;

Attachment: signature.asc
Description: Digital signature

Reply via email to