summaryrefslogtreecommitdiff
path: root/modules/tempname
Commit message (Collapse)AuthorAgeFilesLines
* tempname: consume less entropyPaul Eggert2021-01-111-0/+1
| | | | | | | | | | Derived from a glibc patch proposed by Adhemerval Zanella in: https://sourceware.org/pipermail/libc-alpha/2021-January/121302.html * lib/tempname.c: Include stdbool.h. (random_bits): New arg use_getrandom. (try_tempname_len): Skip getrandom on the first try, unless __GT_NOCREATE. * modules/tempname (Depends-on): Add stdbool.
* Update link dependencies in modules after 2020-09-09 change.Bruno Haible2020-11-161-0/+1
| | | | | | | | | | | | * modules/tempname (Link): Add $(LIB_CLOCK_GETTIME). * modules/mkdtemp (Link): Likewise. * modules/mkostemp (Link): Likewise. * modules/mkostemps (Link): Likewise. * modules/mkstemp (Link): Likewise. * modules/mkstemps (Link): Likewise. * modules/supersede (Link): Likewise. * modules/tmpfile (Link): Likewise. * modules/tmpfile-safer (Link): Likewise.
* tempname: help merge with glibcPaul Eggert2020-09-101-0/+3
| | | | | | | | | | | | | | | | | Inspired by draft patches by Adhemerval Zanella in: https://sourceware.org/pipermail/libc-alpha/2020-September/117501.html https://sourceware.org/pipermail/libc-alpha/2020-September/117502.html * lib/tempname.c: Include stdalign.h, time.h. If _LIBC, do not include random-bits.h. (__getrandom, __clock_gettime64, __timespec64) [!_LIBC]: New macros. (RANDOM_BITS): Remove, replacing with ... (random_bits): ... this new static function. All uses changed. Add entropy each time if getrandom is not supported. (RANDOM_VALUE, BASE_62_DIGITS, BASE_62_POWER): Assume 64-bit support a la C99. (try_tempname_len): Take advantage of ASLR when initializing random value. * modules/tempname (Depends-on): Add clock-time, stdalign, time.
* Use module 'c99' when needed for subobject initializer syntax.Bruno Haible2020-09-051-0/+1
| | | | | * modules/tempname (Depends-on): Add c99. * modules/nstrftime-tests (Depends-on): Likewise.
* clean-temp: Add support for temporary files with unpredictable names.Bruno Haible2020-07-041-0/+1
| | | | | | | * lib/clean-temp.h (gen_register_open_temp): New declaration. * lib/clean-temp.c: Include tempname.h. (gen_register_open_temp): New function. * modules/tempname (configure.ac): Define a module indicator.
* tempname et al.: Fix link errors on MSVC (regression from 2020-05-31).Bruno Haible2020-06-271-0/+3
| | | | | | | | | | | | | | | | | * modules/tempname (Link): New section. * modules/mkdtemp (Link): Likewise. * modules/clean-temp (Link): Likewise. * modules/mkstemp (Link): Likewise. * modules/stdlib-safer (Link): Likewise. * modules/mkstemps (Link): Likewise. * modules/mkostemp (Link): Likewise. * modules/mkostemps (Link): Likewise. * modules/tmpfile (Link): Likewise. * modules/tmpfile-safer (Link): Likewise. * modules/javacomp (Link): Add $(LIB_GETRANDOM). * modules/argv-iter-tests (Makefile.am): Link test-argv-iter with $(LIB_GETRANDOM). * NEWS: Mention the changes.
* tempname: use getrandom, not getentropyPaul Eggert2020-06-011-1/+1
| | | | | | | This removes a dependency, as getentropy depends on getrandom. * lib/tempname.c: Include sys/random.h instead of unistd.h. (RANDOM_BITS) [!_LIBC]: Use getrandom, not getentropy. * modules/tempname (Depends-on): Depend on getrandom, not getentropy.
* tempname: merge from glibc and coreutilsPaul Eggert2020-05-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Also, merge in Gnulib’s more-recent methods of making it easier to share between Gnulib and glibc, and fix a few randomness glitches. * lib/tempname.c: Include libc-config.h, not config.h, if !_LIBC. (__set_errno): Remove; libc-config.h does that for us. Do not include <sys/time.h>. (__secure_getenv) [_LIBC]: New macro. (__try_tempname, __getpid, __gettimeofday) [!_LIBC]: Remove macros. (RANDOM_BITS): Rewrite. (RANDOM_VALUE_MAX, BASE_62_DIGITS, BASE_62_POWER): New macros. (random_value): New typedef. (try_file, try_dir, try_nocreate): Move up. (gen_tempname_len, try_tempname_len): New functions. (gen_tempname_len): Use a constant array rather than a switch. (try_tempname_len): Don’t assume string length fits in int. Generalize use of RANDOM_BITS. If _LIBC, don’t assume RANDOM_BITS has enough entropy (it’s a bit short). (__gen_tempname): Rewrite in terms of gen_tempname_len. (__try_tempname): Rewrite in terms of try_tempname_len. * lib/tempname.h (gen_tempname_len, try_tempname_len): New decls. * modules/tempname (Depends-on): Remove gettimeofday, sys_time. Add getentropy, libc-config.
* tempname: Depend on 'mkdir'.Bruno Haible2018-10-051-0/+1
| | | | | | | Reported by Maarten Bosmans <mkbosmans@gmail.com> at <https://savannah.gnu.org/bugs/?33379>. * modules/tempname (Depends-on): Add 'mkdir'.
* tempname: do not depend on secure_getenvPaul Eggert2017-08-091-1/+0
| | | | | | Excess dependency noted by Eli Zaretskii (Bug#28023#17). * lib/tempname.c (__secure_getenv) [!_LIBC]: Remove; unused. * modules/tempname (Depends-on): Remove secure_getenv.
* Remove red warnings from the generated MODULES.html.Bruno Haible2017-04-211-1/+2
| | | | | | | | * modules/fcntl (Description): Disambiguate function references. * modules/getcwd-lgpl (Description): Likewise. * modules/hostent (Description): Likewise. * modules/servent (Description): Likewise. * modules/tempname (Description): Likewise.
* maint: various whitespace cleanups in tempnamePádraig Brady2015-02-111-1/+1
| | | | | | | | | | Recent changes to the tempname module, introduced whitespace inconsistencies that are triggering issues in coreutils diffs generated against the new files. * lib/tempname.c: Normalize spacing and line length. * lib/tempname.h: Likewise. * modules/tempname: Likewise.
* tempname: new try_tempname functionAndreas Gruenbacher2015-02-041-1/+1
| | | | | | | | | | | | | The way how gen_tempname() creates files is not always sufficient. For example, it may make sense to create directories when creating the temporary file or directory fails with errno set to ENOENT. Add a try_tempname() variant of gen_tempname() that allows that. Implement gen_tempname() on top of it. * lib/tempname.c (try_tempname): New function and backend of gen_tempname(). (try_file, try_dir, try_nocreate): Callbacks to use for the different kinds that gen_tempname supports (GT_FILE, GT_DIR, GT_NOCREATE). * lib/tempname.h (try_tempname): Declare here. * modules/tempname: Mention try_tempname.
* tempname: use secure_getenvPaul Eggert2013-02-041-0/+1
| | | | | | | * lib/tempname.c (__secure_getenv) [!_LIBC]: Define to secure_getenv, not getenv. * modules/tempname (Depends-on): Add secure_getenv.
* tempname: Support for MSVC.Bruno Haible2011-09-141-0/+1
| | | | | | * doc/posix-headers/fcntl.texi: Document the problem with O_ACCMODE on MSVC. * modules/tempname (Depends-on): Add fcntl-h.
* tempname: Move AC_LIBOBJ invocations to module description.Bruno Haible2011-06-161-0/+1
| | | | | * m4/tempname.m4 (gl_FUNC_GEN_TEMPNAME): Remove AC_LIBOBJ invocation. * modules/tempname (Makefile.am): Augment lib_SOURCES.
* * modules/tempname (Depends-on): Add lstat.Jim Meyering2008-10-281-0/+1
|
* * modules/tempname (License): Relicense under LGPLv2+.Jim Meyering2008-08-071-1/+1
|
* * MODULES.html.sh (Support for systems lacking POSIX:2001): NewPaul Eggert2007-01-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | module sys_time. * lib/gethrxtime.c: Include <sys/time.h>, since we can no longer assume timespec.h defines struct timeval. * lib/settime.c: Likewise. * lib/utimens.c: Likewise. * lib/gettime.c (gettime): Remove test against HAVE_GETTIMEOFDAY, since we now assume the gettimeofday module. * lib/tempname.c (__gen_tempname): Likewise. * lib/gettimeofday.h: Remove. * lib/gettimeofday.c: Include <sys/time.h> instead of "gettimeofday.h". Don't include <sys/types.h> and <stdlib.h>; shouldn't be needed. Include <time.h>, for 'time()'. (localtime_buffer_addr): Also use this workaround if TZSET_CLOBBERS_LOCALTIME. Set to a dummy static variable by default, to simplify the uses. All uses changed. (localtime, gmtime, tzset, gettimeofday): Reformat slightly so that #undef is inside {}, and 'const' follows type name consistently. (tzset): Define replacement only if TZSET_CLOBBERS_LOCALTIME. (gettimeofday): Do not use the maximum possible value for tv->tv_usec, since that might break usages other than ls.c. Instead, we'll leave ls.c alone. This undoes today's patch by Bruno. Add a compile-time warning for 1s-clock resolution; we've never observed the problem but might as well keep the canary. * lib/nanosleep.c: Include timespec.h first, for interface check. * lib/nanosleep.c: Include <sys/time.h> unconditionally, since we now assume the sys_time module. * lib/tempname.c: Likewise. * lib/timespec.h: Likewise. * lib/nanosleep.c: Don't worry about TIME_WITH_SYS_TIME; no longer needed. * lib/strftime.c: Likewise. * lib/timespec.h: Likewise. * lib/posixtm.c: Include posixtm.h first, for interface check. Don't worry about TM_IN_SYS_TIME; that's wayyy obsolete. * lib/posixtm.h: Include stdbool.h and time.h, for proper interface. * lib/strftime.c: Don't include <sys/types.h>; shouldn't be needed. * lib/sys_time_.h: New file. * lib/timespec.h (struct timespec): Use long int, not long. * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): (gl_FUNC_GETTIMEOFDAY_CLOBBER, gl_PREREQ_GETTIMEOFDAY): Remove obsolescent call to AC_HEADER_TIME. * m4/mktime.m4 (AC_FUNC_MKTIME): Likewise. * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Likewise. * m4/strftime.m4 (gl_FUNC_STRFTIME): Likewise. * m4/timespec.m4 (gl_TIMESPEC, gl_CHECK_TYPE_STRUCT_TIMESPEC): Likewise. * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Likewise. * m4/utimbuf.m4 (gl_CHECK_TYPE_STRUCT_UTIMBUF): Likewise. * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Move sys/time.h tests into the sys_time module. Check for gettimeofday just once. Prefix our variables with gl_, not with ac_ or jm_. Tighten test for gettimeofday signature to just check the signature. Merely compile it, since linking doesn't test signature. Improve test for whether gettimeofday.o is actually needed. (gl_FUNC_GETTIMEOFDAY_CLOBBER): Renamed from AC_FUNC_GETTIMEOFDAY_CLOBBER. All uses changed. Use AC_RUN_IFELSE rather than AC_TRY_RUN. If clobbering, set and define GETTIMEOFDAY_CLOBBERS_LOCALTIME. (gl_GETTIMEOFDAY_REPLACE_LOCALTIME): Don't define GETTIMEOFDAY_CLOBBERS_LOCALTIME; that's gl_FUNC_GETTIMEOFDAY_CLOBBER's job. Don't define tzset; that's gl_FUNC_TZSET_CLOBBER's job. * m4/mktime.m4 (AC_FUNC_MKTIME): Just include <time.h> rather than worrying about sys/time.h. * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Don't bother worrying about TIME_WITH_SYS_TIME. * m4/stat-time.m4 (gl_STAT_TIME): Likewise. * m4/posixtm.m4 (gl_POSIXTM): Remove obsolescent call to AC_STRUCT_TM. * m4/sys_time_h.m4: New file. * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Require gl_HEADER_SYS_TIME_H. Don't include sys/time.h. Return from main rather than exiting. Define TZSET_CLOBBERS_LOCALTIME, for consistency with other names; all uses changed. * modules/gethrxtime (Depends-on): Add sys_time. * modules/gettime (Depends-on): Likewise. * modules/gettimeofday (Depends-on): Likewise. * modules/nanosleep (Depends-on): Likewise. * modules/settime (Depends-on): Likewise. * modules/tempname (Depends-on): Likewise. * modules/utimens (Depends-on): Likewise. * modules/gettimeofday (Files): Remove lib/gettimeofday.h. (Include:) Change back to <sys/time.h>. (Maintainer:) Add self. * modules/sys_time: New file. * modules/tempname (Depends-on): Add gettimeofday. * tests/test-gettimeofday.c: Include <sys/time.h> rather than gettimeofday.h.
* * modules/tempname (License): Change to LGPL.Eric Blake2006-11-141-1/+1
|
* * MODULES.html.sh: Document tempname.Eric Blake2006-10-271-0/+26
* modules/mkstemp (Depends-on): Add tempname, and drop transitive dependencies. (Files): Move lib/tempname.c... * modules/tempname: ...to this new module. * m4/mkstemp.m4 (gl_FUNC_MKSTEMP): Remove tempname checks. (gl_PREREQ_TEMPNAME): Move... * m4/tempname.m4: ...to this new file. * lib/mkstemp.c (includes) [!_LIBC]: Use tempname.h. * modules/sys_stat (Depends-on): Add stat-macros. * lib/stat_.h (includes): Pick up stat macros. * m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Replace <sys/stat.h> if stat macros are broken. * lib/tempname.c (includes): No need to include "stat-macros.h". (__gen_tempname) [!_LIBC]: Expose as gen_tempname. (direxists, __path_search) [!_LIBC]: Don't compile these in gnulib; the tmpdir module covers that. * lib/tempname.h: New file.