summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 8ba194d..1cf7f9d 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 26612d4..e7be40e 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;
OpenPOWER on IntegriCloud