Prereq: "beta(3)
diff -ruN 7.2.6-b3/version.h 7.2.6-b4/version.h
--- 7.2.6-b3/version.h	Sun Nov 17 17:44:40 1996
+++ 7.2.6-b4/version.h	Thu Mar 19 09:26:55 1998
@@ -1,7 +1,7 @@
 /* @(#)version.h	(c) Copyright 1989, 1990, 1991 (Dan Heller) */
 
 #define MUSHNAME	"Mail User's Shell"
-#define RELEASE_DATE	"beta(3) 11/17/96"
+#define RELEASE_DATE	"beta(4) 03/19/98"
 #define RELEASE		7
 #define REVISION	"2"
 #define PATCHLEVEL	6
diff -ruN 7.2.6-b3/README 7.2.6-b4/README
--- 7.2.6-b3/README	Sun Nov 17 18:48:30 1996
+++ 7.2.6-b4/README	Sun Mar 15 09:23:32 1998
@@ -1,6 +1,6 @@
 /* @(#)README		(c) copyright 2/1/92	(Dan Heller) */
 
-Authors:
+Original Authors:
     Dan Heller
     Bart Schaefer
 
@@ -18,6 +18,7 @@
 that actually -delivers- mail.
 
 Mush is copyright (c) 1986, 1987, 1988, 1989, 1990, 1991 by Dan Heller.
+Copyright (c) 1994, 1995 by Network Computing Devices, Inc.
 All Rights Reserved.   This software is not in the public domain.
 
 Redistribution of the unmodified source code is permitted as long as all
@@ -112,6 +113,9 @@
     Use makefile.linux.  If you don't actually have LINUX, you may need
     to try makefile.bsdi.
 
+    If you are using RedHat 5.0, choose the CFLAGS and LIBS definitions
+    that omit -I/usr/include/ncurses, add -DNCURSES, and omit -ltermcap.
+
 If you have BSDI or a POSIX-like system:
 
     Use makefile.bsdi.
@@ -407,6 +411,11 @@
     as /usr/spool/mail for BSD and SVR4.  However, some systems are unusual,
     so you may need to define this explicitly.
 
+ENV_MAIL
+    Define this if mush should recognize the MAIL environment variable
+    as the location of the spool file.  The compiled-in MAILDIR is still
+    used by default if $MAIL is not set in the environment at startup.
+
 MAIL_DELIVERY
     This is the program that mush invokes to send your messages off to your
     list of recipients.  It defaults to "sendmail" (or "submit" for MMDF).
@@ -612,6 +621,11 @@
     predefined, mush.h looks for <ncurses.h> instead.  If you have the
     standard installation, add -I/usr/include/ncurses to CFLAGS and do
     not define NCURSES.
+
+DEFINE_CURSES_SGTTY
+    Define this if your curses header files do not provide a typedef
+    for the SGTTY type.  This applies to Linux (see makefile.linux) and
+    probably to other POSIX systems and/or those using NCURSES.
 
 ---------------
 The sprintf() function:
diff -ruN 7.2.6-b3/README-7.2.6 7.2.6-b4/README-7.2.6
--- 7.2.6-b3/README-7.2.6	Sun Nov 17 19:02:02 1996
+++ 7.2.6-b4/README-7.2.6	Sun Mar 15 09:17:57 1998
@@ -8,7 +8,7 @@
 Computing Devices, Inc., in February 1994, as a contingency of the NCD
 purchase of Z-Code Software Corporation.  Z-Code's product line, Z-Mail,
 was sold to NetManage in June of 1996, and ownership of Mush is assumed
-to have transferred with it.
+to have transferred with it.  However, I am unable to confirm this.
 
 Availablity of Mush 7.2.5 continues to be governed by the license that
 appears in the file README in the Mush distribution.  Under the terms of
@@ -53,6 +53,18 @@
 	standard installation, add -I/usr/include/ncurses to CFLAGS and do
 	not define NCURSES.
 
+    DEFINE_CURSES_SGTTY
+	Mush has long assumed that curses.h provides a typedef for SGTTY.
+	This is no longer true of many curses headers, including ncurses.
+	Define DEFINE_CURSES_SGTTY if you get undefined symbol errors for
+	the symbol SGTTY when compiling CURSES mode.
+
+    ENV_MAIL
+	This isn't really new, but hasn't been documented before.  If you
+	want mush to recognize the $MAIL environment variable as the path
+	to the mail spool file, define ENV_MAIL.  Previously, this could
+	not be used in combination with HOMEMAIL, but it now can.
+
     ROOTMAIL
 	When running mush from under "su root", the name of the current
 	user is set to the real user logged in on the terminal.  This
@@ -120,8 +132,7 @@
     it should.
 
   * Curses mode should work with ncurses now, and uses POSIX cfgetospeed()
-    when available.  (Availability of ncurses is assumed on the basis of
-    the operating system type, unfortunately.)
+    when available.
 
   * It should be possible to build mush with CURSES on linux, which as far
     as I can tell never worked even though the contributed makefile.linux
diff -ruN 7.2.6-b3/cmd_help 7.2.6-b4/cmd_help
--- 7.2.6-b3/cmd_help	Thu May 16 18:28:46 1991
+++ 7.2.6-b4/cmd_help	Thu Mar 19 09:40:36 1998
@@ -442,6 +442,7 @@
   -R         by subject including Re:
   -s         by subject ignoring Re: (alphabetical)
   -S         by status
+  -t         by To: address
 
 Any combination of the options can be given.  Each comparison
 proceeds from left to right through the list of criteria,
diff -ruN 7.2.6-b3/config.h-dist 7.2.6-b4/config.h-dist
--- 7.2.6-b3/config.h-dist	Sun Nov 17 17:20:52 1996
+++ 7.2.6-b4/config.h-dist	Mon Mar  9 10:01:41 1998
@@ -27,7 +27,7 @@
 #define LPR		"lp"
 #define PRINTER_OPT	"-d"
 #endif /* SYSV */
-#ifdef BSD
+#if defined(BSD) || defined(linux)
 #define LPR		"lpr"
 #define PRINTER_OPT	"-P"
 #endif /* BSD */
@@ -161,7 +161,11 @@
 #ifdef BSD44
 #define MAILDIR		"/var/mail"
 #else
+#ifdef linux
+#define MAILDIR		"/var/spool/mail"
+#else
 #define MAILDIR		"/usr/spool/mail"
+#endif /* linux */
 #endif /* BSD44 */
 #endif /* SYSV && !SVR4 */
 #endif /* MAILDIR */
@@ -214,9 +218,9 @@
 /* If your system has the BSD-style directory routines (opendir/readdir),
  * define DIRECTORY.  This happens automatically in glob.h for BSD.
  */
-#ifdef SVR4
+#if defined(SVR4) || defined(POSIX)
 #define DIRECTORY
-#endif /* SVR4 */
+#endif /* SVR4 || POSIX */
 
 /* If your system does not have bzero, remove this */
 #define HAS_BZERO
diff -ruN 7.2.6-b3/folders.c 7.2.6-b4/folders.c
--- 7.2.6-b3/folders.c	Sun Nov 17 15:43:58 1996
+++ 7.2.6-b4/folders.c	Thu Mar 19 09:47:21 1998
@@ -138,12 +138,8 @@
 	xfree(msg[msg_cnt].m_subject);
 	xfree(msg[msg_cnt].m_to);
 	xfree(msg[msg_cnt].m_from);
-	xfree(msg[msg_cnt].m_name);
-	xfree(msg[msg_cnt].m_addr);
 	msg[msg_cnt].m_subject = NULL;
 	msg[msg_cnt].m_to = msg[msg_cnt].m_from = NULL;
-	msg[msg_cnt].m_name = msg[msg_cnt].m_addr = NULL;
-	msg[msg_cnt].m_author = 0;
     }
     msg_cnt = 0, msg[0].m_offset = 0L;
     turnoff(glob_flags, CONT_PRNT);
@@ -689,7 +685,8 @@
 	if (fputs(from, fp) == EOF)
 #endif /* MSG_SEPARATOR */
 	    art_cnt = -1;
-	if (!(p = header_field(n, "from")))
+	if (!(p = header_field(n, "from"))
+		&& !(p = read_header_field(n, "newsgroups")))
 	    p = "Mush-Undigest (Real author unknown)";
 	if (fprintf(fp, "From: %s\n", p) == EOF)
 	    art_cnt = -1;
diff -ruN 7.2.6-b3/hdrs.c 7.2.6-b4/hdrs.c
--- 7.2.6-b3/hdrs.c	Sun Nov 17 15:43:58 1996
+++ 7.2.6-b4/hdrs.c	Thu Mar 19 09:31:25 1998
@@ -3,7 +3,8 @@
 /*
  * Routines that deal with message headers inside messages
  * msg_get(n, from, count) -- get the From_ line in msg n into "from".
- * header_field(n, str) -- get the header named "str" from msg n.
+ * read_header_field(n, str) -- get the header named "str" from msg n.
+ * header_field(n, str) -- read_header_field() with some fields cached.
  * do_hdrs(argc, argv, list) -- diplay message headers.
  * specl_hdrs(argv, list) -- display msgs that share common attributes.
  * compose_hdr(cnt) -- compose a message header from msg n.
@@ -54,7 +55,7 @@
 static char    buf_header_field[HDRSIZ];
 
 char *
-real_header_field(n, str)
+read_header_field(n, str)
 char *str;
 {
     char 	   tmp[HDRSIZ];
@@ -101,21 +102,21 @@
 
     if (!lcase_strncmp(str, "from", -1)) {
 	if (!(p = q = msg[n].m_from))
-	    p = real_header_field(n, str);
+	    p = read_header_field(n, str);
       	if (p == NULL) return NULL;
 	if (q == NULL) msg[n].m_from = savestr(p);
     } else if (!lcase_strncmp(str, "subject", -1)) {
 	if (!(p = q = msg[n].m_subject))
-	    p = real_header_field(n, str);
+	    p = read_header_field(n, str);
 	if (p == NULL) return NULL;
 	if (q == NULL) msg[n].m_subject = savestr(p);
     } else if (!lcase_strncmp(str, "to", -1)) {
 	if (!(p = q = msg[n].m_to))
-	    p = real_header_field(n, str);
+	    p = read_header_field(n, str);
 	if (p == NULL) return NULL;
 	if (q == NULL) msg[n].m_to = savestr(p);
     } else
-	p = real_header_field(n,str);
+	p = read_header_field(n,str);
 
     return !p || p == buf_header_field ? p : strcpy(buf_header_field,p);
 }
@@ -549,7 +550,7 @@
 		when 's': p2 = subject;
 		when 'l': p2 = sprintf(lines, "%d", msg[cnt].m_lines);
 		when 'c': p2 = sprintf(lines, "%ld", msg[cnt].m_size);
-		when 'i': (p2 = header_field(cnt, "message-id")) || (p2 = "");
+		when 'i': (p2 = read_header_field(cnt, "message-id")) || (p2 = "");
 		/* date formatting chars */
 		when 'd': p2 = date; /* the full date */
 		when 'T': p2 = Tm;
@@ -674,9 +675,9 @@
 	if (!p)
 	    print("Warning: message contains no `reply_to_hdr' headers.\n");
     }
-    if (p || (!p && ((p = header_field(n, field = "reply-to")) ||
-		    (p = header_field(n, field = "from")) ||
-		    (p = header_field(n, field = "return-path"))))) {
+    if (p || (!p && ((p = read_header_field(n, field = "reply-to")) ||
+		    (p = read_header_field(n, field = "from")) ||
+		    (p = read_header_field(n, field = "return-path"))))) {
 	skipspaces(0);
     } else if (!p) {
 DoFrom:
@@ -725,13 +726,13 @@
 	 */
 BrokenFrom:
 	if (!lcase_strncmp(field, "from_", -1) &&
-		(p = header_field(n, "resent-from")) ||
-		    (p = header_field(n, "from")) ||
-		    (p = header_field(n, "sender"))) {
+		(p = read_header_field(n, "resent-from")) ||
+		    (p = read_header_field(n, "from")) ||
+		    (p = read_header_field(n, "sender"))) {
 	    /* p2 is either NULL or addr (BrokenFrom) */
 	    (void) get_name_n_addr(p, name, p2);
 	}
-	if (!name[0] && (p = header_field(n, "name")))
+	if (!name[0] && (p = read_header_field(n, "name")))
 	    (void) strcpy(name, p);
 	if (name[0]) {
 	    if ((p = any(name, "(<,\"")) && (*p == ',' || *p == '<'))
@@ -757,7 +758,7 @@
 	 * The assumption that HDRSIZ is correct is unwise, but I know it
 	 * to be true for Mush.  Be forewarned if you call this routine.
 	 */
-	if (lim > 0 && (p = header_field(n, "resent-to")) && *p) {
+	if (lim > 0 && (p = read_header_field(n, "resent-to")) && *p) {
 	    *b++ = ',', *b++ = ' ';
 	    p[lim] = '\0'; /* prevent overflow */
 	    b += Strcpy(b, p);
@@ -769,14 +770,14 @@
 	    b += Strcpy(b, p);
 	    lim = HDRSIZ - (b - buf) - 2;
 	}
-	if (lim > 0 && (p = header_field(n, "apparently-to")) && *p) {
+	if (lim > 0 && (p = read_header_field(n, "apparently-to")) && *p) {
 	    *b++ = ',', *b++ = ' ';
 	    p[lim] = '\0'; /* prevent overflow */
 	    b += Strcpy(b, p);
 	    lim = HDRSIZ - (b - buf) - 2;
 	}
 	/* Also append the Resent-From address if there is one. */
-	if (lim > 0 && (p = header_field(n, "resent-from")) && *p) {
+	if (lim > 0 && (p = read_header_field(n, "resent-from")) && *p) {
 	    *b++ = ',', *b++ = ' ';
 	    p[lim] = '\0'; /* prevent overflow */
 	    (void) strcpy(b, p);
@@ -824,7 +825,7 @@
 {
     register char *p;
     buf[0] = 0; /* make sure it's already null terminated */
-    if (!(p = header_field(n, "cc")))
+    if (!(p = read_header_field(n, "cc")))
 	return NULL;
     fix_up_addr(p);
     if (!do_set(set_options, "metoo"))
diff -ruN 7.2.6-b3/init.c 7.2.6-b4/init.c
--- 7.2.6-b3/init.c	Sun Nov 17 15:43:58 1996
+++ 7.2.6-b4/init.c	Sun Dec 15 11:39:41 1996
@@ -98,15 +98,15 @@
 	(void) add_option(&set_options, argv);
     }
 
-#ifdef HOMEMAIL
-    strdup(spoolfile, sprintf(buf, "%s/%s", home, MAILFILE));
-#else /* HOMEMAIL */
 #ifdef ENV_MAIL
     if ((p = getenv("MAIL")) && *p)
 	strdup(spoolfile, p);
     else
 #endif /* ENV_MAIL */
-	strdup(spoolfile, sprintf(buf, "%s/%s", MAILDIR, login));
+#ifdef HOMEMAIL
+    strdup(spoolfile, sprintf(buf, "%s/%s", home, MAILFILE));
+#else /* HOMEMAIL */
+    strdup(spoolfile, sprintf(buf, "%s/%s", MAILDIR, login));
 #endif /* HOMEMAIL */
     mailfile = "";
 
diff -ruN 7.2.6-b3/mail.c 7.2.6-b4/mail.c
--- 7.2.6-b3/mail.c	Sun Nov 17 15:48:38 1996
+++ 7.2.6-b4/mail.c	Thu Mar 19 09:31:25 1998
@@ -1076,14 +1076,14 @@
 
 	tmpf = ed_fp;
 	msg[msg_cnt].m_offset = 0L;
-	if (p = real_header_field(msg_cnt, "to")) {
+	if (p = read_header_field(msg_cnt, "to")) {
 	    (void) strcpy(To, p);
 	    Cc[0] = Bcc[0] = 0;
-	    if (p = real_header_field(msg_cnt, "cc"))
+	    if (p = read_header_field(msg_cnt, "cc"))
 		(void) strcpy(Cc, p);
-	    if (p = real_header_field(msg_cnt, "bcc"))
+	    if (p = read_header_field(msg_cnt, "bcc"))
 		(void) strcpy(Bcc, p);
-	    if (p = real_header_field(msg_cnt, "fcc"))
+	    if (p = read_header_field(msg_cnt, "fcc"))
 		next_file += find_files(p, names+next_file, size-next_file, 1);
 	} else
 	    *To = 0; /* Error caught below */
diff -ruN 7.2.6-b3/main.c 7.2.6-b4/main.c
--- 7.2.6-b3/main.c	Sun Nov 17 15:43:59 1996
+++ 7.2.6-b4/main.c	Sun Dec 15 15:08:58 1996
@@ -335,7 +335,8 @@
 {
     char cwd[MAXPATHLEN];
 
-    errno=0;
+    errno = 0;
+    cwd[0] = '\0';
     if (GetCwd(cwd, MAXPATHLEN) == NULL) {
 	error("set_cwd: %s", cwd);
 	(void) un_set(&set_options, "cwd");
@@ -347,5 +348,5 @@
 	argv[3] = NULL;
 	(void) add_option(&set_options, argv);
     }
-    return ;
+    return;
 }
diff -ruN 7.2.6-b3/makefile.linux 7.2.6-b4/makefile.linux
--- 7.2.6-b3/makefile.linux	Sun Nov 17 18:58:52 1996
+++ 7.2.6-b4/makefile.linux	Mon Mar  9 10:07:25 1998
@@ -28,12 +28,14 @@
 # installed in /usr/include/ncurses.h, the other has the standard ncurses
 # installation using /usr/include/ncurses/curses.h.  The former of these
 # apparently has the ncurses library installed as -lcurses, whereas the latter
-# has a separate -lncurses.  Set CFLAGS and LIBS here as appropriate.
-CFLAGS= $(DEBUG) -DPOSIX -DSIGRET=void -fwritable-strings -DCURSES -I/usr/include/ncurses
-#CFLAGS= $(DEBUG) -DPOSIX -DSIGRET=void -fwritable-strings -DCURSES -DNCURSES
+# has a separate -lncurses.  RedHat for 5.0 recommends dropping -ltermcap
+# and using only -lcurses.  Set CFLAGS and LIBS here as appropriate.
+CFLAGS= $(DEBUG) -DPOSIX -DSIGRET=void -fwritable-strings -DCURSES -DDEFINE_CURSES_SGTTY -I/usr/include/ncurses
+#CFLAGS= $(DEBUG) -DPOSIX -DSIGRET=void -fwritable-strings -DCURSES -DDEFINE_CURSES_SGTTY -DNCURSES
 LDFLAGS= $(DEBUG)
 LIBS= -lncurses -ltermcap
 #LIBS= -lcurses -ltermcap
+#LIBS= -lcurses
 OTHERLIBS=
 # Use some variant of this one if you #define MMDF in config.h
 #OTHERLIBS=/usr/src/mmdf/lib/libmmdf.a
@@ -52,7 +54,7 @@
 BINDIR= $(PREFIX)/bin
 LIBDIR= $(PREFIX)/lib
 MRCDIR= $(PREFIX)/lib
-MANDIR= $(PREFIX)/man1
+MANDIR= $(PREFIX)/man/man1
 MANEXT= 1
 
 install: mush
diff -ruN 7.2.6-b3/mush.1 7.2.6-b4/mush.1
--- 7.2.6-b3/mush.1	Sun Nov 17 17:20:50 1996
+++ 7.2.6-b4/mush.1	Thu Mar 19 09:52:11 1998
@@ -3249,7 +3249,7 @@
 .B home
 variable descriptions for more information.
 .TP
-.BR sort " [\-i] [[\-r] \-a | \-d | \-l | \-p | \-R | \-s | \-S]"
+.BR sort " [\-i] [[\-r] \-a | \-d | \-l | \-p | \-R | \-s | \-S | \-t]"
 This command sorts messages according to author, date, status or subject
 (with or without considering the \*QRe:\ \*U, in replied messages).
 In addition, the messages can be sorted in reverse order (same arguments).
@@ -3267,6 +3267,7 @@
 \-R	sort by subject including \*QRe:\*U
 \-s	sort by subject (alphabetical)
 \-S	sort by message status
+\-t	sort by To: address
 .in -2
 .fi
 .sp
diff -ruN 7.2.6-b3/mush.h 7.2.6-b4/mush.h
--- 7.2.6-b3/mush.h	Sun Nov 17 18:35:56 1996
+++ 7.2.6-b4/mush.h	Thu Mar 19 09:45:18 1998
@@ -50,6 +50,10 @@
 #undef overwrite
 #endif
 
+#ifdef linux
+#include <termios.h>
+#endif /* linux */
+
 #if !defined(USG) && defined(_USG)
 #    define USG
 #endif /* USG */
@@ -75,10 +79,6 @@
 #include <termio.h>
 #endif /* HPUX */
 
-#ifdef HPUX
-#include <termio.h>
-#endif /* HPUX */
-
 #if defined(SVR4)
 #include <sys/ttold.h>
 #endif /* SVR4 */
@@ -299,7 +299,7 @@
 #define nocbreak() cbrkoff()
 
 #else /* CURSES */
-#ifdef POSIX
+#ifdef DEFINE_CURSES_SGTTY
 typedef struct termios SGTTY;
 #endif
 /* If curses is defined, use the echo/cbreak commands in library only
@@ -559,9 +559,6 @@
     char   *m_to;	/* Cached To: field */
     char   *m_subject;	/* Cached Subject: field */
     char   *m_from;	/* Cached Reply-To: or From: field */
-    char   *m_addr;	/* Cached Reply-To: or From: field */
-    char   *m_name;	/* Cached Reply-To: or From: field */
-    char   m_author;	/* if any of the 3 preceding ones has been inited */
 } msg[MAXMSGS];
 
 struct options {
@@ -594,7 +591,7 @@
 
 #if (__STDC__ > 0) || defined(DECLARE_ERRLIST)
 extern char
-#ifndef BSD44
+#if !defined(BSD44) && !defined(linux)
     *sys_errlist[],     /* system's list of global error messages */
 #endif
     **environ;		/* user's environment variables */
@@ -646,7 +643,7 @@
     *cc_to(),     	/* when responding, return str which is the cc-list */
     *compose_hdr(),	/* passes hdr_format to format_hdr() for displays */
     *format_hdr(),	/* returns a formatted line describing passed msg # */
-    *real_header_field(),/* the line in msg described by arg (message header) */
+    *read_header_field(),/* the line in msg described by arg (message header) */
     *header_field(),    /* the line in msg described by arg (possibly cached) */
     *reply_to(),	/* who do we reply to when responding */
     *subject_to(),      /* when responding, return str which is the subject */
diff -ruN 7.2.6-b3/pmush.c 7.2.6-b4/pmush.c
--- 7.2.6-b3/pmush.c	Sun Nov 17 17:20:51 1996
+++ 7.2.6-b4/pmush.c	Sun Dec 15 15:08:53 1996
@@ -202,7 +202,7 @@
 	    if (fprintf(mfstream, "\nFrom %s %s\n%s",
 			fromline, dateline, msgptr)
 		    < (strlen(fromline) + strlen(dateline) + strlen(msgptr))) {
-		fprintf(stderr, "Error writing mailbox file\n");
+		perror(mailbox);
 		pop_close(postinfo);
 		if (master)
 		    cleanup(-1);
diff -ruN 7.2.6-b3/pop.c 7.2.6-b4/pop.c
--- 7.2.6-b3/pop.c	Sun Nov 17 17:20:51 1996
+++ 7.2.6-b4/pop.c	Sun Dec 15 15:08:57 1996
@@ -188,7 +188,7 @@
 #endif
     if (!host) {
 	host = getenv("MAILHOST");
-	if (!host) {
+	if (!host || !*host) {
 #ifdef DEFAULT_POPHOST
 	    host = DEFAULT_POPHOST;
 #else /* !DEFAULT_POPHOST */
@@ -197,30 +197,6 @@
 #endif /* !DEFAULT_POPHOST */
 	}
     }
-    /* Determine the password */
-#ifdef KERBEROS
-#define DONT_NEED_PASSWORD (! (flags & POP_NO_KERBEROS))
-#else
-#define DONT_NEED_PASSWORD 0
-#endif
-
-    /* Modified to return password if possible -- Bart */
-    if ((!password || !*password) && (!DONT_NEED_PASSWORD)) {
-	if (!(flags & POP_NO_GETPASS)) {
-	    char *p = getpass("Enter POP password:");
-	    if (p && password)
-		(void) strcpy(password, p);
-	    password = p;
-	}
-	if (!password) {
-	    strcpy(pop_error, "Could not determine POP password");
-	    return (0);
-	}
-    }
-    if (password)
-	flags |= POP_NO_KERBEROS;
-    else
-	password = username;
 
     sock = socket_connection(host, flags);
     if (sock == -1)
@@ -255,10 +231,35 @@
     	pop_close(server);
 	return (0);
     }
-    if (strlen(password) > ERROR_MAX - 6) {
+
+    /* Determine the password */
+#ifdef KERBEROS
+#define DONT_NEED_PASSWORD (! (flags & POP_NO_KERBEROS))
+#else
+#define DONT_NEED_PASSWORD 0
+#endif
+
+    /* Modified to return password if possible -- Bart */
+    if ((!password || !*password) && (!DONT_NEED_PASSWORD)) {
+	if (!(flags & POP_NO_GETPASS)) {
+	    char *p = getpass("Enter POP password:");
+	    if (p && password)
+		(void) strcpy(password, p);
+	    password = p;
+	}
+	if (!password) {
+	    strcpy(pop_error, "Could not determine POP password");
+	    return (0);
+	}
+    }
+    if (password)
+	flags |= POP_NO_KERBEROS;
+    else
+	password = username;
+
+    if (strlen(password) > (sizeof buf - 6)) {
 	pop_close(server);
-	strcpy(pop_error,
-		"Password too long; recompile pop.c with larger ERROR_MAX");
+	strcpy(pop_error, "Password too long");
 	return (0);
     }
     sprintf(buf, "PASS %s", password);