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
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.
Created attachment 3210 [details] Don't set $MAIL is PAM is in use
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.
Created attachment 3239 [details] check use_pam instead of preprocessor w/ Darren's feedback
This has been committed and will be in the OpenSSH 8.0 release.
Closing all resolved bug with release of openssh-8.2
[spam removed]