printf("->load_editor()\n");
#endif
- /* write the entry into a temp file */
- if (tmpnam(entry_temp_file) == NULL) {
- perror("tmpnam");
- return -1;
- }
- if ((tmpfd = open(entry_temp_file, O_WRONLY|O_CREAT|O_EXCL, 0600)) == -1) {
- perror(entry_temp_file);
+#ifdef HAVE_MKSTEMP
+ strcpy(entry_temp_file, LDAP_TMPDIR LDAP_DIRSEP "udXXXXXX");
+
+ tmpfd = mkstemp(entry_temp_file);
+
+ if( tmpfd < 0 ) {
+ perror("mkstemp");
return -1;
}
+
if ((fp = fdopen(tmpfd, "w")) == NULL) {
perror("fdopen");
return(-1);
}
+
+#else
+ fp = tmpfile();
+ if ( fp == NULL ) {
+ perror("tmpfile");
+ return(-1);
+ }
+#endif
+
fprintf(fp, "## Directory entry of %s\n", Entry.name);
fprintf(fp, "##\n");
fprintf(fp, "## Syntax is:\n");
if (verbose) {
char *p;
- if (( p = strrchr( editor, '/' )) == NULL ) {
+ if (( p = strrchr( editor, *LDAP_DIRSEP )) == NULL ) {
p = editor;
} else {
++p;