Bug 2937 - Unable to disable $MAIL setting.
Summary: Unable to disable $MAIL setting.
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 7.9p1
Hardware: All Linux
: P5 major
Assignee: Damien Miller
URL:
Keywords:
Depends on:
Blocks: V_8_0
  Show dependency treegraph
 
Reported: 2018-11-30 23:11 AEDT by sergio
Modified: 2021-10-14 01:40 AEDT (History)
3 users (show)

See Also:


Attachments
Don't set $MAIL is PAM is in use (481 bytes, patch)
2018-12-07 13:19 AEDT, Damien Miller
no flags Details | Diff
check use_pam instead of preprocessor (612 bytes, patch)
2019-02-08 13:07 AEDT, Damien Miller
dtucker: ok+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sergio 2018-11-30 23:11:26 AEDT
I have commented out all pam_mail.so in all pam.d/*
I have commented out MAIL_DIR in login.defs

But I still have $MAIL set to /var/mail/sergio after ssh host.

Looks like it's from 2003:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=189920
Comment 1 Damien Miller 2018-12-07 13:14:37 AEDT
MAIL is set implicitly by sshd, it being one of the environment traditionally established by login(1). It might make sense to have sshd skip this when PAM is in use, as that part of the session setup is usually delegated to a PAM module.
Comment 2 Damien Miller 2018-12-07 13:19:13 AEDT
Created attachment 3210 [details]
Don't set $MAIL is PAM is in use
Comment 3 Darren Tucker 2018-12-07 15:40:43 AEDT
Comment on attachment 3210 [details]
Don't set $MAIL is PAM is in use

No that skips it when PAM is compiled in.  To skip it when PAM is in use you need to also test options.use_pam:

>+#ifndef USE_PAM
    if (!options.use_pam) {
> 	snprintf(buf, sizeof buf, "%.200s/%.50s", _PATH_MAILDIR, pw->pw_name);
> 	child_set_env(&env, &envsize, "MAIL", buf);
    }
>+#endif

with that change ok dtucker.
Comment 4 Damien Miller 2019-02-08 13:07:04 AEDT
Created attachment 3239 [details]
check use_pam instead of preprocessor

w/ Darren's feedback
Comment 5 Damien Miller 2019-02-08 14:54:44 AEDT
This has been committed and will be in the OpenSSH 8.0 release.
Comment 6 Damien Miller 2020-02-14 15:59:20 AEDT
Closing all resolved bug with release of openssh-8.2
Comment 7 Ahmed Sayeed 2021-10-14 01:40:52 AEDT
[spam removed]