]> git.sur5r.net Git - openldap/blob - servers/slurpd/re.c
Resync with HEAD
[openldap] / servers / slurpd / re.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright (c) 1996 Regents of the University of Michigan.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of Michigan at Ann Arbor. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17
18 /* 
19  * re.c - routines which deal with Re (Replication entry) structures.
20  * An Re struct is an in-core representation of one replication to
21  * be performed, along with member functions which are called by other
22  * routines.  The Re struct is defined in slurp.h.
23  */
24
25
26 #include "portable.h"
27
28 #include <stdio.h>
29
30 #include <ac/errno.h>
31 #include <ac/socket.h>
32 #include <ac/string.h>
33 #include <ac/ctype.h>
34
35 #include "slurp.h"
36 #include "globals.h"
37
38 #include "../slapd/slap.h"
39
40 /* Forward references */
41 static Rh       *get_repl_hosts LDAP_P(( char *, int *, char ** ));
42 static int      gettype LDAP_P(( char * ));
43 static int      getchangetype LDAP_P(( char * ));
44 static int      Re_parse LDAP_P(( Re *re, char *replbuf ));
45 static void     Re_dump LDAP_P(( Re *re, FILE *fp ));
46 static void     warn_unknown_replica LDAP_P(( char *, int port ));
47
48 /* Globals, scoped within this file */
49 static int      nur = 0;        /* Number of unknown replicas */
50 static Rh       *ur = NULL;     /* array of unknown replica names */
51
52
53 /*
54  * Return the next Re in a linked list.
55  */
56 static Re *
57 Re_getnext(
58     Re  *re
59 )
60 {
61     return(( re == NULL ) ? NULL :  re->re_next );
62 }
63
64
65
66
67 /*
68  * Free an Re
69  * ??? Something should apparently return nonzero here, but I dont know what.
70  */
71 static int
72 Re_free(
73     Re  *re
74 )
75 {
76     Rh  *rh;
77     Mi  *mi;
78     int i;
79
80     if ( re == NULL ) {
81         return 0;
82     }
83     if ( re->re_refcnt > 0 ) {
84 #ifdef NEW_LOGGING
85         LDAP_LOG (( "re", LDAP_LEVEL_WARNING, "Re_free: "
86                 "Warning: freeing re (dn: %s) with nonzero refcnt\n", re->re_dn ));
87 #else
88         Debug( LDAP_DEBUG_ANY,
89                 "Warning: freeing re (dn: %s) with nonzero refcnt\n",
90                 re->re_dn, 0, 0 );
91 #endif
92     }
93
94     ldap_pvt_thread_mutex_destroy( &re->re_mutex );
95
96     if (( rh = re->re_replicas ) != NULL ) {
97         for ( i = 0; rh[ i ].rh_hostname != NULL; i++ ) {
98             free( rh[ i ].rh_hostname );
99         }
100         free( rh );
101     }
102     ch_free( re->re_dn );
103     if (( mi = re->re_mods ) != NULL ) {
104         for ( i = 0; mi[ i ].mi_type != NULL; i++ ) {
105             free( mi[ i ].mi_type );
106             ch_free( mi[ i ].mi_val );
107         }
108         free( mi );
109     }
110     free( re );
111     return 0;
112 }
113
114
115
116
117 /*
118  * Read a buffer of data from a replication log file and fill in
119  * an (already allocated) Re.
120  */
121
122 #define BEGIN           0
123 #define GOT_DN          1
124 #define GOT_TIME        2
125 #define GOT_CHANGETYPE  4
126 #define GOT_ALL         ( GOT_DN | GOT_TIME | GOT_CHANGETYPE )
127
128 static int
129 Re_parse(
130     Re          *re,
131     char        *replbuf
132 )
133 {
134     int                 state;
135     int                 nml;
136     char                *buf, *rp, *p;
137     size_t              buflen;
138     char                *type, *value;
139     ber_len_t   len;
140     int                 nreplicas;
141
142     if ( re == NULL ) {
143 #ifdef NEW_LOGGING
144         LDAP_LOG (( "re", LDAP_LEVEL_ERR, "Re_parse: Error: re is NULL\n" ));
145 #else
146         Debug( LDAP_DEBUG_ANY, "Re_parse: error: re is NULL\n", 0, 0, 0 );
147 #endif
148         return -1;
149     }
150     if ( replbuf == NULL ) {
151 #ifdef NEW_LOGGING
152         LDAP_LOG (( "re", LDAP_LEVEL_ERR, "Re_parse: Error: replbuf is NULL\n" ));
153 #else
154         Debug( LDAP_DEBUG_ANY, "Re_parse: error: replbuf is NULL\n", 0, 0, 0 );
155 #endif
156         return -1;
157     }
158
159     state = BEGIN;
160     nml = 0;    /* number of modification information entries */
161     rp = replbuf;
162
163     re->re_replicas = get_repl_hosts( replbuf, &nreplicas, &rp );
164     re->re_refcnt = sglob->num_replicas;
165
166     for (;;) {
167         if (( state == GOT_ALL ) || ( buf = ldif_getline( &rp )) == NULL ) {
168             break;
169         }
170         /*
171          * If we're processing a rejection log, then the first line
172          * of each replication record will begin with "ERROR" - just
173          * ignore it.
174          */
175         if ( strncmp( buf, ERROR_STR, strlen( ERROR_STR )) == 0 ) {
176             continue;
177         }
178         buflen = strlen( buf );
179         if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) {
180 #ifdef NEW_LOGGING
181                 LDAP_LOG (( "re", LDAP_LEVEL_ERR, 
182                         "Re_parse: Error: malformed replog file\n" ));
183 #else
184             Debug( LDAP_DEBUG_ANY,
185                     "Error: Re_parse: malformed replog file\n",
186                     0, 0, 0 );
187 #endif
188             return -1;
189         }
190         switch ( gettype( type )) {
191         case T_CHANGETYPE:
192             re->re_changetype = getchangetype( value );
193             state |= GOT_CHANGETYPE;
194             break;
195         case T_TIME:
196             if (( p = strchr( value, '.' )) != NULL ) {
197                 /* there was a sequence number */
198                 *p++ = '\0';
199             }
200             re->re_timestamp = atol( value );
201             if ( p != NULL && isdigit( (unsigned char) *p )) {
202                 re->re_seq = atoi( p );
203             }
204             state |= GOT_TIME;
205             break;
206         case T_DN:
207             re->re_dn = ch_malloc( len + 1 );
208                 AC_MEMCPY( re->re_dn, value, len );
209                 re->re_dn[ len ]='\0';
210             state |= GOT_DN;
211             break;
212         default:
213             if ( !( state == GOT_ALL )) {
214 #ifdef NEW_LOGGING
215                 LDAP_LOG (( "re", LDAP_LEVEL_ERR, 
216                         "Re_parse: Error: bad type <%s>\n", type ));
217 #else
218                 Debug( LDAP_DEBUG_ANY,
219                         "Error: Re_parse: bad type <%s>\n",
220                         type, 0, 0 );
221 #endif
222                 free( type );
223                 if ( value != NULL )
224                         free( value );
225                 return -1;
226             }
227         }
228         free( type );
229         if ( value != NULL )
230                 free( value );
231     }
232
233     if ( state != GOT_ALL ) {
234 #ifdef NEW_LOGGING
235         LDAP_LOG (( "re", LDAP_LEVEL_ERR, 
236                 "Re_parse: Error: malformed replog file\n" ));
237 #else
238         Debug( LDAP_DEBUG_ANY,
239                 "Error: Re_parse: malformed replog file\n",
240                 0, 0, 0 );
241 #endif
242         return -1;
243     }
244
245     for (;;) {
246         char *const dash = "-";
247
248         if (( buf = ldif_getline( &rp )) == NULL ) {
249             break;
250         }
251         buflen = strlen( buf );
252         if (( buflen == 1 ) && ( buf[ 0 ] == '-' )) {
253             type  = dash;
254             value = NULL;
255         } else {
256             if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) {
257 #ifdef NEW_LOGGING
258                 LDAP_LOG (( "re", LDAP_LEVEL_ERR, 
259                         "Re_parse: Error: malformed replog line \"%s\"\n", buf ));
260 #else
261                 Debug( LDAP_DEBUG_ANY,
262                         "Error: malformed replog line \"%s\"\n",
263                         buf, 0, 0 );
264 #endif
265                 return -1;
266             }
267         }
268         re->re_mods = ( Mi  *) ch_realloc( (char *) re->re_mods,
269             sizeof( Mi ) * ( nml + 2 ));
270         re->re_mods[ nml ].mi_type = strdup( type );
271         if ( value != NULL ) {
272             re->re_mods[ nml ].mi_val = ch_malloc( len + 1 );
273                 AC_MEMCPY( re->re_mods[ nml ].mi_val, value, len );
274                 re->re_mods[ nml ].mi_val[ len ] = '\0';
275             re->re_mods[ nml ].mi_len = len;
276         } else {
277             re->re_mods[ nml ].mi_val = NULL;
278             re->re_mods[ nml ].mi_len = 0;
279         }
280         re->re_mods[ nml + 1 ].mi_type = NULL;
281         re->re_mods[ nml + 1 ].mi_val = NULL;
282         nml++;
283
284         if ( type != dash )
285                 free( type );
286         if ( value != NULL )
287                 free( value );
288     }
289     return 0;
290 }
291
292
293
294 /*
295  * Extract the replication hosts from a repl buf.  Check to be sure that
296  * each replica host and port number are ones we know about (that is, they're
297  * in the slapd config file we read at startup).  Without that information
298  * from the config file, we won't have the appropriate credentials to
299  * make modifications.  If there are any unknown replica names, don't
300  * add them the the Re struct.  Instead, log a warning message.
301  */
302 static Rh *
303 get_repl_hosts(
304     char        *replbuf,
305     int         *r_nreplicas,
306     char        **r_rp
307 )
308 {
309     char                *type, *value, *line, *p;
310     Rh                  *rh = NULL;
311     int                 nreplicas;
312         ber_len_t       len;
313     int                 port;
314     int                 repl_ok;
315     int                 i;
316
317     if ( replbuf == NULL ) {
318         return( NULL );
319     }
320
321     nreplicas = 0;
322
323     /*
324      * Get the host names of the replicas
325      */
326     *r_nreplicas = 0;
327     *r_rp = replbuf;
328     for (;;) {
329         /* If this is a reject log, we need to skip over the ERROR: line */
330         if ( !strncmp( *r_rp, ERROR_STR, strlen( ERROR_STR ))) {
331             line = ldif_getline( r_rp );
332             if ( line == NULL ) {
333                 break;
334             }
335         }
336         if ( strncasecmp( *r_rp, "replica:", 7 )) {
337             break;
338         }
339         line = ldif_getline( r_rp );
340         if ( line == NULL ) {
341             break;
342         }
343         if ( ldif_parse_line( line, &type, &value, &len ) < 0 ) {
344             return( NULL );
345         }
346         port = 0;
347         if (( p = strchr( value, ':' )) != NULL ) {
348             *p = '\0';
349             p++;
350             if ( *p != '\0' ) {
351                 port = atoi( p );
352             }
353         }
354
355         /* Verify that we've heard of this replica before */
356         repl_ok = 0;
357         for ( i = 0; i < sglob->num_replicas; i++ ) {
358             if ( strcmp( sglob->replicas[ i ]->ri_hostname, value )) {
359                 continue;
360             }
361             if ( sglob->replicas[ i ]->ri_port == port ) {
362                 repl_ok = 1;
363                 break;
364             }
365         }
366         free( type );
367         if ( !repl_ok ) {
368             warn_unknown_replica( value, port );
369             if ( value != NULL )
370                 free( value );
371             continue;
372         }
373
374         rh = (Rh *) ch_realloc((char *) rh, ( nreplicas + 2 ) * sizeof( Rh ));
375         if ( rh == NULL ) {
376 #ifdef NEW_LOGGING
377                 LDAP_LOG (( "re", LDAP_LEVEL_ERR, 
378                         "get_repl_hosts: Out of memory\n" ));
379 #else
380             Debug( LDAP_DEBUG_ANY, "Out of memory in get_repl_hosts\n",
381                     0, 0, 0 );
382 #endif
383             return NULL;
384         }
385         rh[ nreplicas ].rh_hostname = strdup( value );
386         rh[ nreplicas ].rh_port = port;
387         nreplicas++;
388
389         if ( value != NULL )
390                 free( value );
391     }
392
393     if ( nreplicas == 0 ) {
394         return( NULL );
395     }
396
397     rh[ nreplicas ].rh_hostname = NULL;
398     *r_nreplicas = nreplicas;
399
400     return( rh );
401 }
402
403
404
405
406
407 /*
408  * Convert "type" to an int.
409  */
410 static int
411 gettype(
412     char        *type
413 )
414 {
415     if ( !strcmp( type, T_CHANGETYPESTR )) {
416         return( T_CHANGETYPE );
417     }
418     if ( !strcmp( type, T_TIMESTR )) {
419         return( T_TIME );
420     }
421     if ( !strcmp( type, T_DNSTR )) {
422         return( T_DN );
423     }
424     return( T_ERR );
425 }
426
427
428
429 /*
430  * Convert "changetype" to an int.
431  */
432 static int
433 getchangetype(
434     char        *changetype
435 )
436 {
437     if ( !strcmp( changetype, T_ADDCTSTR )) {
438         return( T_ADDCT );
439     }
440     if ( !strcmp( changetype, T_MODIFYCTSTR )) {
441         return( T_MODIFYCT );
442     }
443     if ( !strcmp( changetype, T_DELETECTSTR )) {
444         return( T_DELETECT );
445     }
446     if ( !strcmp( changetype, T_MODRDNCTSTR )) {
447         return( T_MODRDNCT );
448     }
449     return( T_ERR );
450 }
451
452
453
454
455 /*
456  * Find the first line which is not a "replica:" line in buf.
457  * Returns a pointer to the line.  Returns NULL if there are
458  * only "replica:" lines in buf.
459  */
460 static char *
461 skip_replica_lines(
462     char        *buf
463 )
464 {
465     char *p = buf;
466     for (;;) {
467         if ( strncasecmp( p, "replica:", 8 )) {
468             return( p );
469         }
470         while (( *p != '\0' )  && ( *p != '\n' )) {
471             p++;
472         }
473         if ( *p == '\0' ) {
474             return ( NULL );
475         } else {
476             p++;
477         }
478     }
479 }
480
481
482
483
484 /*
485  * For debugging purposes: dump the contents of a replication entry.
486  * to the given stream.
487  */
488 static void
489 Re_dump(
490     Re          *re,
491     FILE        *fp
492 )
493 {
494     int i;
495     Mi *mi;
496
497     if ( re == NULL ) {
498 #ifdef NEW_LOGGING
499         LDAP_LOG (( "re", LDAP_LEVEL_ERR, "Re_dump: re is NULL\n" ));
500 #else
501         Debug( LDAP_DEBUG_TRACE, "Re_dump: re is NULL\n", 0, 0, 0 );
502 #endif
503         return;
504     }
505     fprintf( fp, "Re_dump: ******\n" );
506     fprintf( fp, "re_refcnt: %d\n", re->re_refcnt );
507     fprintf( fp, "re_timestamp: %ld\n", (long) re->re_timestamp );
508     fprintf( fp, "re_seq: %d\n", re->re_seq );
509     for ( i = 0; re->re_replicas && re->re_replicas[ i ].rh_hostname != NULL;
510                 i++ ) {
511         fprintf( fp, "re_replicas[%d]: %s:%d\n", 
512                 i, re->re_replicas[ i ].rh_hostname,
513                 re->re_replicas[ i ].rh_port );
514     }
515     fprintf( fp, "re_dn: %s\n", re->re_dn );
516     switch ( re->re_changetype ) {
517     case T_ADDCT:
518         fprintf( fp, "re_changetype: add\n" );
519         break;
520     case T_MODIFYCT:
521         fprintf( fp, "re_changetype: modify\n" );
522         break;
523     case T_DELETECT:
524         fprintf( fp, "re_changetype: delete\n" );
525         break;
526     case T_MODRDNCT:
527         fprintf( fp, "re_changetype: modrdn\n" );
528         break;
529     default:
530         fprintf( fp, "re_changetype: (unknown, type = %d\n",
531                 re->re_changetype );
532     }
533     if ( re->re_mods == NULL ) {
534         fprintf( fp, "re_mods: (none)\n" );
535     } else {
536         mi = re->re_mods;
537         fprintf( fp, "re_mods:\n" );
538         for ( i = 0; mi[ i ].mi_type != NULL; i++ ) {
539             fprintf( fp, "  %s, \"%s\", (%d bytes)\n",
540                     mi[ i ].mi_type,
541                     mi[ i ].mi_val == NULL ?  "(null)" : mi[ i ].mi_val,
542                     mi[ i ].mi_len );
543         }
544     }
545     return;
546 }
547
548
549 /* 
550  * Given an Ri, an Re, and a file pointer, write a replication record to
551  * the file pointer.  If ri is NULL, then include all replicas in the
552  * output.  If ri is non-NULL, then only include a single "replica:" line
553  * (used when writing rejection records).  Returns 0 on success, -1
554  * on failure.  Note that Re_write will not write anything out if the
555  * refcnt is zero.
556  */
557 static int
558 Re_write(
559     Ri          *ri,
560     Re          *re,
561     FILE        *fp )
562 {
563     int         i;
564     char        *s;
565     int         rc = 0;
566
567     if ( re == NULL || fp == NULL ) {
568 #ifdef NEW_LOGGING
569         LDAP_LOG (( "re", LDAP_LEVEL_ERR, 
570                 "Re_write: Internal error: NULL argument\n" ));
571 #else
572         Debug( LDAP_DEBUG_ANY, "Internal error: Re_write: NULL argument\n",
573                 0, 0, 0 );
574 #endif
575         return -1;
576     }
577
578     if ( re->re_refcnt < 1 ) {
579         return 0;               /* this is not an error */
580     }
581
582     if ( ri != NULL ) {         /* write a single "replica:" line */
583         if ( fprintf( fp, "replica: %s:%d\n", ri->ri_hostname,
584                 ri->ri_port ) < 0 ) {
585             rc = -1;
586             goto bad;
587         }
588     } else {                    /* write multiple "replica:" lines */
589         for ( i = 0; re->re_replicas[ i ].rh_hostname != NULL; i++ ) {
590             if ( fprintf( fp, "replica: %s:%d\n",
591                     re->re_replicas[ i ].rh_hostname,
592                     re->re_replicas[ i ].rh_port ) < 0 ) {
593                 rc = -1;
594                 goto bad;
595             }
596         }
597     }
598     if ( fprintf( fp, "time: %ld.%d\n", (long) re->re_timestamp, re->re_seq ) < 0 ) {
599         rc = -1;
600         goto bad;
601     }
602     if ( fprintf( fp, "dn: %s\n", re->re_dn ) < 0 ) {
603         rc = -1;
604         goto bad;
605     }
606     if ( fprintf( fp, "changetype: " ) < 0 ) {
607         rc = -1;
608         goto bad;
609     }
610     switch ( re->re_changetype ) {
611     case T_ADDCT:
612         s = T_ADDCTSTR;
613         break;
614     case T_MODIFYCT:
615         s = T_MODIFYCTSTR;
616         break;
617     case T_DELETECT:
618         s = T_DELETECTSTR;
619         break;
620     case T_MODRDNCT:
621         s = T_MODRDNCTSTR;
622         break;
623     default:
624         s = "IllegalModifyType!!!";
625     }
626     if ( fprintf( fp, "%s\n", s ) < 0 ) {
627         rc = -1;
628         goto bad;
629     }
630     for ( i = 0; (( re->re_mods != NULL ) &&
631             ( re->re_mods[ i ].mi_type != NULL )); i++ ) {
632         if ( !strcmp( re->re_mods[ i ].mi_type, T_MODSEPSTR )) {
633             if ( fprintf( fp, "%s\n", T_MODSEPSTR ) < 0 ) {
634                 rc = -1;
635                 goto bad;
636             }
637         } else {
638             char *obuf;
639             obuf = ldif_put( LDIF_PUT_VALUE,
640                         re->re_mods[ i ].mi_type,
641                     re->re_mods[ i ].mi_val ? re->re_mods[ i ].mi_val : "",
642                     re->re_mods[ i ].mi_len );
643             if ( fputs( obuf, fp ) < 0 ) {
644                 rc = -1;
645                 free( obuf );
646                 goto bad;
647             } else {
648                 ber_memfree( obuf );
649             }
650         }
651     }
652     if ( fprintf( fp, "\n" ) < 0 ) {
653         rc = -1;
654         goto bad;
655     }
656     if ( fflush( fp ) != 0 ) {
657         rc = -1;
658         goto bad;
659     }
660 bad:
661     if ( rc != 0 ) {
662 #ifdef NEW_LOGGING
663         LDAP_LOG (( "re", LDAP_LEVEL_ERR, 
664                 "Re_write: Error while writing: %s\n", sys_errlist[ errno ] ));
665 #else
666         Debug( LDAP_DEBUG_ANY, "Error while writing: %s\n",
667                 sys_errlist[ errno ], 0, 0 );
668 #endif
669     }
670     return rc;
671 }
672
673
674
675
676 /*
677  * Decrement the refcnt.  Locking handled internally.
678  */
679 static int
680 Re_decrefcnt(
681     Re  *re
682 )
683 {
684     re->re_lock( re );
685     re->re_refcnt--;
686     re->re_unlock( re );
687     return 0;
688 }
689
690
691
692 /*
693  * Get the refcnt.  Locking handled internally.
694  */
695 static int
696 Re_getrefcnt(
697     Re  *re
698 )
699 {
700     int ret;
701
702     re->re_lock( re );
703     ret = re->re_refcnt;
704     re->re_unlock( re );
705     return ret;
706 }
707     
708     
709
710
711
712 /*
713  * Lock this replication entry
714  */
715 static int
716 Re_lock(
717     Re  *re
718 )
719 {
720     return( ldap_pvt_thread_mutex_lock( &re->re_mutex ));
721 }
722
723
724
725
726 /*
727  * Unlock this replication entry
728  */
729 static int
730 Re_unlock(
731     Re  *re
732 )
733 {
734     return( ldap_pvt_thread_mutex_unlock( &re->re_mutex ));
735 }
736
737
738
739
740 /* 
741  * Instantiate and initialize an Re.
742  */
743 int
744 Re_init(
745     Re **re
746 )
747 {
748     /* Instantiate */
749     (*re) = (Re *) malloc( sizeof( Re ));
750     if ( *re == NULL ) {
751         return -1;
752     }
753
754     /* Fill in the member function pointers */
755     (*re)->re_free = Re_free;
756     (*re)->re_getnext = Re_getnext;
757     (*re)->re_parse = Re_parse;
758     (*re)->re_write = Re_write;
759     (*re)->re_dump = Re_dump;
760     (*re)->re_lock = Re_lock;
761     (*re)->re_unlock = Re_unlock;
762     (*re)->re_decrefcnt = Re_decrefcnt;
763     (*re)->re_getrefcnt = Re_getrefcnt;
764
765     /* Initialize private data */
766    (*re)->re_refcnt = sglob->num_replicas;
767    (*re)->re_timestamp = (time_t) 0L;
768    (*re)->re_replicas = NULL;
769    (*re)->re_dn = NULL;
770    (*re)->re_changetype = 0;
771    (*re)->re_seq = 0;
772    (*re)->re_mods = NULL;
773    (*re)->re_next = NULL;
774
775    ldap_pvt_thread_mutex_init( &((*re)->re_mutex) );
776    return 0;
777 }
778
779
780
781
782 /*
783  * Given a host and port, generate a warning message iff we haven't already
784  * generated a message for this host:port combination.
785  */
786 static void
787 warn_unknown_replica( 
788     char        *host,
789     int         port
790 )
791 {
792     int found = 0;
793     int i;
794
795     for ( i = 0; i < nur; i++ ) {
796         if ( strcmp( ur[ i ].rh_hostname, host )) {
797             continue;
798         }
799         if ( ur[ i ].rh_port == port ) {
800             found = 1;
801             break;
802         }
803     }
804     if ( !found ) {
805 #ifdef NEW_LOGGING
806         LDAP_LOG (( "re", LDAP_LEVEL_WARNING, "warn_unknown_replica: "
807                 "Warning: unknown replica %s:%d found in replication log\n",
808                 host, port ));
809 #else
810         Debug( LDAP_DEBUG_ANY,
811                 "Warning: unknown replica %s:%d found in replication log\n",
812                 host, port, 0 );
813 #endif
814         nur++;
815         ur = (Rh *) ch_realloc( (char *) ur, ( nur * sizeof( Rh )));
816         ur[ nur - 1 ].rh_hostname = strdup( host );
817         ur[ nur - 1 ].rh_port = port;
818     }
819 }