1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 09:12:24 +00:00

Autoconf workaround for lack of setpwent / endpwent.

Test-building inside Termux on Android, it seems that <pwd.h> in that
environment defines the important functions getpwnam and getpwuid, but
not the setpwent/endpwent with which we bookend them. Tolerate their
absence.
This commit is contained in:
Simon Tatham 2019-03-26 19:03:15 +00:00
parent 235f5bf8ae
commit 9375d1325f
2 changed files with 5 additions and 1 deletions

View File

@ -173,7 +173,7 @@ AC_CHECK_LIB(X11, XOpenDisplay,
[GTK_LIBS="-lX11 $GTK_LIBS" [GTK_LIBS="-lX11 $GTK_LIBS"
AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])]) AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])])
AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx fstatat dirfd futimes]) AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx fstatat dirfd futimes setpwent endpwent])
AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]]) AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
AC_CHECK_HEADERS([sys/auxv.h asm/hwcap.h]) AC_CHECK_HEADERS([sys/auxv.h asm/hwcap.h])
AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])]) AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])])

View File

@ -119,7 +119,9 @@ char *get_username(void)
* coping correctly with people who have su'ed. * coping correctly with people who have su'ed.
*/ */
user = getlogin(); user = getlogin();
#if HAVE_SETPWENT
setpwent(); setpwent();
#endif
if (user) if (user)
p = getpwnam(user); p = getpwnam(user);
else else
@ -141,7 +143,9 @@ char *get_username(void)
return NULL; return NULL;
ret = p->pw_name; ret = p->pw_name;
} }
#if HAVE_ENDPWENT
endpwent(); endpwent();
#endif
return dupstr(ret); return dupstr(ret);
} }