MAIL environment variable set wrong

Andrew Farris flyindragon1 at aol.com
Thu Jul 30 22:03:00 UTC 2009


On Thu, 2009-07-30 at 09:39 +0100, David Banks wrote:
> Hi,
> 
> [This was previously posted on the forums, I didn't get a response 
> there; apologies if you've seen it before.]
> 
> I am using Ubuntu Hardy x86_64. The problem I have is that whenever I 
> log in, the MAIL environment variable is set to '/var/mail/david' (where 
> my username is 'david'). This isn't right, since I don't keep my mail in 
> Mbox under /var/mail. In fact, on this machine I don't get mail for my 
> local username, and I'd like MAIL to be unset when I log in.
> 
>    david at scatha $ echo $MAIL
>    /var/mail/david
> 
> I've tried to find out where this gets set, and I've found that it's set 
> by PAM.  The PAM module responsible for setting the variable seems to be 
> 'pam_mail'. There are a few lines in various files under /etc/pam.d that 
> seem to enable this module:
> 
>    david at scatha $ grep -r pam_mail /etc/pam.d
>    /etc/pam.d/login:session    optional   pam_mail.so standard
>    /etc/pam.d/sshd:session    optional     pam_mail.so standard noenv # [1]
>    /etc/pam.d/su:session    optional   pam_mail.so nopen
> 
> However, commenting out all these lines doesn't seem to solve the 
> problem. (Since I log in by ssh, I restarted sshd to apply the changes.) 
> "man pam_mail" says that appending "noenv" to the module lines should 
> work - I tried adding it to all of these files, but it didn't work. MAIL 
> is still set in all circumstances - this includes non-SSH physical logins.
> 
> There's also some related things in /etc/login.defs, with the following 
> note:
> 
>    # NOTE: This is no more used for setting up users MAIL environment 
> variable
>    #       which is, starting from shadow 4.0.12-1 in Debian, entirely the
>    #       job of the pam_mail PAM modules
>    #       See default PAM configuration files provided for
>    #       login, su, etc.
> 
> Why do I care? Because zsh automatically checks for mail when MAIL is 
> defined:
> 
>    MAIL: If this parameter is set and mailpath is not set, the shell
>    looks for mail in the specified file.
> 
> There's no way to disable this check except by unsetting MAIL, so (since 
> /var/mail is forbidden to my user), every five minutes I get a message 
> "/var/mail/david: permission denied". There are quite a few workarounds 
> for this: unset MAIL in my zshrc, profile, /etc/profile; change the 
> permissions on /var/mail. But none of these do exactly what I want, 
> which is to avoid setting MAIL in the first place. Ideally the 'noenv' 
> option should do this perfectly, but it doesn't seem to work.
> 
> Any idea where I'm going wrong?
> 
> Cheers
> David
> 

Following your trail, I decided to check and see if my own $MAIL
variable was set to anything...lo and behold, it's empty. The only other
difference I noticed between what I got on my system, and whay you
showed, is that I dont have/use SSH, so the line about
"/etc/pam.d/sshd:session" wasn't there for me. Other than that,
everything else is the same.  I haven't the fondest idea why SSH would
make a difference, but maybe somebody with some SSH experience could
explain?

Sorry that's not more helpful.


-- 
Andrew
_____________________________
Registered Linux User: 473690
Registered Ubuntu User: 22747





More information about the ubuntu-users mailing list