Bug 2937

Summary: Unable to disable $MAIL setting.
Product: Portable OpenSSH Reporter: sergio <sergio+it>
Component: sshdAssignee: Damien Miller <djm>
Status: CLOSED FIXED    
Severity: major CC: ahmedsayeed1982, djm, dtucker
Priority: P5    
Version: 7.9p1   
Hardware: All   
OS: Linux   
Bug Depends on:    
Bug Blocks: 2915    
Attachments:
Description Flags
Don't set $MAIL is PAM is in use
none
check use_pam instead of preprocessor dtucker: ok+

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]