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