From nobody  Thu Nov 12 06:45:40 1998
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id GAA13023;
          Thu, 12 Nov 1998 06:45:40 -0800 (PST)
          (envelope-from nobody)
Message-Id: <199811121445.GAA13023@hub.freebsd.org>
Date: Thu, 12 Nov 1998 06:45:40 -0800 (PST)
From: odip@bionet.nsc.ru
To: freebsd-gnats-submit@freebsd.org
Subject: /usr/bin/mail -u user not worked if exists $MAIL
X-Send-Pr-Version: www-1.0

>Number:         8665
>Category:       bin
>Synopsis:       /usr/bin/mail -u user not worked if exists $MAIL
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jmz
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 12 06:50:01 PST 1998
>Closed-Date:    Thu May 20 15:23:24 PDT 1999
>Last-Modified:  Fri May 21 11:37:16 PDT 1999
>Originator:     Grigorovich Dmitry
>Release:        3.0-RELEASE
>Organization:
ICiG
>Environment:
FreeBSD ghost.bionet.nsc.ru 3.0-RELEASE FreeBSD 3.0-RELEASE #0: Thu Nov  5 17:36
:19 NS 1998     root@ghost.bionet.nsc.ru:/usr/src/sys/compile/ODIPN  i386
>Description:
In FreeBSD 3.0-RELEASE ( and lower versions ! )
if environment variable MAIL exists,
then "/usr/bin/mail -u user" always open mailbox ${MAIL}

In FreeBSD 3.0 by default exists $MAIL ( via /etc/login.conf )
"/usr/bin/mail -u user" under root always open MAIL=/var/mail/root,
though "/usr/bin/mail -f /var/mail/user" worked fine

Also in "man mail" we reading:
     -u    Is equivalent to:
                 mail -f /var/mail/user
I look at code of mail program and found that this is not true,
if exists environment variable $MAIL

>How-To-Repeat:
Under root and /bin/sh type:
MAIL=/var/mail/root mail -u user
where user - some user in your system
Always opened /var/mail/root file !

>Fix:
--- /usr/src/usr.bin/mail/main.c.orig	Fri Jan  2 22:43:50 1998
+++ /usr/src/usr.bin/mail/main.c	Sun Nov  1 03:18:09 1998
@@ -64,6 +64,7 @@
 	char *subject, *replyto;
 	char *ef, *cp;
 	char nosrc = 0;
+	char xname[PATHSIZE];
 	void hdrstop();
 	sig_t prevint;
 	void sigchild();
@@ -110,6 +111,8 @@
 			 * Next argument is person to pretend to be.
 			 */
 			myname = optarg;
+			snprintf( xname, sizeof(xname), "%s/%s", _PATH_MAILDIR, myname );
+			ef= xname;
 			break;
 		case 'i':
 			/*

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->billf 
Responsible-Changed-By: billf 
Responsible-Changed-When: Sun Dec 13 17:16:47 PST 1998 
Responsible-Changed-Why:  
I will look into this 
State-Changed-From-To: open->closed 
State-Changed-By: jmz 
State-Changed-When: Thu May 20 15:23:24 PDT 1999 
State-Changed-Why:  
Fixed. 
Responsible-Changed-From-To: billf->jmz 
Responsible-Changed-By: billf 
Responsible-Changed-When: Fri May 21 11:36:27 PDT 1999 
Responsible-Changed-Why:  
jmz ended up fixing this one in: 

rev 1.6 of src/usr.bin/mail/mail.c 
>Unformatted:
