From 230c091c8766f4569dbe566b7f63404c46ff4065 Mon Sep 17 00:00:00 2001 From: hno <> Date: Tue, 16 Jul 2002 03:24:48 +0000 Subject: [PATCH] Not all systems support the 'obsolete' getpass() function --- configure.in | 5 +++-- src/client.cc | 26 +++++++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/configure.in b/configure.in index d27603ed02..6e8d01115a 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ dnl Configuration input file for Squid dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.277 2002/07/07 18:18:11 hno Exp $ +dnl $Id: configure.in,v 1.278 2002/07/15 21:24:48 hno Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AC_INIT(src/main.c) AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 2.6-DEVEL) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.277 $)dnl +AC_REVISION($Revision: 1.278 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -1662,6 +1662,7 @@ AC_CHECK_FUNCS(\ fchmod \ getdtablesize \ getpagesize \ + getpass \ getrlimit \ getrusage \ getspnam \ diff --git a/src/client.cc b/src/client.cc index ee686aaa30..8963b57b8b 100644 --- a/src/client.cc +++ b/src/client.cc @@ -1,6 +1,6 @@ /* - * $Id: client.cc,v 1.98 2002/07/15 21:18:32 hno Exp $ + * $Id: client.cc,v 1.99 2002/07/15 21:24:48 hno Exp $ * * DEBUG: section 0 WWW Client * AUTHOR: Harvest Derived @@ -252,24 +252,32 @@ main(int argc, char *argv[]) if (proxy_user) { char *user = proxy_user; char *password = proxy_password; +#if HAVE_GETPASS if (!password) password = getpass("Proxy password: "); - if (password) { - snprintf(buf, BUFSIZ, "%s:%s", user, password); - snprintf(buf, BUFSIZ, "Proxy-Authorization: Basic %s\n", base64_encode(buf)); - strcat(msg, buf); +#endif + if (!password) { + fprintf(stderr, "ERROR: Proxy password missing\n"); + exit(1); } + snprintf(buf, BUFSIZ, "%s:%s", user, password); + snprintf(buf, BUFSIZ, "Proxy-Authorization: Basic %s\n", base64_encode(buf)); + strcat(msg, buf); } if (www_user) { char *user = www_user; char *password = www_password; +#if HAVE_GETPASS if (!password) password = getpass("WWW password: "); - if (password) { - snprintf(buf, BUFSIZ, "%s:%s", user, password); - snprintf(buf, BUFSIZ, "Authorization: Basic %s\n", base64_encode(buf)); - strcat(msg, buf); +#endif + if (!password) { + fprintf(stderr, "ERROR: WWW password missing\n"); + exit(1); } + snprintf(buf, BUFSIZ, "%s:%s", user, password); + snprintf(buf, BUFSIZ, "Authorization: Basic %s\n", base64_encode(buf)); + strcat(msg, buf); } if (keep_alive) { if (port != 80) -- 2.47.3