backupfile, chdir-long, fts, savedir: make safer
[gnulib.git] / ChangeLog
index 8bf2621..3ac7d12 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,197 @@
+2009-09-02  Eric Blake  <ebb9@byu.net>
+
+       backupfile, chdir-long, fts, savedir: make safer
+       * lib/backupfile.c (includes): Use "dirent--.h", since
+       numbered_backup can write to stderr during readdir.
+       * lib/savedir.c (includes): Likewise.
+       * lib/chdir-long.c (includes): Use "fcntl--.h", since openat
+       emulation can write to stderr on failure.
+       * lib/fts.c (includes) [!_LIBC]: Likewise for opendir and openat.
+       * lib/getcwd.c: Document why opendir_safer is unused.
+       * lib/glob.c: Likewise.
+       * lib/scandir.c: Likewise.
+       * lib/openat-proc.c: Likewise, for open_safer.
+       * modules/backupfile (Depends-on): Add dirent-safer.
+       * modules/savedir (Depends-on): Likewise.
+       * modules/fts (Depends-on): Add dirent-safer and openat-safer.
+       * modules/chdir-long (Depends-on): Add openat-safer.
+
+       openat-safer: new module
+       * modules/openat-safer: New file.
+       * lib/openat-safer.c: Likewise.
+       * m4/fcntl-safer.m4 (gl_OPENAT_SAFER): New macro.
+       * lib/fcntl-safer.h (openat_safer): Declare.
+       * lib/fcntl--.h (openat): Override.
+       * MODULES.html.sh (File descriptor based I/O): Mention it.
+       * lib/openat.h: Add double-inclusion guards.
+       * lib/openat.c (includes): Only include "fcntl-safer.h", not
+       "fcntl--.h", so we can implement openat.
+       * modules/openat-safer-tests: New test.
+       * tests/test-openat-safer.c: New file.
+
+       dirent-safer: new module
+       * modules/dirent-safer: New file.
+       * lib/dirent--.h: Likewise.
+       * lib/dirent-safer.h: Likewise.
+       * lib/opendir-safer.c: Likewise.
+       * m4/dirent-safer.m4: Likewise.
+       * MODULES.html.sh (Enhancements for POSIX:2008): Mention it.
+       * modules/dirent-safer-tests: New test.
+       * tests/test-dirent-safer.c: New file.
+       * lib/fdopendir.c (includes): Ensure fdopendir is also safe.
+
+       fdopendir: optimize on mingw
+       * lib/unistd.in.h (_gl_directory_name): New prototype.
+       * lib/fchdir.c (_gl_directory_name): Implement it.
+       (fchdir): Use it to simplify implementation.
+       * lib/fdopendir.c (fdopendir) [REPLACE_FCHDIR]: Use metadata from
+       fchdir, when available, to avoid calling [f]chdir().
+
+       fdopendir: split into its own module
+       * lib/openat.c (fdopendir): Move...
+       * lib/fdopendir.c: ...into new file.
+       * modules/fdopendir: New module.
+       * m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): New file.
+       * modules/openat (Depends-on): Add fdopendir.
+       * m4/openat.m4 (gl_FUNC_OPENAT): No longer need to check for
+       fdopendir here.
+       * modules/savedir (Depends-on): Only need fdopendir, not full
+       openat.
+       * lib/savedir.c (include): Use <dirent.h>, not "openat.h".
+       * lib/openat.h (fdopendir): Drop prototype.
+       * lib/dirent.in.h (fdopendir): Provide prototype.
+       * m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): Add replacements.
+       * modules/dirent (Makefile.am): Substitute them.
+       * MODULES.html.sh (File system functions): Mention it.
+       * doc/posix-functions/fdopendir.texi (fdopendir): Likewise.
+       * modules/fdopendir-tests: New file.
+       * tests/test-fdopendir.c: Likewise.
+
+       fchdir: use more consistent macro convention
+       * lib/fcntl.in.h (_gl_register_fd): Move declaration to unistd.
+       * lib/sys_stat.in.h (rpl_fstat): Declare via make-time
+       REPLACE_FCHDIR, rather than relying on config.h macros.
+       * lib/unistd.in.h (fchdir): Move all fchdir internal declarations
+       inside a single make-time REPLACE_FCHDIR block, rather than using
+       the config.h FCHDIR_REPLACEMENT.
+       * m4/fchdir.m4 (gl_FUNC_FCHDIR): REPLACE_FCHDIR was already
+       AC_SUBST'd, also AC_DEFINE it.  Don't define FCHDIR_REPLACEMENT.
+       Manage fstat replacement.
+       * m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Pick up
+       REPLACE_FCHDIR.
+       * modules/sys_stat (Files): Add m4/unistd_h.m4.
+       (Makefile.am): Substitute REPLACE_FCHDIR.
+       * lib/close.c (rpl_close): Use REPLACE_FCHDIR, not
+       FCHDIR_REPLACEMENT.
+       * lib/dup-safer.c (dup_safer): Likewise.
+       * lib/dup2.c (rpl_dup2): Likewise.
+       * lib/dup3.c (rpl_dup3): Likewise.
+       * lib/open.c (rpl_open): Likewise.
+
+       fchdir: simplify error handling, and support dup3
+       * modules/fchdir (Depends-on): Use strdup-posix, not strdup.  Add
+       stdbool, malloc-posix, realloc-posix.
+       * lib/fchdir.c (struct dir_info_t): Delete saved_errno.
+       (ensure_dirs_slot): Return false on allocation failure.
+       (rpl_dup2): Delete.
+       (_gl_register_dup): New function.
+       (_gl_unregister_fd, rpl_opendir, rpl_dup): Update callers.
+       (_gl_register_fd): Close fd on allocation failure.
+       * lib/fcntl.in.h (_gl_register_fd): Update signature.
+       * lib/unistd.in.h (_gl_register_dup) [FCHDIR_REPLACEMENT]: New
+       prototype.
+       (rpl_dup2_fchdir): Delete prototype.
+       * lib/open.c (open): Update caller.
+       * lib/dup2.c (dup2): Track fchdir metadata.
+       * lib/dup3.c (dup3): Likewise.
+       * m4/dup2.m4 (gl_REPLACE_DUP2): New macro.
+       * m4/fchdir.m4 (gl_FUNC_FCHDIR): Use it.
+
+2009-09-02  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       * gnulib-tool (func_create_testdir, func_create_megatestdir): Use
+       AC_CONFIG_HEADERS instead of AM_CONFIG_HEADER. Use AC_CONFIG_FILES and
+       don't pass arguments to AC_OUTPUT.
+
+2009-09-02  Bruno Haible  <bruno@clisp.org>
+
+       * modules/mkdtemp (License): Relicense under LGPLv2+.
+       Reported by Paolo Bonzini.
+
+2009-09-02  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       Replace uses of obsolete autoconf macros in Jim's modules.
+       The Autoconf macros AC_TRY_CPP, AC_TRY_COMPILE, AC_TRY_LINK and
+       AC_TRY_RUN have been obsolete since Autoconf 2.55, and each use
+       can evoke a warning from autoconf when run with -Wobsolete
+       enabled.  They were declared obsolete for good reasons (see
+       the `AC_FOO_IFELSE vs AC_TRY_FOO' node in the Autoconf manual,
+       recently renamed to `AC_ACT_IFELSE vs AC_TRY_ACT'), and we
+       should not continue using the deprecated macros.
+       * m4/d-type.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE): Replace
+       obsolete Autoconf macros with modern counterparts.
+       * m4/dirfd.m4 (gl_FUNC_DIRFD): Likewise.
+       * m4/dos.m4 (gl_AC_DOS): Likewise.
+       * m4/fpending.m4 (gl_FUNC_FPENDING): Likewise.
+       * m4/fsusage.m4 (gl_FILE_SYSTEM_USAGE): Likewise.
+       * m4/getloadavg.m4 (gl_PREREQ_GETLOADAVG): Likewise.
+       * m4/jm-winsz1.m4 (gl_WINSIZE_IN_PTEM): Likewise.
+       * m4/link-follow.m4 (gl_AC_FUNC_LINK_FOLLOWS_SYMLINK): Likewise.
+       * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Likewise.
+       * m4/mkdir-slash.m4 (gl_FUNC_MKDIR_TRAILING_SLASH): Likewise.
+       * m4/mode_t.m4 (gl_PROMOTED_TYPE_MODE_T): Likewise.
+       * m4/rename-dest-slash.m4 (gl_FUNC_RENAME_TRAILING_DEST_SLASH):
+       Likewise.
+       * m4/rename.m4 (gl_FUNC_RENAME): Likewise.
+       * m4/rmdir-errno.m4 (gl_FUNC_RMDIR_NOTEMPTY): Likewise.
+       * m4/rpmatch.m4 (gl_PREREQ_RPMATCH): Likewise.
+       * m4/st_dm_mode.m4 (AC_STRUCT_ST_DM_MODE): Likewise.
+       * m4/stat-time.m4 (gl_STAT_TIME): Likewise.
+       * m4/utimes-null.m4 (gl_FUNC_UTIMES_NULL): Likewise.
+
+2009-09-01  Eric Blake  <ebb9@byu.net>
+
+       fchdir: fix off-by-one bug in previous patch
+       * lib/fchdir.c (rpl_fstat): Use correct bounds.
+       (_gl_unregister_fd): Delete useless if.
+
+2009-09-01  Daniel P. Berrange  <berrange@redhat.com>
+
+       maint.mk: sort the list of syntax-check rules
+       * top/maint.mk (syntax-check-rules): Sort syntax-check rules, so it's
+       easier to get a sense of progress when the rules are run sequentially
+       and take a long time.
+
+2009-09-01  Simon Josefsson  <simon@josefsson.org>
+
+       * modules/arpa_inet: Use $(MKDIR_P) instead of @MKDIR_P@.
+       * modules/netinet_in: Likewise.
+       * modules/sys_file: Likewise.
+       * modules/sys_ioctl: Likewise.
+       * modules/sys_select: Likewise.
+       * modules/sys_socket: Likewise.
+       * modules/sys_stat: Likewise.
+       * modules/sys_time: Likewise.
+       * modules/sys_times: Likewise.
+       * modules/sys_utsname: Likewise.
+       * modules/sys_wait: Likewise.
+
+2009-09-01  Jim Meyering  <meyering@redhat.com>
+
+       fts: help ensure that return values are not ignored
+       * lib/fts_.h (__GNUC_PREREQ): Define.
+       (__attribute_warn_unused_result__): Define.
+       (fts_children, fts_close, fts_open, fts_read): Declare with
+       __attribute_warn_unused_result__.
+
+       fts: fts_close now fails also when closing a dir file descriptor fails
+       * lib/fts.c (fts_close): Detect close failure, not just fchdir failure,
+       and propagate to caller, along with errno.
+
+       announce-gen: correct formatting in --help output
+       * build-aux/announce-gen (usage): Move the one-line description in
+       --help output "up", to where it belongs, just after Usage:.
+
 2009-08-31  Eric Blake  <ebb9@byu.net>
 
        fchdir: port to mingw