Mail Archives: djgpp-workers/2000/08/28/09:43:47
This is the last missing piece in symlink puzzle, as pointed
out by Eli. I'll submit yet another one patch which makes
open() to resolve leading dirs even with O_NOLINK flag, but
is there anything else skipped?
Tested, works[*].
Any comments?
Laurynas
[*] For me.
Index: mkstemp.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/stdio/mkstemp.c,v
retrieving revision 1.2
diff -u -p -r1.2 mkstemp.c
--- mkstemp.c 1998/12/13 13:10:58 1.2
+++ mkstemp.c 2000/08/28 13:41:17
@@ -1,5 +1,7 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#include <libc/symlink.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
@@ -9,6 +11,7 @@ int
mkstemp (char *_template)
{
char tmp_name[FILENAME_MAX];
+ char real_path[FILENAME_MAX];
int fd = -1;
/* Make sure we create a non-exisiting file, even
@@ -17,7 +20,8 @@ mkstemp (char *_template)
strcpy(tmp_name, _template);
errno = 0;
} while (mktemp (tmp_name) != NULL
- && (fd = _creatnew(tmp_name, 0, SH_DENYRW)) == -1
+ && __solve_symlinks(tmp_name, real_path)
+ && (fd = _creatnew(real_path, 0, SH_DENYRW)) == -1
&& errno == EEXIST);
if (fd == -1)
- Raw text -