Mercurial > gnulib
changeset 39799:b0ba15e72c3c
getpass: Move declaration to <unistd.h>.
* lib/unistd.in.h (getpass): New declaration.
* lib/getpass.h: Replace with a stub that just includes <unistd.h>.
* m4/getpass.m4 (gl_FUNC_GETPASS): Declare through AC_DEFUN_ONCE.
Require gl_UNISTD_H_DEFAULTS. Don't test whether getpass is declared.
(gl_FUNC_GETPASS_GNU): Require gl_UNISTD_H_DEFAULTS and gl_FUNC_GETPASS.
On glibc systems, don't set REPLACE_GETPASS to 1.
* modules/getpass (Depends-on): Add 'unistd'.
(configure.ac): Test also REPLACE_GETPASS. Define a module indicator.
(Include): Specify <unistd.h> instead of "getpass.h".
* modules/getpass-gnu (Depends-on): Merely depend on 'getpass'.
(configure.ac): Sync with the configure.ac section of modules/getpass.
(Include): Specify <unistd.h> instead of "getpass.h".
* m4/unistd_h.m4 (gl_UNISTD_H): Test whether getpass is declared.
(gl_UNISTD_H_DEFAULTS): Initialize GNULIB_GETPASS, HAVE_GETPASS,
REPLACE_GETPASS.
* modules/unistd (Makefile.am): Substitute GNULIB_GETPASS, HAVE_GETPASS,
REPLACE_GETPASS.
* tests/test-unistd-c++.cc: Test also the declaration of 'getpass'.
* doc/glibc-functions/getpass.texi: A length limit exists also on uClibc
and musl.
* NEWS: Mention the change.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 19 Aug 2018 14:14:17 +0200 |
parents | cc685716a57d |
children | 516c78d5715b |
files | ChangeLog NEWS doc/glibc-functions/getpass.texi lib/getpass.h lib/unistd.in.h m4/getpass.m4 m4/unistd_h.m4 modules/getpass modules/getpass-gnu modules/unistd tests/test-unistd-c++.cc |
diffstat | 11 files changed, 107 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Aug 19 12:03:27 2018 +0200 +++ b/ChangeLog Sun Aug 19 14:14:17 2018 +0200 @@ -1,3 +1,28 @@ +2018-08-19 Bruno Haible <bruno@clisp.org> + + getpass: Move declaration to <unistd.h>. + * lib/unistd.in.h (getpass): New declaration. + * lib/getpass.h: Replace with a stub that just includes <unistd.h>. + * m4/getpass.m4 (gl_FUNC_GETPASS): Declare through AC_DEFUN_ONCE. + Require gl_UNISTD_H_DEFAULTS. Don't test whether getpass is declared. + (gl_FUNC_GETPASS_GNU): Require gl_UNISTD_H_DEFAULTS and gl_FUNC_GETPASS. + On glibc systems, don't set REPLACE_GETPASS to 1. + * modules/getpass (Depends-on): Add 'unistd'. + (configure.ac): Test also REPLACE_GETPASS. Define a module indicator. + (Include): Specify <unistd.h> instead of "getpass.h". + * modules/getpass-gnu (Depends-on): Merely depend on 'getpass'. + (configure.ac): Sync with the configure.ac section of modules/getpass. + (Include): Specify <unistd.h> instead of "getpass.h". + * m4/unistd_h.m4 (gl_UNISTD_H): Test whether getpass is declared. + (gl_UNISTD_H_DEFAULTS): Initialize GNULIB_GETPASS, HAVE_GETPASS, + REPLACE_GETPASS. + * modules/unistd (Makefile.am): Substitute GNULIB_GETPASS, HAVE_GETPASS, + REPLACE_GETPASS. + * tests/test-unistd-c++.cc: Test also the declaration of 'getpass'. + * doc/glibc-functions/getpass.texi: A length limit exists also on uClibc + and musl. + * NEWS: Mention the change. + 2018-08-19 Bruno Haible <bruno@clisp.org> glob: Fix over-optimization due to attribute __nonnull__.
--- a/NEWS Sun Aug 19 12:03:27 2018 +0200 +++ b/NEWS Sun Aug 19 14:14:17 2018 +0200 @@ -42,6 +42,9 @@ Date Modules Changes +2018-08-18 getpass The include file is changed from "getpass.h" to + getpass-gnu <unistd.h>. + 2018-07-17 hard-locale m4/hard-locale.m4 and gl_HARD_LOCALE are removed. 2018-07-05 renameat2 This module is renamed to 'renameatu' and all
--- a/doc/glibc-functions/getpass.texi Sun Aug 19 12:03:27 2018 +0200 +++ b/doc/glibc-functions/getpass.texi Sun Aug 19 14:14:17 2018 +0200 @@ -15,7 +15,7 @@ @itemize @item The returned password is truncated to PASS_MAX characters on some platforms: -Mac OS X 10.5 (128), FreeBSD 6.2 (128), NetBSD 3.0 (128), OpenBSD 4.0 (128), AIX 5.1 (32), HP-UX 11 (8), IRIX 6.5 (32), OSF/1 5.1 (80), Solaris 11 2010-11 (8, even less than PASS_MAX), Cygwin (128). +uClibc (256), musl (128), Mac OS X 10.5 (128), FreeBSD 6.2 (128), NetBSD 3.0 (128), OpenBSD 4.0 (128), AIX 5.1 (32), HP-UX 11 (8), IRIX 6.5 (32), OSF/1 5.1 (80), Solaris 11 2010-11 (8, even less than PASS_MAX), Cygwin (128). The gnulib implementation returns the password untruncated. @end itemize
--- a/lib/getpass.h Sun Aug 19 12:03:27 2018 +0200 +++ b/lib/getpass.h Sun Aug 19 14:14:17 2018 +0200 @@ -1,30 +1,4 @@ -/* getpass.h -- Read a password of arbitrary length from /dev/tty or stdin. - Copyright (C) 2004, 2009-2018 Free Software Foundation, Inc. - Contributed by Simon Josefsson <jas@extundo.com>, 2004. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <https://www.gnu.org/licenses/>. */ - -#ifndef GETPASS_H -# define GETPASS_H +/* Obsolete; consider using unistd.h instead. */ /* Get getpass declaration, if available. */ -# include <unistd.h> - -# if !HAVE_DECL_GETPASS -/* Read a password of arbitrary length from /dev/tty or stdin. */ -char *getpass (const char *prompt); - -# endif - -#endif /* GETPASS_H */ +#include <unistd.h>
--- a/lib/unistd.in.h Sun Aug 19 12:03:27 2018 +0200 +++ b/lib/unistd.in.h Sun Aug 19 14:14:17 2018 +0200 @@ -935,6 +935,36 @@ #endif +#if @GNULIB_GETPASS@ +/* Function getpass() from module 'getpass': + Read a password from /dev/tty or stdin. + Function getpass() from module 'getpass-gnu': + Read a password of arbitrary length from /dev/tty or stdin. */ +# if @REPLACE_GETPASS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getpass +# define getpass rpl_getpass +# endif +_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (getpass, char *, (const char *prompt)); +# else +# if !@HAVE_GETPASS@ +_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (getpass, char *, (const char *prompt)); +# endif +_GL_CXXALIASWARN (getpass); +#elif defined GNULIB_POSIXCHECK +# undef getpass +# if HAVE_RAW_DECL_GETPASS +_GL_WARN_ON_USE (getpass, "getpass is unportable - " + "use gnulib module getpass or getpass-gnu for portability"); +# endif +#endif + + #if @GNULIB_GETUSERSHELL@ /* Return the next valid login shell on the system, or NULL when the end of the list has been reached. */
--- a/m4/getpass.m4 Sun Aug 19 12:03:27 2018 +0200 +++ b/m4/getpass.m4 Sun Aug 19 14:14:17 2018 +0200 @@ -1,4 +1,4 @@ -# getpass.m4 serial 15 +# getpass.m4 serial 16 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2018 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -6,16 +6,15 @@ dnl with or without modifications, as long as this notice is preserved. # Provide a getpass() function if the system doesn't have it. -AC_DEFUN([gl_FUNC_GETPASS], +AC_DEFUN_ONCE([gl_FUNC_GETPASS], [ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + dnl Persuade Solaris <unistd.h> and <stdlib.h> to declare getpass(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_CHECK_FUNCS([getpass]) - AC_CHECK_DECLS_ONCE([getpass]) - if test $ac_cv_func_getpass = yes; then - HAVE_GETPASS=1 - else + AC_CHECK_FUNCS_ONCE([getpass]) + if test $ac_cv_func_getpass = no; then HAVE_GETPASS=0 fi ]) @@ -24,19 +23,27 @@ # arbitrary length (not just 8 bytes as on HP-UX). AC_DEFUN([gl_FUNC_GETPASS_GNU], [ - dnl Persuade Solaris <unistd.h> and <stdlib.h> to declare getpass(). - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - - AC_CHECK_DECLS_ONCE([getpass]) - dnl TODO: Detect when GNU getpass() is already found in glibc. - REPLACE_GETPASS=1 + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_GETPASS]) - if test $REPLACE_GETPASS = 1; then - dnl We must choose a different name for our function, since on ELF systems - dnl an unusable getpass() in libc.so would override our getpass() if it is - dnl compiled into a shared library. - AC_DEFINE([getpass], [gnu_getpass], - [Define to a replacement function name for getpass().]) + if test $ac_cv_func_getpass = yes; then + AC_CACHE_CHECK([for getpass without length limitations], + [gl_cv_func_getpass_good], + [AC_EGREP_CPP([Lucky GNU user], + [ +#include <features.h> +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ >= 2) && !defined __UCLIBC__ + Lucky GNU user + #endif +#endif + ], + [gl_cv_func_getpass_good=yes], + [gl_cv_func_getpass_good=no]) + ]) + if test $gl_cv_func_getpass_good != yes; then + REPLACE_GETPASS=1 + fi fi ])
--- a/m4/unistd_h.m4 Sun Aug 19 12:03:27 2018 +0200 +++ b/m4/unistd_h.m4 Sun Aug 19 14:14:17 2018 +0200 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 73 +# unistd_h.m4 serial 74 dnl Copyright (C) 2006-2018 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -43,7 +43,7 @@ #endif ]], [chdir chown dup dup2 dup3 environ euidaccess faccessat fchdir fchownat fdatasync fsync ftruncate getcwd getdomainname getdtablesize getgroups - gethostname getlogin getlogin_r getpagesize + gethostname getlogin getlogin_r getpagesize getpass getusershell setusershell endusershell group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite readlink readlinkat rmdir sethostname sleep symlink symlinkat @@ -83,6 +83,7 @@ GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN]) GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE]) + GNULIB_GETPASS=0; AC_SUBST([GNULIB_GETPASS]) GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL]) GNULIB_GROUP_MEMBER=0; AC_SUBST([GNULIB_GROUP_MEMBER]) GNULIB_ISATTY=0; AC_SUBST([GNULIB_ISATTY]) @@ -126,6 +127,7 @@ HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) + HAVE_GETPASS=1; AC_SUBST([HAVE_GETPASS]) HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER]) HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) HAVE_LINK=1; AC_SUBST([HAVE_LINK]) @@ -168,6 +170,7 @@ REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) + REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS]) REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY]) REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
--- a/modules/getpass Sun Aug 19 12:03:27 2018 +0200 +++ b/modules/getpass Sun Aug 19 14:14:17 2018 +0200 @@ -7,6 +7,7 @@ m4/getpass.m4 Depends-on: +unistd extensions fseeko getline @@ -15,15 +16,16 @@ configure.ac: gl_FUNC_GETPASS -if test $HAVE_GETPASS = 0; then +if test $HAVE_GETPASS = 0 || test $REPLACE_GETPASS = 1; then AC_LIBOBJ([getpass]) gl_PREREQ_GETPASS fi +gl_UNISTD_MODULE_INDICATOR([getpass]) Makefile.am: Include: -"getpass.h" +<unistd,h> License: LGPLv2+
--- a/modules/getpass-gnu Sun Aug 19 12:03:27 2018 +0200 +++ b/modules/getpass-gnu Sun Aug 19 14:14:17 2018 +0200 @@ -7,21 +7,20 @@ m4/getpass.m4 Depends-on: -fseeko -getline -stdbool +getpass configure.ac: gl_FUNC_GETPASS_GNU -if test $REPLACE_GETPASS = 1; then +if test $HAVE_GETPASS = 0 || test $REPLACE_GETPASS = 1; then AC_LIBOBJ([getpass]) gl_PREREQ_GETPASS fi +gl_UNISTD_MODULE_INDICATOR([getpass]) Makefile.am: Include: -"getpass.h" +<unistd.h> License: LGPL
--- a/modules/unistd Sun Aug 19 12:03:27 2018 +0200 +++ b/modules/unistd Sun Aug 19 14:14:17 2018 +0200 @@ -58,6 +58,7 @@ -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \ -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \ -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \ + -e 's/@''GNULIB_GETPASS''@/$(GNULIB_GETPASS)/g' \ -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \ -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \ -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \ @@ -101,6 +102,7 @@ -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ + -e 's|@''HAVE_GETPASS''@|$(HAVE_GETPASS)|g' \ -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \ -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ @@ -144,6 +146,7 @@ -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ + -e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \ -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
--- a/tests/test-unistd-c++.cc Sun Aug 19 12:03:27 2018 +0200 +++ b/tests/test-unistd-c++.cc Sun Aug 19 14:14:17 2018 +0200 @@ -110,6 +110,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::getpagesize, int, (void)); #endif +#if GNULIB_TEST_GETPASS +SIGNATURE_CHECK (GNULIB_NAMESPACE::getpass, char *, (const char *)); +#endif + #if GNULIB_TEST_GETUSERSHELL SIGNATURE_CHECK (GNULIB_NAMESPACE::getusershell, char *, (void)); #endif