int code;
snprintf(buffer, sizeof(buffer), "%s/afs_XXXXXX", gettmpdir());
- mkdtemp(buffer);
+ afstest_mkdtemp(buffer);
dirEnd = buffer + strlen(buffer);
/* Create a CellServDB file */
/* config.c */
extern char *afstest_BuildTestConfig(void);
extern void afstest_UnlinkTestConfig(char *);
+extern char *afstest_mkdtemp(char *template);
struct afsconf_dir;
extern int afstest_AddDESKeyFile(struct afsconf_dir *dir);
}
/*!
+ * Wrapper for mkdtemp
+ */
+
+char *
+afstest_mkdtemp(char *template)
+{
+#if defined(HAVE_MKDTEMP)
+ return mkdtemp(template);
+#else
+ /*
+ * Note that using the following is not a robust replacement
+ * for mkdtemp as there is a possible race condition between
+ * creating the name and creating the directory itself. The
+ * use of this routine is limited to running tests.
+ */
+ if (mktemp(template) == NULL)
+ return NULL;
+ if (mkdir(template, 0700))
+ return NULL;
+ return template;
+#endif
+}
+
+/*!
* Build a test configuration directory, containing a CellServDB and ThisCell
* file for the "example.org" cell
*
if (asprintf(&dir, "%s/afs_XXXXXX", gettmpdir()) == -1)
goto fail;
- if (mkdtemp(dir) == NULL)
+ if (afstest_mkdtemp(dir) == NULL)
goto fail;
/* Work out which IP address to use in our CellServDB. We figure this out