mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Update.
* include/stdio.h: Add new parameter to __path_search. * libio/oldtmpfile.c: Add 0 as new parameter to __path_search. * stdio-common/tmpfile.c: Likewise. * stdio-common/tmpfile64.c: Likewise. * stdio-common/tmpnam.c: Likewise. * stdio-common/tmpnam_r.c: Likewise. * stdio-common/tempnam.c: Add 1 as new parameter to __path_search. * sysdeps/posix/tempname.c: Add new parameter. If value is nonzero consider TMPDIR environment variable and dir parameter. Otherwise not. * stdio-common/Makefile (tests): Add tst-tmpnam. * stdio-common/tst-tmpnam.c: New file.
This commit is contained in:
12
ChangeLog
12
ChangeLog
@ -1,5 +1,17 @@
|
|||||||
1998-12-14 Ulrich Drepper <drepper@cygnus.com>
|
1998-12-14 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* include/stdio.h: Add new parameter to __path_search.
|
||||||
|
* libio/oldtmpfile.c: Add 0 as new parameter to __path_search.
|
||||||
|
* stdio-common/tmpfile.c: Likewise.
|
||||||
|
* stdio-common/tmpfile64.c: Likewise.
|
||||||
|
* stdio-common/tmpnam.c: Likewise.
|
||||||
|
* stdio-common/tmpnam_r.c: Likewise.
|
||||||
|
* stdio-common/tempnam.c: Add 1 as new parameter to __path_search.
|
||||||
|
* sysdeps/posix/tempname.c: Add new parameter. If value is nonzero
|
||||||
|
consider TMPDIR environment variable and dir parameter. Otherwise not.
|
||||||
|
* stdio-common/Makefile (tests): Add tst-tmpnam.
|
||||||
|
* stdio-common/tst-tmpnam.c: New file.
|
||||||
|
|
||||||
* po/es.po: Update from translation team.
|
* po/es.po: Update from translation team.
|
||||||
|
|
||||||
1998-12-12 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
|
1998-12-12 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
|
||||||
|
@ -33,8 +33,8 @@ extern int __vsscanf __P ((__const char *__restrict __s,
|
|||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
/* Generate a unique file name (and possibly open it). */
|
/* Generate a unique file name (and possibly open it). */
|
||||||
extern int __path_search __P ((char *__tmpl, size_t __tmpl_len,
|
extern int __path_search __P ((char *__tmpl, size_t __tmpl_len,
|
||||||
__const char *__dir,
|
__const char *__dir, __const char *__pfx,
|
||||||
__const char *__pfx));
|
int __try_tempdir));
|
||||||
|
|
||||||
extern int __gen_tempname __P ((char *__tmpl, int __openit, int __large_file));
|
extern int __gen_tempname __P ((char *__tmpl, int __openit, int __large_file));
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ __old_tmpfile (void)
|
|||||||
int fd;
|
int fd;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
|
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
fd = __gen_tempname (buf, 1, 0);
|
fd = __gen_tempname (buf, 1, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
@ -48,7 +48,8 @@ tests := tst-printf tstscanf test_rdwr test-popen tstgetln test-fseek \
|
|||||||
xbug errnobug \
|
xbug errnobug \
|
||||||
bug1 bug2 bug3 bug4 bug5 bug6 bug7 bug8 bug9 bug10 bug11 bug12 \
|
bug1 bug2 bug3 bug4 bug5 bug6 bug7 bug8 bug9 bug10 bug11 bug12 \
|
||||||
tfformat tiformat tstdiomisc tst-printfsz tst-wc-printf \
|
tfformat tiformat tstdiomisc tst-printfsz tst-wc-printf \
|
||||||
scanf1 scanf2 scanf3 scanf4 scanf5 scanf7 scanf8 scanf9 scanf10
|
scanf1 scanf2 scanf3 scanf4 scanf5 scanf7 scanf8 scanf9 scanf10 \
|
||||||
|
tst-tmpnam
|
||||||
|
|
||||||
include ../Rules
|
include ../Rules
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ tempnam (const char *dir, const char *pfx)
|
|||||||
{
|
{
|
||||||
char buf[FILENAME_MAX];
|
char buf[FILENAME_MAX];
|
||||||
|
|
||||||
if (__path_search (buf, FILENAME_MAX, dir, pfx))
|
if (__path_search (buf, FILENAME_MAX, dir, pfx, 1))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (__gen_tempname (buf, 0, 0))
|
if (__gen_tempname (buf, 0, 0))
|
||||||
|
@ -36,7 +36,7 @@ tmpfile (void)
|
|||||||
int fd;
|
int fd;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
|
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
fd = __gen_tempname (buf, 1, 0);
|
fd = __gen_tempname (buf, 1, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
@ -35,7 +35,7 @@ tmpfile64 ()
|
|||||||
int fd;
|
int fd;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
|
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
fd = __gen_tempname (buf, 1, 1);
|
fd = __gen_tempname (buf, 1, 1);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
@ -34,7 +34,7 @@ tmpnam (char *s)
|
|||||||
/* In the following call we use the buffer pointed to by S if
|
/* In the following call we use the buffer pointed to by S if
|
||||||
non-NULL although we don't know the size. But we limit the size
|
non-NULL although we don't know the size. But we limit the size
|
||||||
to L_tmpnam characters in any case. */
|
to L_tmpnam characters in any case. */
|
||||||
if (__path_search (s ? : tmpbuf, L_tmpnam, NULL, NULL))
|
if (__path_search (s ? : tmpbuf, L_tmpnam, NULL, NULL, 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (__gen_tempname (s ? : tmpbuf, 0, 0))
|
if (__gen_tempname (s ? : tmpbuf, 0, 0))
|
||||||
|
@ -26,7 +26,7 @@ tmpnam_r (char *s)
|
|||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (__path_search (s, L_tmpnam, NULL, NULL))
|
if (__path_search (s, L_tmpnam, NULL, NULL, 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (__gen_tempname (s, 0, 0))
|
if (__gen_tempname (s, 0, 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
51
stdio-common/tst-tmpnam.c
Normal file
51
stdio-common/tst-tmpnam.c
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
|
/* Set TMPDIR to a value other than the traditional /tmp. */
|
||||||
|
setenv ("TMPDIR", "/usr", 1);
|
||||||
|
|
||||||
|
name = tmpnam (NULL);
|
||||||
|
|
||||||
|
printf ("name = %s\n", name);
|
||||||
|
|
||||||
|
/* Make sure the name is based on the value in TMPDIR. */
|
||||||
|
if (strncmp (name, "/usr", 4) == 0)
|
||||||
|
{
|
||||||
|
puts ("error: `tmpnam' used TMPDIR value");
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test that it is in the directory denoted by P_tmpdir. */
|
||||||
|
if (strncmp (name, P_tmpdir, sizeof (P_tmpdir) - 1) != 0)
|
||||||
|
{
|
||||||
|
puts ("error: `tmpnam' return value not in P_tmpdir directory");
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
@ -43,7 +43,8 @@ direxists (const char *dir)
|
|||||||
doesn't exist, none of the searched dirs exists, or there's not
|
doesn't exist, none of the searched dirs exists, or there's not
|
||||||
enough space in TMPL. */
|
enough space in TMPL. */
|
||||||
int
|
int
|
||||||
__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx)
|
__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
|
||||||
|
int try_tmpdir)
|
||||||
{
|
{
|
||||||
const char *d;
|
const char *d;
|
||||||
size_t dlen, plen;
|
size_t dlen, plen;
|
||||||
@ -60,14 +61,17 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx)
|
|||||||
plen = 5;
|
plen = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
d = __secure_getenv ("TMPDIR");
|
if (try_tmpdir)
|
||||||
if (d != NULL && direxists (d))
|
{
|
||||||
dir = d;
|
d = __secure_getenv ("TMPDIR");
|
||||||
else if (dir != NULL && direxists (dir))
|
if (d != NULL && direxists (d))
|
||||||
/* nothing */ ;
|
dir = d;
|
||||||
else if (direxists (P_tmpdir))
|
else if (dir != NULL && direxists (dir))
|
||||||
|
/* nothing */ ;
|
||||||
|
}
|
||||||
|
if (direxists (P_tmpdir))
|
||||||
dir = P_tmpdir;
|
dir = P_tmpdir;
|
||||||
else if (direxists ("/tmp"))
|
else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
|
||||||
dir = "/tmp";
|
dir = "/tmp";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user