From 47f53d7b6fafc4917c213e31d6f800adec41dbb6 Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Mon, 24 Apr 2000 17:03:23 +0000 Subject: [PATCH] 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 --- servers/slurpd/args.c | 3 ++- servers/slurpd/globals.c | 2 +- servers/slurpd/main.c | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/servers/slurpd/args.c b/servers/slurpd/args.c index c3b202065c..a807d8dd69 100644 --- a/servers/slurpd/args.c +++ b/servers/slurpd/args.c @@ -105,7 +105,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 HAVE_KERBEROS diff --git a/servers/slurpd/globals.c b/servers/slurpd/globals.c index fed3bbf31d..aebc413f8c 100644 --- a/servers/slurpd/globals.c +++ b/servers/slurpd/globals.c @@ -48,7 +48,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 cc094ba446..1510f21825 100644 --- a/servers/slurpd/main.c +++ b/servers/slurpd/main.c @@ -65,6 +65,14 @@ main( exit( 1 ); } + /* + * 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. */ -- 2.47.2