aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2002-04-20 09:26:43 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2002-04-20 09:26:43 +0000
commitb36e10eee65d7c16534e96ccd2bd266061ed8da0 (patch)
tree9869fda56cd10a2b502411a5f15cd08fca560262 /crypto
parent640984ba48c506b8b878cb69f47fd19772038d31 (diff)
downloadsrc-b36e10eee65d7c16534e96ccd2bd266061ed8da0.tar.gz
src-b36e10eee65d7c16534e96ccd2bd266061ed8da0.zip
1) Surprisingly, "CheckMail" handling code completely removed from this
version, so documented "CheckMail" option exists but does nothing. Bring it back to life adding code back. 2) Cosmetique. Reduce number of args in do_setusercontext()
Notes
Notes: svn path=/head/; revision=95119
Diffstat (limited to 'crypto')
-rw-r--r--crypto/openssh/servconf.c1
-rw-r--r--crypto/openssh/session.c25
2 files changed, 24 insertions, 2 deletions
diff --git a/crypto/openssh/servconf.c b/crypto/openssh/servconf.c
index 8ba194d77121..1cf7f9d90e6d 100644
--- a/crypto/openssh/servconf.c
+++ b/crypto/openssh/servconf.c
@@ -110,6 +110,7 @@ initialize_server_options(ServerOptions *options)
options->client_alive_count_max = -1;
options->authorized_keys_file = NULL;
options->authorized_keys_file2 = NULL;
+ options->check_mail = -1;
}
void
diff --git a/crypto/openssh/session.c b/crypto/openssh/session.c
index 26612d431a39..e7be40e80935 100644
--- a/crypto/openssh/session.c
+++ b/crypto/openssh/session.c
@@ -1143,9 +1143,10 @@ do_nologin(struct passwd *pw)
/* Set login name, uid, gid, and groups. */
static char **
-do_setusercontext(struct passwd *pw, Session *s)
+do_setusercontext(Session *s)
{
char **env = NULL;
+ struct passwd *pw = s->pw;
#ifdef HAVE_LOGIN_CAP
char buf[256];
char **tmpenv;
@@ -1222,6 +1223,7 @@ do_child(Session *s, const char *command)
const char *shell, *shell0, *hostname = NULL;
struct passwd *pw = s->pw;
u_int i;
+ int ttyfd = s->ttyfd;
/* remove hostkey from the child's memory */
destroy_sensitive_data();
@@ -1236,7 +1238,7 @@ do_child(Session *s, const char *command)
*/
if (!options.use_login) {
do_nologin(pw);
- env = do_setusercontext(pw, s);
+ env = do_setusercontext(s);
}
/*
@@ -1359,6 +1361,25 @@ do_child(Session *s, const char *command)
exit(1);
}
+ /*
+ * Check for mail if we have a tty and it was enabled
+ * in server options.
+ */
+ if (ttyfd != -1 && options.check_mail) {
+ 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. */
argv[0] = argv0;
argv[1] = NULL;