Hello Howard

I've red this manpage quite a lot. Also trying to find somewhere
documentations about overlay interfaces, but without any success
I've also red the code. I don't understand how to say doit..

Here is my perl code, doing nothing..

#!/usr/bin/perl
use IO::Socket::UNIX;

my $socket_path = '/tmp/mysocket';
unlink $socket_path if -e $socket_path;

my $socket = IO::Socket::UNIX->new(
    Local  => $socket_path,
    Type   => SOCK_STREAM,
#    Type   => SOCK_DGRAM,
    Listen => SOMAXCONN,
);

die "Can't create socket: $!" unless $socket;
while (1) {
   next unless my $connection = $socket->accept;
   if (fork() == 0) {       $connection->autoflush(1);
       while (<$connection>) {
               #chomp($line);
               print ;
               next if /^ADD$/;
               next if /^msgid:/;
               next if /^suffix:/;
               print $connection $_;
               last if /^$/;
       }

       print $connection "CONTINUE\n";
       exit;
   }
}

And here is a BUG, in back-sock/result.c
It goes here only once at the end of the ldif, but never after..

      /* line marked the end of an entry or result */
      if ( *line == '\n' ) {
      Debug( LDAP_DEBUG_ANY, "TRACE1 \n", 0, 0, 0 );
         if ( strncasecmp( buf, "RESULT", 6 ) == 0 ) {
            break;
         }
      Debug( LDAP_DEBUG_ANY, "TRACE2 buf=%s\n",buf, 0, 0 );
         if ( strncasecmp( buf, "CONTINUE", 8 ) == 0 ) {
      Debug( LDAP_DEBUG_ANY, "TRACE3\n", 0, 0, 0 );
            struct sockinfo   *si = (struct sockinfo *)
op->o_bd->be_private;
            /* Only valid when operating as an overlay! */
            assert( si->si_ops != 0 );
            rs->sr_err = SLAP_CB_CONTINUE;
            goto skip;
         }
So I just put if ( strncasecmp( buf, "CONTINUE", 8 ) == 0 ) outside of if (
*line == '\n' ) { and it works..
I am no more a C specialist (1985 last time) so I don't know how to patch

Hope this helps other people, or if I'm wrong please correct me

Thanks

Dom





2015-06-23 18:22 GMT+02:00 Howard Chu <[email protected]>:

> Lalot Dominique wrote:
>
>> Hello,
>>
>> I am trying to understand how the sock overlay works. I'am partly
>> successfull
>> in getting the entries, so the unix socket is working.
>> What I want  to do, is acting as a trigger each time an entry is added
>> I receive the data, but I don't know how to say; "that's OK add it" to
>> mdm backend
>> I just answer "RESULT\n";
>> So the ldapadd is considered successfull, but in fact no entry is added.
>> Is there a way to do that? I have some difficulties to understand the way
>> it works
>>
>
> Re-read slapd-sock(5) manpage, paragraph "When used as an overlay"
>
>  Thanks
>>
>> Dom
>>
>>
>
> --
>   -- Howard Chu
>   CTO, Symas Corp.           http://www.symas.com
>   Director, Highland Sun     http://highlandsun.com/hyc/
>   Chief Architect, OpenLDAP  http://www.openldap.org/project/
>

Reply via email to