summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2009-08-31 22:25:44 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2009-08-31 22:25:44 +0000
commit10e5a92aaab1d27d06becb6b1bd7597228647e19 (patch)
tree1df48d4ae99f0ce5546391fa0da1289cf4dc78b6 /usr.bin
parent02bb00339200f8330ae96d95a76ddb372aa5a756 (diff)
also, like ssh, set up MAIL to the location we've just checked
so that ksh could take advantage of it. ok millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/login/login.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c
index 93f285c49b9..cfb18042398 100644
--- a/usr.bin/login/login.c
+++ b/usr.bin/login/login.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: login.c,v 1.58 2009/08/03 21:43:07 martynas Exp $ */
+/* $OpenBSD: login.c,v 1.59 2009/08/31 22:25:43 martynas Exp $ */
/* $NetBSD: login.c,v 1.13 1996/05/15 23:50:16 jtc Exp $ */
/*-
@@ -73,7 +73,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)login.c 8.4 (Berkeley) 4/2/94";
#endif
-static const char rcsid[] = "$OpenBSD: login.c,v 1.58 2009/08/03 21:43:07 martynas Exp $";
+static const char rcsid[] = "$OpenBSD: login.c,v 1.59 2009/08/31 22:25:43 martynas Exp $";
#endif /* not lint */
/*
@@ -153,6 +153,7 @@ main(int argc, char *argv[])
char *lipaddr, *script, *ripaddr, *style, *type, *fqdn;
char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
char localhost[MAXHOSTNAMELEN], *copyright;
+ char mail[sizeof(_PATH_MAILDIR) + 1 + NAME_MAX];
int ask, ch, cnt, fflag, pflag, quietlog, rootlogin, lastchance;
int error, homeless, needto, authok, tries, backoff;
struct addrinfo *ai, hints;
@@ -606,9 +607,12 @@ failed:
}
if (term[0] == '\0')
(void)strlcpy(term, stypeof(tty), sizeof(term));
+ (void)snprintf(mail, sizeof(mail), "%s/%s", _PATH_MAILDIR,
+ pwd->pw_name);
if (setenv("TERM", term, 0) == -1 ||
setenv("LOGNAME", pwd->pw_name, 1) == -1 ||
- setenv("USER", pwd->pw_name, 1) == -1) {
+ setenv("USER", pwd->pw_name, 1) == -1 ||
+ setenv("MAIL", mail, 1) == -1) {
warn("unable to setenv()");
quickexit(1);
}
@@ -704,9 +708,7 @@ failed:
login_getcapstr(lc, "copyright", NULL, NULL)) != NULL)
auth_cat(copyright);
motd();
- (void)snprintf(tbuf,
- sizeof(tbuf), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
- if (stat(tbuf, &st) == 0 && st.st_size != 0)
+ if (stat(mail, &st) == 0 && st.st_size != 0)
(void)printf("You have %smail.\n",
(st.st_mtime > st.st_atime) ? "new " : "");
}