From: Ben Collins Date: Mon, 24 Apr 2000 17:03:45 +0000 (+0000) Subject: for slurpd's replica directory (slurpd.status, and rej file) use a subdir of what... X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~3088 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=32bdecbb5fb9fc8bb9163574fee6e6ef40a6cbc6;p=openldap for slurpd's replica directory (slurpd.status, and rej file) use a subdir of what the user specifies (add replica/ to it) to avoid /tmp races. A lot of the files that slurpd uses cannot be opened with O_EXCL, nor can we safely determine if there are any hardlinks from another file to it, so we create our own subdirectory so we can control the perms, even in /tmp --- diff --git a/servers/slurpd/args.c b/servers/slurpd/args.c index 6fd96c9dd9..ff28e0bb4f 100644 --- a/servers/slurpd/args.c +++ b/servers/slurpd/args.c @@ -111,7 +111,8 @@ doargs( rflag++; break; case 't': /* dir to use for our copies of replogs */ - g->slurpd_rdir = strdup( optarg ); + g->slurpd_rdir = (char *)malloc (strlen(optarg) + strlen("/replica") + 1); + sprintf(g->slurpd_rdir, "%s/replica", optarg); break; case 'k': /* name of kerberos srvtab file */ #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND diff --git a/servers/slurpd/globals.c b/servers/slurpd/globals.c index ec913dfd06..9c7911ffd5 100644 --- a/servers/slurpd/globals.c +++ b/servers/slurpd/globals.c @@ -50,7 +50,7 @@ init_globals( void ) g->slurpd_shutdown = 0; g->num_replicas = 0; g->replicas = NULL; - g->slurpd_rdir = DEFAULT_SLURPD_REPLICA_DIR; + g->slurpd_rdir = DEFAULT_SLURPD_REPLICA_DIR "/replica"; strcpy( g->slurpd_status_file, DEFAULT_SLURPD_STATUS_FILE ); g->slapd_replogfile[ 0 ] = '\0'; g->slurpd_replogfile[ 0 ] = '\0'; diff --git a/servers/slurpd/main.c b/servers/slurpd/main.c index 2aa86e75c9..ab029f26c2 100644 --- a/servers/slurpd/main.c +++ b/servers/slurpd/main.c @@ -70,6 +70,14 @@ main( exit( EXIT_FAILURE ); } + /* + * Make sure our directory exists + */ + if ( mkdir(sglob->slurpd_rdir, 0755) == -1 && errno != EEXIST) { + perror(sglob->slurpd_rdir); + exit( 1 ); + } + /* * Get any saved state information off the disk. */