| 1 |
# getpass.m4 |
| 2 |
# serial 20 |
| 3 |
dnl Copyright (C) 2002-2003, 2005-2006, 2009-2024 Free Software Foundation, |
| 4 |
dnl Inc. |
| 5 |
dnl This file is free software; the Free Software Foundation |
| 6 |
dnl gives unlimited permission to copy and/or distribute it, |
| 7 |
dnl with or without modifications, as long as this notice is preserved. |
| 8 |
dnl This file is offered as-is, without any warranty. |
| 9 |
|
| 10 |
# Provide a getpass() function if the system doesn't have it. |
| 11 |
AC_DEFUN_ONCE([gl_FUNC_GETPASS], |
| 12 |
[ |
| 13 |
AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) |
| 14 |
|
| 15 |
dnl Persuade Solaris <unistd.h> and <stdlib.h> to declare getpass(). |
| 16 |
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
| 17 |
|
| 18 |
dnl Persuade Android <unistd.h> to not define getpass() as an inline function. |
| 19 |
AC_DEFINE([NO_INLINE_GETPASS], [1], [Define to 1 on Android.]) |
| 20 |
|
| 21 |
AC_CHECK_FUNCS_ONCE([getpass]) |
| 22 |
if test $ac_cv_func_getpass = no; then |
| 23 |
HAVE_GETPASS=0 |
| 24 |
fi |
| 25 |
]) |
| 26 |
|
| 27 |
# Provide the GNU getpass() implementation. It supports passwords of |
| 28 |
# arbitrary length (not just 8 bytes as on HP-UX). |
| 29 |
AC_DEFUN([gl_FUNC_GETPASS_GNU], |
| 30 |
[ |
| 31 |
AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) |
| 32 |
AC_REQUIRE([gl_FUNC_GETPASS]) |
| 33 |
|
| 34 |
if test $ac_cv_func_getpass = yes; then |
| 35 |
AC_CACHE_CHECK([for getpass without length limitations], |
| 36 |
[gl_cv_func_getpass_good], |
| 37 |
[AC_EGREP_CPP([Lucky GNU user], |
| 38 |
[ |
| 39 |
#include <features.h> |
| 40 |
#ifdef __GNU_LIBRARY__ |
| 41 |
#if (__GLIBC__ >= 2) && !defined __UCLIBC__ |
| 42 |
Lucky GNU user |
| 43 |
#endif |
| 44 |
#endif |
| 45 |
], |
| 46 |
[gl_cv_func_getpass_good=yes], |
| 47 |
[gl_cv_func_getpass_good=no]) |
| 48 |
]) |
| 49 |
if test $gl_cv_func_getpass_good != yes; then |
| 50 |
REPLACE_GETPASS_FOR_GETPASS_GNU=1 |
| 51 |
fi |
| 52 |
fi |
| 53 |
]) |
| 54 |
|
| 55 |
# Prerequisites of lib/getpass.c. |
| 56 |
AC_DEFUN([gl_PREREQ_GETPASS], [ |
| 57 |
AC_CHECK_HEADERS_ONCE([stdio_ext.h termios.h]) |
| 58 |
gl_CHECK_FUNCS_ANDROID([__fsetlocking], [[#include <stdio_ext.h>]]) |
| 59 |
AC_CHECK_DECLS([__fsetlocking],,, |
| 60 |
[[#include <stdio.h> |
| 61 |
#if HAVE_STDIO_EXT_H |
| 62 |
#include <stdio_ext.h> |
| 63 |
#endif]]) |
| 64 |
AC_CHECK_DECLS_ONCE([fflush_unlocked]) |
| 65 |
AC_CHECK_DECLS_ONCE([flockfile]) |
| 66 |
AC_CHECK_DECLS_ONCE([fputs_unlocked]) |
| 67 |
AC_CHECK_DECLS_ONCE([funlockfile]) |
| 68 |
AC_CHECK_DECLS_ONCE([putc_unlocked]) |
| 69 |
gl_HAVE_TCGETATTR |
| 70 |
|
| 71 |
dnl We can't use AC_CHECK_FUNC here, because tcsetattr() is defined as a |
| 72 |
dnl static inline function when compiling for Android 4.4 or older. |
| 73 |
AC_CACHE_CHECK([for tcsetattr], [gl_cv_func_tcsetattr], |
| 74 |
[AC_LINK_IFELSE( |
| 75 |
[AC_LANG_PROGRAM( |
| 76 |
[[#include <termios.h> |
| 77 |
struct termios x; |
| 78 |
]], |
| 79 |
[[return tcsetattr(0,0,&x);]]) |
| 80 |
], |
| 81 |
[gl_cv_func_tcsetattr=yes], |
| 82 |
[gl_cv_func_tcsetattr=no]) |
| 83 |
]) |
| 84 |
if test $gl_cv_func_tcsetattr = yes; then |
| 85 |
HAVE_TCSETATTR=1 |
| 86 |
else |
| 87 |
HAVE_TCSETATTR=0 |
| 88 |
fi |
| 89 |
AC_DEFINE_UNQUOTED([HAVE_TCSETATTR], [$HAVE_TCSETATTR], |
| 90 |
[Define to 1 if the system has the 'tcsetattr' function.]) |
| 91 |
]) |