X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslurpd%2Freject.c;h=0b4d5ee12e04f1de9d7c49cebc909464f0cc6baf;hb=782b481a9a0415fb652590282b95bb11701a00e4;hp=a8f2f657b79dca972b265e5f224bdb7144b872ec;hpb=3d491808a8d12428eae124e73c49876befef3286;p=openldap diff --git a/servers/slurpd/reject.c b/servers/slurpd/reject.c index a8f2f657b7..0b4d5ee12e 100644 --- a/servers/slurpd/reject.c +++ b/servers/slurpd/reject.c @@ -1,6 +1,6 @@ /* $OpenLDAP$ */ /* - * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ /* @@ -36,6 +36,12 @@ #include "slurp.h" #include "globals.h" +#ifdef _WIN32 +#define PORTSEP "," +#else +#define PORTSEP ":" +#endif + /* * Write a replication record to a reject file. The reject file has the * same name as the replica's private copy of the file but with ".rej" @@ -57,18 +63,18 @@ write_reject( int rc; ldap_pvt_thread_mutex_lock( &sglob->rej_mutex ); - sprintf( rejfile, "%s" LDAP_DIRSEP "%s:%d.rej", sglob->slurpd_rdir, - ri->ri_hostname, ri->ri_port ); + snprintf( rejfile, sizeof rejfile, "%s" LDAP_DIRSEP "%s" PORTSEP "%d.rej", + sglob->slurpd_rdir, ri->ri_hostname, ri->ri_port ); if ( access( rejfile, F_OK ) < 0 ) { /* Doesn't exist - try to create */ int rjfd; - if (( rjfd = open( rejfile, O_RDWR | O_APPEND | O_CREAT, + if (( rjfd = open( rejfile, O_RDWR|O_APPEND|O_CREAT|O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )) < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "reject", LDAP_LEVEL_ERR, "write_reject: " + LDAP_LOG ( SLURPD, ERR, "write_reject: " "Error: Cannot create \"%s\":%s\n", - rejfile, sys_errlist[ errno ] )); + rejfile, sys_errlist[ errno ], 0 ); #else Debug( LDAP_DEBUG_ANY, "Error: write_reject: Cannot create \"%s\": %s\n", @@ -82,8 +88,8 @@ write_reject( } if (( rc = acquire_lock( rejfile, &rfp, &lfp )) < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "reject", LDAP_LEVEL_ERR, "write_reject: " - "Error: Cannot open reject file \"%s\"\n", rejfile )); + LDAP_LOG ( SLURPD, ERR, "write_reject: " + "Error: Cannot open reject file \"%s\"\n", rejfile, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "Error: cannot open reject file \"%s\"\n", rejfile, 0, 0 ); @@ -97,8 +103,8 @@ write_reject( } if ((rc = re->re_write( ri, re, rfp )) < 0 ) { #ifdef NEW_LOGGING - LDAP_LOG (( "reject", LDAP_LEVEL_ERR, "write_reject: " - "Error: Cannot write reject file \"%s\"\n", rejfile )); + LDAP_LOG ( SLURPD, ERR, "write_reject: " + "Error: Cannot write reject file \"%s\"\n", rejfile, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "Error: cannot write reject file \"%s\"\n", @@ -107,8 +113,9 @@ write_reject( } (void) relinquish_lock( rejfile, rfp, lfp ); #ifdef NEW_LOGGING - LDAP_LOG (( "reject", LDAP_LEVEL_ERR, "write_reject: " - "Error: ldap operation failed, data written to \"%s\"\n", rejfile )); + LDAP_LOG ( SLURPD, ERR, "write_reject: " + "Error: ldap operation failed, data written to \"%s\"\n", + rejfile, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, "Error: ldap operation failed, data written to \"%s\"\n",