From owner-freebsd-current Mon Aug 5 3:57:48 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3BBC837B400; Mon, 5 Aug 2002 03:57:45 -0700 (PDT) Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3E59C43E42; Mon, 5 Aug 2002 03:57:44 -0700 (PDT) (envelope-from ache@pobrecita.freebsd.ru) Received: from pobrecita.freebsd.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.12.5/8.12.5) with ESMTP id g75AvPUI002457; Mon, 5 Aug 2002 14:57:33 +0400 (MSD) (envelope-from ache@pobrecita.freebsd.ru) Received: (from ache@localhost) by pobrecita.freebsd.ru (8.12.5/8.12.5/Submit) id g75AvMO6002456; Mon, 5 Aug 2002 14:57:22 +0400 (MSD) (envelope-from ache) Date: Mon, 5 Aug 2002 14:57:20 +0400 From: "Andrey A. Chernov" To: current@freebsd.org, des@freebsd.org Subject: CFR: openssh, login_cap bugfix, mail check adding patch Message-ID: <20020805105719.GA2404@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.1i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Please review. 1) Do all login cap calls _before_ all descriptors closed hardly, because this may invalidate login cap calls especially when login.conf is database. 2) Add traditional login-like mail check (see PR 41328) (all this was in old openssh we have for ages but lost in the merge of new version) --- 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/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message