From cravey@www.gotbrains.org  Sun Aug  4 11:33:41 2002
Return-Path: <cravey@www.gotbrains.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0861A37B400
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  4 Aug 2002 11:33:41 -0700 (PDT)
Received: from www.gotbrains.org (www2.gotbrains.org [206.180.149.129])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2AFB743E42
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  4 Aug 2002 11:33:40 -0700 (PDT)
	(envelope-from cravey@www.gotbrains.org)
Received: from www.gotbrains.org (localhost [127.0.0.1])
	by www.gotbrains.org (8.12.3/8.12.3) with ESMTP id g74IXdo9036085
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 4 Aug 2002 13:33:39 -0500 (CDT)
	(envelope-from cravey@www.gotbrains.org)
Received: (from cravey@localhost)
	by www.gotbrains.org (8.12.3/8.12.3/Submit) id g74IXdXm036084;
	Sun, 4 Aug 2002 13:33:39 -0500 (CDT)
Message-Id: <200208041833.g74IXdXm036084@www.gotbrains.org>
Date: Sun, 4 Aug 2002 13:33:39 -0500 (CDT)
From: Stephen Cravey <cravey@gotbrains.org>
Reply-To: Stephen Cravey <cravey@gotbrains.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: ssh logins in 4.6.1 no longer give incoming mail status
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         41328
>Category:       misc
>Synopsis:       ssh logins in 4.6.1 no longer give incoming mail status
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 04 11:40:01 PDT 2002
>Closed-Date:    Mon Jul 14 03:47:24 PDT 2003
>Last-Modified:  Mon Jul 14 03:47:24 PDT 2003
>Originator:     Stephen Cravey
>Release:        FreeBSD 4.6.1-RELEASE-p7 i386
>Organization:
>Environment:
System: FreeBSD ******** 4.6.1-RELEASE-p7 FreeBSD 4.6.1-RELEASE-p7 #0: Fri Aug 2 18:21:23 CDT 2002 cravey@*************:/usr/obj/usr/src/sys/******* i386


>Description:
	On a ssh login to a 4.6.1 machine (presumeable due to the new openssh), you no longer are given a: 'You have New mail.' message after the motd as on openssh 2.9 from 4.6-RELEASE. It does not notify you if 'You have mail.' either. This was the default behaviour on login previously

>How-To-Repeat:
	get new mail. ssh to the box you get new mail on.
>Fix:
	Write a shell script to check mail status and drop it into your .login, etc...


>Release-Note:
>Audit-Trail:

From: "Andrey A. Chernov" <ache@nagual.pp.ru>
To: Stephen Cravey <cravey@gotbrains.org>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: misc/41328: ssh logins in 4.6.1 no longer give incoming mail status
Date: Mon, 5 Aug 2002 14:58:42 +0400

 On Sun, Aug 04, 2002 at 13:33:39 -0500, Stephen Cravey wrote:
 > >How-To-Repeat:
 > 	get new mail. ssh to the box you get new mail on.
 
 Try this patch:
 
 --- session.c.old	Sat Jul 27 00:56:22 2002
 +++ session.c	Mon Aug  5 14:46:40 2002
 @@ -1288,6 +1288,9 @@
  	const char *shell, *shell0, *hostname = NULL;
  	struct passwd *pw = s->pw;
  	u_int i;
 +#ifdef HAVE_LOGIN_CAP
 +	int lc_requirehome, lc_nocheckmail;
 +#endif
  
  	/* remove hostkey from the child's memory */
  	destroy_sensitive_data();
 @@ -1346,6 +1349,11 @@
  	/* XXX better use close-on-exec? -markus */
  	channel_close_all();
  
 +#ifdef HAVE_LOGIN_CAP
 +	lc_requirehome = login_getcapbool(lc, "requirehome", 0);
 +	lc_nocheckmail = login_getcapbool(lc, "nocheckmail", 0);
 +	login_close(lc);
 +#endif
  	/*
  	 * Close any extra file descriptors.  Note that there may still be
  	 * descriptors left by system functions.  They will be closed later.
 @@ -1384,7 +1392,7 @@
  		fprintf(stderr, "Could not chdir to home directory %s: %s\n",
  		    pw->pw_dir, strerror(errno));
  #ifdef HAVE_LOGIN_CAP
 -		if (login_getcapbool(lc, "requirehome", 0))
 +		if (lc_requirehome)
  			exit(1);
  #endif
  	}
 @@ -1422,6 +1430,28 @@
  			errno = EINVAL;
  			perror(shell);
  			exit(1);
 +		}
 +
 +		/*
 +		 * Check for mail if we have a tty.
 +		 */
 +		if (s->ttyfd != -1
 +#ifdef HAVE_LOGIN_CAP
 +		    && !lc_nocheckmail
 +#endif
 +		   ) {
 +			char *mailbox;
 +			struct stat mailstat;
 +
 +			mailbox = getenv("MAIL");
 +			if (mailbox != NULL) {
 +				if (stat(mailbox, &mailstat) != 0 || mailstat.st_size == 0)
 +					;
 +				else if (mailstat.st_mtime < mailstat.st_atime)
 +					printf("You have mail.\n");
 +				else
 +					printf("You have new mail.\n");
 +			}
  		}
  
  		/* Execute the shell. */
 
 -- 
 Andrey A. Chernov
 http://ache.pp.ru/

From: Stephen Cravey <cravey@gotbrains.org>
To: "Andrey A. Chernov" <ache@nagual.pp.ru>
Cc: <FreeBSD-gnats-submit@FreeBSD.ORG>
Subject: Re: misc/41328: ssh logins in 4.6.1 no longer give incoming mail
 status
Date: Mon, 5 Aug 2002 15:35:02 -0500 (CDT)

 On Mon, 5 Aug 2002, Andrey A. Chernov wrote:
 
 ---snip---
 
 > Try this patch:
 
 ---snip---
 
 The line numbers didn't match up to what I had.. I applied it manually,
 but I'm not sure how to get openssh compiled and installed with it other
 than a make world.  Can you give me some suggestions? I'm getting better
 at this. Really, I am. :)
 
 My diff follows. Let me know if I missed something.
 
 -Stephen
 
 *** session.c.oldd	Mon Aug  5 12:35:37 2002
 --- session.c	Mon Aug  5 12:49:53 2002
 ***************
 *** 1269,1274 ****
 --- 1269,1277 ----
   	const char *shell, *shell0, *hostname = NULL;
   	struct passwd *pw = s->pw;
   	u_int i;
 + #ifdef HAVE_LOGIN_CAP
 +         int lc_requirehome, lc_nocheckmail;
 + #endif
 
   	/* remove hostkey from the child's memory */
   	destroy_sensitive_data();
 ***************
 *** 1327,1332 ****
 --- 1330,1340 ----
   	/* XXX better use close-on-exec? -markus */
   	channel_close_all();
 
 + #ifdef HAVE_LOGIN_CAP
 +         lc_requirehome = login_getcapbool(lc, "requirehome", 0);
 +         lc_nocheckmail = login_getcapbool(lc, "nocheckmail", 0);
 +         login_close(lc);
 + #endif
   	/*
   	 * Close any extra file descriptors.  Note that there may still be
   	 * descriptors left by system functions.  They will be closed later.
 ***************
 *** 1365,1371 ****
   		fprintf(stderr, "Could not chdir to home directory %s: %s\n",
   		    pw->pw_dir, strerror(errno));
   #ifdef HAVE_LOGIN_CAP
 ! 		if (login_getcapbool(lc, "requirehome", 0))
   			exit(1);
   #endif
   	}
 --- 1373,1379 ----
   		fprintf(stderr, "Could not chdir to home directory %s: %s\n",
   		    pw->pw_dir, strerror(errno));
   #ifdef HAVE_LOGIN_CAP
 ! 		if (lc_requirehome)
   			exit(1);
   #endif
   	}
 ***************
 *** 1403,1408 ****
 --- 1411,1439 ----
   			errno = EINVAL;
   			perror(shell);
   			exit(1);
 + 		}
 +
 + 		/*
 + 		 * Check for mail if we have a tty.
 + 		 */
 + 		if (s->ttyfd != -1
 + #ifdef HAVE_LOGIN_CAP
 + 		    && !lc_nocheckmail
 + #endif
 + 		    ) {
 + 		  char *mailbox;
 + 		  struct stat mailstat;
 +
 + 		  mailbox = getenv("MAIL");
 + 		  if (mailbox != NULL) {
 + 		    if (stat(mailbox, &mailstat) != 0 || mailstat.st_size == 0)
 + 		      ;
 + 		    else if (mailstat.st_mtime < mailstat.st_atime)
 + 		      printf("You have mail.\n");
 + 		    else
 + 		      printf("You have new mail.\n");
 + 		  }
 +
   		}
 
   		/* Execute the shell. */
 
 

From: Stephen Cravey <cravey@gotbrains.org>
To: "Andrey A. Chernov" <ache@nagual.pp.ru>
Cc: <FreeBSD-gnats-submit@FreeBSD.ORG>
Subject: Re: misc/41328: ssh logins in 4.6.1 no longer give incoming mail
 status
Date: Mon, 5 Aug 2002 23:42:33 -0500 (CDT)

 As a (temporary?) workaround, I've turned your patch into a standalone
 program that can be run on login. (I'm lazy.) This can be run from the
 .login (t/csh users) or some other way for other shells. Yes there's a
 compiler warning. If someone would like to fix it, I suppose they should
 feel free. Otherwise it works fine.
 
 I don't want to get deeplyinto the politics of this, but at a minimum,
 this change (and/or official position why it won't be fixed) should
 probably be reflected in the next release notes for freebsd in the openssh
 section. I realize we haven't really had release notes for 4.6.x yet.
 
 Compilation and installation is left as an exercise for the reader.
 
 -Stephen
 
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
 
 int main(void)
 {
   char *mailbox;
   struct stat mailstat;
   mailbox = getenv("MAIL");
   if (mailbox != NULL) {
     if (stat(mailbox, &mailstat) != 0 || mailstat.st_size == 0);
     else if (mailstat.st_mtime < mailstat.st_atime)
       printf("You have mail.\n");
     else
       printf("You have new mail.\n");
   }
 }
 
 
 

From: George Glynn <gglynn@biffduncan.com>
To: freebsd-gnats-submit@FreeBSD.org, cravey@gotbrains.org
Cc:  
Subject: Re: misc/41328: ssh logins in 4.6.1 no longer give incoming mail
 status
Date: Tue, 03 Sep 2002 09:01:23 -0400

 Here it is, fixed:
 
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
 extern char *getenv();
 
 int main(void)
 {
   char *mailbox;
   struct stat mailstat;
   mailbox = getenv("MAIL");
   if (mailbox != NULL) {
     if (stat(mailbox, &mailstat) != 0 || mailstat.st_size == 0);
     else if (mailstat.st_mtime < mailstat.st_atime)
       printf("You have mail.\n");
     else
       printf("You have new mail.\n");
   }
   return(0);
 }
 
 Cheers,
 George
 
 

From: Stephen Cravey <cravey@gotbrains.org>
To: George Glynn <gglynn@biffduncan.com>
Cc: <freebsd-gnats-submit@FreeBSD.org>
Subject: Re: misc/41328: ssh logins in 4.6.1 no longer give incoming mail
 status
Date: Tue, 3 Sep 2002 21:58:07 -0500 (CDT)

 OK, so if a patch isn't going to get applied, and we've got a functional
 workaround, let's close the PR. OK with everyone?
 
 -Stephen
 
 
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: kris 
Responsible-Changed-When: Sat Jul 12 17:58:22 PDT 2003 
Responsible-Changed-Why:  
Assign to SSH maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41328 
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Mon Jul 14 03:47:23 PDT 2003 
State-Changed-Why:  
Not a bug. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41328 
>Unformatted:
