OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Michael Schloh
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-src                      Date:   22-Mar-2004 18:46:32
  Branch: HEAD                             Handle: 2004032217463101

  Added files:
    openpkg-src/ripe-dbase  rc.ripe-dbase.extobjs whois_filt.conf
                            whois_filt.pl
  Modified files:
    openpkg-src/ripe-dbase  ripe-dbase.spec

  Log:
    conditionally (with_extobjs yes) add whois_filt.pl, whois_filt.conf,
    and rc.ripe-dbase.extobjs to buildconf

  Summary:
    Revision    Changes     Path
    1.1         +64 -0      openpkg-src/ripe-dbase/rc.ripe-dbase.extobjs
    1.26        +13 -0      openpkg-src/ripe-dbase/ripe-dbase.spec
    1.1         +47 -0      openpkg-src/ripe-dbase/whois_filt.conf
    1.1         +231 -0     openpkg-src/ripe-dbase/whois_filt.pl
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/ripe-dbase/rc.ripe-dbase.extobjs
  ============================================================================
  $ cvs diff -u -r0 -r1.1 rc.ripe-dbase.extobjs
  --- /dev/null 2004-03-22 18:46:32.000000000 +0100
  +++ rc.ripe-dbase.extobjs     2004-03-22 18:46:32.000000000 +0100
  @@ -0,0 +1,64 @@
  [EMAIL PROTECTED]@/lib/openpkg/bash @l_prefix@/etc/rc
  +##
  +##  rc.ripe-dbase -- Run-Commands
  +##
  +
  +%config
  +    ripe_dbase_enable="$openpkg_rc_def"
  +    rip_filter_enable="$openpkg_rc_def"
  +    ripe_dbase_log_prolog="true"
  +    ripe_dbase_log_epilog="true"
  +    ripe_dbase_log_numfiles="10"
  +    ripe_dbase_log_minsize="1M"
  +    ripe_dbase_log_complevel="9"
  +
  +%common
  +    ripe_dbase_pidrip="@l_prefix@/var/ripe-dbase/whois_rip.pid"
  +    ripe_dbase_pidfilt="@l_prefix@/var/ripe-dbase/whois_filt.pid"
  +    ripe_dbase_cfgfile="@l_prefix@/etc/ripe-dbase/rip.config.sample"
  +    ripe_dbase_signal () {
  +        [ -f $ripe_dbase_pidfile ] && kill -$1 `cat $ripe_dbase_pidfile`
  +    }
  +
  +%status -u @l_susr@ -o
  +    ripe_dbase_usable="unknown"
  +    ripe_dbase_active="no"
  +    rcService ripe-dbase enable yes && \
  +        ripe_dbase_signal 0 && ripe_dbase_active="yes"
  +    echo "ripe_dbase_enable=\"$ripe_dbase_enable\""
  +    echo "ripe_dbase_usable=\"$ripe_dbase_usable\""
  +    echo "ripe_dbase_active=\"$ripe_dbase_active\""
  +
  +%start -u @l_susr@
  +    #   main server
  +    rcService ripe-dbase enable yes || exit 0
  +    rcService ripe-dbase active yes && exit 0
  +    nohup @l_prefix@/bin/whois_rip -p ${ripe_dbase_pidfile} \
  +        -c ${ripe_dbase_cfgfile} &
  +    #   perl filter
  +    rcService rip_filter enable yes || exit 0
  +    rcService rip_filter active yes && exit 0
  +    @l_prefix@/bin/whois_filt
  +
  +%stop -u @l_susr@
  +    rcService ripe-dbase enable yes || exit 0
  +    rcService ripe-dbase active no  && exit 0
  +    ripe_dbase_signal TERM
  +    sleep 8
  +
  +%restart -u @l_susr@
  +    rcService ripe-dbase enable yes || exit 0
  +    rcService ripe-dbase active no  && exit 0
  +    rc ripe-dbase stop start
  +
  +%daily -u @l_susr@
  +    rcService ripe-dbase enable yes || exit 0
  +
  +    #   rotate logfile
  +    shtool rotate -f \
  +        -n ${ripe_dbase_log_numfiles} -s ${ripe_dbase_log_minsize} -d \
  +        -z ${ripe_dbase_log_complevel} -m 644 -o @l_susr@ -g @l_sgrp@ \
  +        -P "${ripe_dbase_log_prolog}" \
  +        -E "${ripe_dbase_log_epilog} && rc ripe_dbase restart" \
  +        @l_prefix@/var/ripe-dbase/log/whois_rip.err.log
  +
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/ripe-dbase/ripe-dbase.spec
  ============================================================================
  $ cvs diff -u -r1.25 -r1.26 ripe-dbase.spec
  --- openpkg-src/ripe-dbase/ripe-dbase.spec    22 Mar 2004 16:22:03 -0000      1.25
  +++ openpkg-src/ripe-dbase/ripe-dbase.spec    22 Mar 2004 17:46:31 -0000      1.26
  @@ -44,6 +44,9 @@
   Source1:      ripe-dbase-setup.sh
   Source2:      ripe-dbase-modify.sh
   Source3:      rc.ripe-dbase
  +Source4:      rc.ripe-dbase.extobjs
  +Source5:      whois_filt.pl
  +Source6:      whois_filt.conf
   Patch0:       ripe-dbase.patch
   Patch1:       ripe-dbase.patch.extobjs
   
  @@ -143,6 +146,16 @@
       %{l_shtool} install -c -m 755 %{l_value -s -a} \
           %{SOURCE ripe-dbase-modify.sh} \
           $RPM_BUILD_ROOT%{l_prefix}/sbin/ripe-dbase-modify
  +    l_hostname=`%{l_shtool} echo -e %h%d`
  +    %{l_shtool} install -c -m 755 %{l_value -s -a} \
  +        -e "s;@l_hostname@;$l_hostname;g" \
  +        %{SOURCE whois_filt.pl} \
  +        $RPM_BUILD_ROOT%{l_prefix}/bin/whois_filt
  +    %{l_shtool} install -c -m 755 %{l_value -s -a} \
  +        %{SOURCE whois_filt.conf} \
  +        $RPM_BUILD_ROOT%{l_prefix}/etc/ripe-dbase/
  +    %{l_shtool} install -c -m 755 %{l_value -s -a} \
  +        %{SOURCE rc.ripe-dbase.extobjs} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   %endif
       %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
           %{l_files_std} \
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/ripe-dbase/whois_filt.conf
  ============================================================================
  $ cvs diff -u -r0 -r1.1 whois_filt.conf
  --- /dev/null 2004-03-22 18:46:32.000000000 +0100
  +++ whois_filt.conf   2004-03-22 18:46:32.000000000 +0100
  @@ -0,0 +1,47 @@
  +#
  +# config.dat
  +#
  +# Defines various data needed for registry synchronisation
  +
  +#
  +# List of our private objects and attributes which
  +# will not get exported by the script
  +#
  +<private>
  +reg-id
  +window
  +facility
  +location
  +remedyref
  +ticket
  +reg-id
  +range
  +preference
  +purpose
  +registry
  +usedfor
  +region
  +comment
  +assigned
  +</private>
  +
  +#
  +# List all maintainers with according passwords which we will need here
  +#
  +# This is not case-sensitive
  +<maintainer>
  +LOCAL-DB-MNT XXXXXXXXXXX
  +CW-EUROPE-GSOC XXXXXXXXXXXX
  +IPERGY-NOC XXXXXXXXx
  +</maintainer>
  +
  +#
  +# This is the the list of source and destination sources
  +# of the registries we use. 
  +#
  +# Left side is the local source and right side is the destination
  +# source. The first pair defines the default for the script.
  +<source>
  +EUCW RIPE
  +ARINDB ARINDB
  +</source>
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/ripe-dbase/whois_filt.pl
  ============================================================================
  $ cvs diff -u -r0 -r1.1 whois_filt.pl
  --- /dev/null 2004-03-22 18:46:32.000000000 +0100
  +++ whois_filt.pl     2004-03-22 18:46:32.000000000 +0100
  @@ -0,0 +1,231 @@
  [EMAIL PROTECTED]@/bin/perl
  +
  +#
  +# whois wrapper to filter out private objects and attributes
  +#
  +# By Arnd Vehling, NetHead - 11/03/2004
  +#
  +# For Cable & Wireless Munic
  +#
  +
  +  require 5.004;
  +  use strict;
  +  require Net::Daemon;
  +  package cwho;
  +
  +  use RipeWhois;
  +  
  +  use vars qw($VERSION @ISA);
  +  $VERSION = '0.01';
  +  @ISA = qw(Net::Daemon); # to inherit from Net::Daemon
  +
  +  sub Version ($) { 'CW Local whoisd server by ::nethead::, 0.01'; }
  +  
  +  #
  +  # Glob Vars
  +  #
  +
  +  # Whois Server Definition
  +  my %ldb = ('Host' => '@l_hostname@',  'Port' => '43001', 
  +          'Mode' => 0);
  +
  +  my @header = (
  +  "% This is the Cable & Wireless Whois server.\n",
  +  "% The objects are in RPSL format.\n",
  +  "%\n",
  +  "% Rights restricted by copyright.\n\n"
  +  );
  +  
  +  # Configuration file with private definitions
  +  my $config="@l_prefix@/etc/ripe-dbase/whois_filt.config";
  +
  +  # All whois objects go into this
  +  my @src_objects = ();
  +  my @privates    = ();
  +
  +  # Which source
  +  my $local_source  = "ARINCW";
  +
  +  ##
  +  ## Whois Query Code
  +  ##
  +
  +  #
  +  # Parse Config File
  +  # 
  +  sub read_config 
  +  {
  +    # Parse config file and read private attributes and local-src name
  +    # for later use
  +    my $Mode = $/; undef $/;
  +    open( CONFIG, $config ) || die( "Cant open config-file $config\n" );
  +    my $cnf  = <CONFIG>;
  +
  +    # Put all private attributes into a string
  +    if ( $cnf =~ /<private>(.*?)<\/private>/ims ) {
  +     my $priv = $1;
  +     @privates = split( /\n/, $priv );
  +    } else { 
  +     die( "Problem with config file $config. No private attributes!\n" ); 
  +     }
  +
  +    close( CONFIG );
  +    $/ = $Mode;
  +  }
  +
  +
  +  #
  +  # Make the Query
  +  #
  +  sub do_query
  +  {
  +    my $whois_query = $_[0];
  +
  +    my $source_whois = new RipeWhois(Host => $ldb{'Host'}, 
  +                               Port => $ldb{'Port'},
  +                               FormatMode => $ldb{'Mode'});
  +
  +    unless(ref($source_whois)) {
  +       print STDERR "ERROR Failed to open Whois Source ".$ldb{'Host'}."\n";
  +       exit 1;
  +    }
  +
  +    if($source_whois->GetErrorCode()) {
  +       print "Error. Problem with ". $ldb{'Host'}.":".$ldb{'Port'}." 
".$source_whois->GetErrorString();
  +       exit 2;
  +    }
  +
  +    # Execute query 
  +    #print "Query: $whois_query\n";
  +
  +    @src_objects = $source_whois->QueryObjects($whois_query);
  +
  +    unless(@src_objects) {
  +      print "\nNo Objects found.\n";
  +      my $myerr = $source_whois->GetErrorString();
  +      print "Query error: $myerr\n";
  +      exit 3;
  +    }
  +
  +    $source_whois->destroy();
  +  }
  +
  +  ##
  +  ## Daemon Code
  +  ##
  +
  +  # Treat command line option in the constructor
  +  sub new ($$;$) {
  +      my($class, $attr, $args) = @_;
  +      my($self) = $class->SUPER::new($attr, $args);
  +      if ($self->{'parent'}) {
  +          # Called via Clone()
  +          $self->{'base'} = $self->{'parent'}->{'base'};
  +      } else {
  +          # Initial call
  +          if ($self->{'options'}  &&  $self->{'options'}->{'base'}) {
  +              $self->{'base'} = $self->{'options'}->{'base'}
  +          }
  +      }
  +      if (!$self->{'base'}) {
  +          $self->{'base'} = 'dec';
  +      }
  +      $self;
  +  }
  +
  +  sub Run ($) {
  +
  +      my($self) = @_;
  +      my($line, $sock, $source, $query, $rc);
  +      $sock = $self->{'socket'};
  +     
  +      if (!defined($line = $sock->getline())) {
  +       if ($sock->error()) {
  +           $self->Error("Client connection error %s",
  +                        $sock->error());
  +       }
  +       $sock->close();
  +       return;
  +      }
  +
  +      # Process whois query
  +      $line =~ s/\s+$//; # Remove CRLF, if any
  +      
  +      # Construct Query
  +      $query = "-s $local_source $line";
  +     
  +      # Execute Query, fills @src_objects
  +      &do_query( $query );
  +
  +      # Print header
  +      #map {($rc = printf $sock)} @header;
  +      $rc = printf $sock @header;
  +
  +      if (!$rc) {
  +       $self->Error("Client connection error %s",
  +                    $sock->error());
  +       $sock->close();
  +       return;
  +      }
  +
  +      # Filter and Print Objects
  +      foreach $source (@src_objects) {
  +
  +     #
  +     # Skip private Objects 
  +     #
  +     # I need to change the config.dat format
  +     # so that attributes and objects are in separate
  +     # config sections so i dont need to code it
  +     # statically here
  +     #
  +     if ( ($source =~ /remarks:\s+NO-EXPORT/is) ||
  +          ($source =~ /^range:\s+/is)           ||
  +          ($source =~ /^ticket:\s+/is)          ||
  +          ($source =~ /^reg-id:\s+/is)          ||
  +          ($source =~ /^purpose:\s+/is)         || 
  +          ($source =~ /^facility:\s+/is)       
  +        ) { next; }
  +
  +     # Remove private attributes, if any
  +     foreach my $priv (@privates) {
  +       $source =~ s/^$priv:.*?$//mgi;
  +     }
  +     $source =~ s/\n\n/\n/g;
  +
  +     print("\n$source\n");
  +     $rc = printf $sock ("\n$source\n");
  +
  +     if (!$rc) {
  +         $self->Error("Client connection error %s",
  +                      $sock->error());
  +         $sock->close();
  +         return;
  +     }
  +      } # foreach
  +
  +      $rc = printf $sock ("\n");
  +
  +      if (!$rc) {
  +       $self->Error("Client connection error %s",
  +                    $sock->error());
  +       $sock->close();
  +       return;
  +      }
  +  }
  +
  +##
  +## Main
  +##
  +
  +
  +  # Read Config File
  +  &read_config();
  +
  +  package Main;
  +
  +  # Create Server
  +  my $server = cwho->new({'pidfile' => '@l_prefix@/var/ripe-dbase/whois_filt.pid', 
'localport' => 43}, [EMAIL PROTECTED]);
  +  # Bind to address/port, run server
  +  $server->Bind();
  +
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to