From 8a0fdbb4e20b413ef75c4d8acb09f11f5030f89b Mon Sep 17 00:00:00 2001
From: Artem Polyakov <artpol84@gmail.com>
Date: Thu, 28 Apr 2016 16:31:19 -0700
Subject: [PATCH] Fix PMIx temp directory to spool (as for PMI2)

---
 src/plugins/mpi/pmix/pmixp_info.c | 21 +++------------------
 src/plugins/mpi/pmix/pmixp_info.h | 15 +++++----------
 2 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/src/plugins/mpi/pmix/pmixp_info.c b/src/plugins/mpi/pmix/pmixp_info.c
index 53f53ef9bfa..d2261c5d41e 100644
--- a/src/plugins/mpi/pmix/pmixp_info.c
+++ b/src/plugins/mpi/pmix/pmixp_info.c
@@ -286,27 +286,12 @@ err_exit:
 static int _env_set(char ***env)
 {
 	char *p = NULL;
+	char *spool = slurm_get_slurmd_spooldir();
 
 	/* ----------- Temp directories settings ------------- */
-
-	/*
-	 * FIXME: This is dangerous to set this from the user environment.
-	 * I was using this to debug in linux containers
-	 * On real hardware each node has it's own separate /tmp directory
-	 */
-
-	/* set server temp directory - change this process environment */
-	p = getenvp(*env, PMIXP_TMPDIR_SRV);
-	if (NULL != p) {
-		setenv(PMIXP_OS_TMPDIR_ENV, p, 1);
-	}
-
-	p = getenv(PMIXP_OS_TMPDIR_ENV);
-	if (NULL == p) {
-		p = PMIXP_TMPDIR_DEFAULT;
-	}
-	_pmixp_job_info.lib_tmpdir = xstrdup_printf("%s/pmix.%d.%d/", p,
+	_pmixp_job_info.lib_tmpdir = xstrdup_printf("%s/pmix.%d.%d/", spool,
 			pmixp_info_jobid(), pmixp_info_stepid());
+	xfree(spool);
 
 	/* save client temp directory if requested
 	 * TODO: We want to get TmpFS value as well if exists.
diff --git a/src/plugins/mpi/pmix/pmixp_info.h b/src/plugins/mpi/pmix/pmixp_info.h
index 51765c3d0b6..b51fec49382 100644
--- a/src/plugins/mpi/pmix/pmixp_info.h
+++ b/src/plugins/mpi/pmix/pmixp_info.h
@@ -267,16 +267,11 @@ static inline char *pmixp_info_job_host(int nodeid)
 /* namespaces list operations */
 static inline char *pmixp_info_nspace_usock(const char *nspace)
 {
-	char *usock = NULL;
-	/* TODO: provide the right way to set this:
-	 * - slrum.conf
-	 * - what else?
-	 */
-	char *tmpdir = getenv("TMPDIR");
-	if (NULL == tmpdir) {
-		tmpdir = PMIXP_TMPDIR_DEFAULT;
-	}
-	xstrfmtcat(usock, "%s/sock.stepd.%s", tmpdir, nspace);
+	char *spool, *usock = NULL;
+	debug("mpi/pmix: setup sockets");
+	spool = slurm_get_slurmd_spooldir();
+	xstrfmtcat(usock, "%s/stepd.%s", spool, nspace);
+	xfree(spool);
 	return usock;
 }
 
-- 
GitLab