Solved

mail check at login

Posted on 1998-02-19
27
645 Views
Last Modified: 2013-12-15
Heya all.

I have 2 main linux pc's.  One is a mail server among other
things, and the other is the pc users login to.

When they login they always get the message
"you have no new mail" as it is checking for email on the
wrong PC.

I want the pc users login to, to do it's mail check on
the mail server.  How is this setup? if at all?

Thanks!
Andrew

q@qonline.com.au
0
Comment
Question by:Q010797
  • 13
  • 8
  • 3
  • +3
27 Comments
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
Environment variable MAIL must point to users mail spool file, for example: /var/spool/mail/user1
This variable is usually set in the (login-) shell's startup file
(/etc/csh.{login.cshrc}, /etc/profile, etc.)
0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
But the mail spool files are on a different PC.
I don't want to mount /var/spool/mail from the other PC also.
So i want a way to do this.
0
 

Expert Comment

by:spjuver
Comment Utility
The question is what you really want...

You can add an .hushlogin file in the users home directory to switch the local mail facility.

Then run a program like fetchpop in a script to just check for mail on the mail server. This script can echo the 'You have new mail' or similiar.

Alternative 2 is to simply use the pop3 client to fetch all mails to the local machine at login. Then the login message will be correct...
0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
Ahhh ok..

First option sounds best..

All i need to know now, is HOW to do this.  Where do I get the software and how do I set it up.

Lastly, how do I REMOVE the current mail check that says 'You have no new mail'.
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
> Lastly, how do I REMOVE the current mail check that says 'You have no new mail'.

You have to use an other login :-(
0
 

Expert Comment

by:spjuver
Comment Utility
Wrong ahoffman, add a .hushlogin file in the home directory and you will get rid of that message.

ftpsearch.ntnu.no is a perfect server to find files if you only know the name of the file or a part of the name.

What you need is a pop client. Fetchmail gives a return code depending of if you have mail or not on the mail server.

Fetchpop is more powerful but have no proper return codes and needs a script with 'greps' out the neccesary information from what the fetchpop program returns.

I propose that you should use the fetchpop program and simply echo the return messasge at login.

It will show a line like:
> fetchpop -c
fetchpop 1.9pl1 release, by Seung-Hong Oh.
using mailbox folder /var/spool/mail/<user>
Checking mail, not fetching.
You have 0 new messages and total of 0 messages.


You can also just show the last line by make a script which re-formatt the message.

0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
Right sp.juver. I forgot that we are in a Linux (not UNIX) topic ;-)
0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
instead of putting a .hushlogin in EVERYONES home dir.. can I make it default for ALL users?
0
 

Expert Comment

by:spjuver
Comment Utility
I'm afraid that all users must have a .hushlogin.

That's no problem you don't need to make it.

put a 'touch $HOME/.hushlogin' in the system files for the shell's and it will be created if it don't exist when someone logs in...
0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
what if the users logging in are running pppd straight away, via AUTOPPP... how then do I make them run
touch $HOME/.hushlogin
on login?

0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
Also.. I have just tried out fetch pop..

All is well except I have to setup each users username and password for the accounts.  This could take weeks.

Any other options ?  btw.. the password and shadow files are the SAME on the pop3 machine, and the dialin machine
0
 

Expert Comment

by:spjuver
Comment Utility
Comment one:

It is the login process which is looking for the .hushlogin file.
The login process will place the user in his home directory and in that directory will be checked for .hushlogin.
If this directory is on the server, the server is running the login process. This means that your nice script should be on the server.

If the login procedure is done on the client then you ofcourse have to put the script on the client.

Comment 2:
I didn't say that you had to use fetchpop but if you really want to check mail at login and the mail are on another server you have to login on that server. Login is a security thing and must be set up per user - sorry.

If you want to fetch things as a single user without password use dos....
0
 

Expert Comment

by:spjuver
Comment Utility
Comment one:

It is the login process which is looking for the .hushlogin file.
The login process will place the user in his home directory and in that directory will be checked for .hushlogin.
If this directory is on the server, the server is running the login process. This means that your nice script should be on the server.

If the login procedure is done on the client then you ofcourse have to put the script on the client.

Comment 2:
I didn't say that you had to use fetchpop but if you really want to check mail at login and the mail are on another server you have to login on that server. Login is a security thing and must be set up per user - sorry.

If you want to fetch things as a single user without password use dos on the server....
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Author Comment

by:Q010797
Comment Utility
Surely if the password and shadow files on the 2 machines is the same, there is some software that will allow me to do the mail check at login.
0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
Surely if the password and shadow files on the 2 machines is the same, there is some software that will allow me to do the mail check at login.
0
 

Expert Comment

by:spjuver
Comment Utility
How is the mails stored on the other machine??
Is they stored in /var/spool/mail/<username> ??

Normal users on that machine with other words. Then simply use finger in a login script (still need to formatt the output if you only want new-mail-part)....

You should rewrite your question so one can answer properly...
0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
Yea that's getting there...  but how do I make it do that for
ALL users regardless of their login?

For that option to work they'd need to be running a script at login and some users (most) login using AUTOPPP and don't execute a script.
0
 

Expert Comment

by:spjuver
Comment Utility
After login all users must have a shell. This shell have always two startup-scripts. One in the home directory and one for the system. You can add 'finger $LOGNAME@your.nice.server' in the system file on the machine the shell is running...


0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
no.. some users use mgetty's AUTOPPP setup..  so for them there
is no way to run a login script.  For these users, how do I get the mail check running and/or other items at login?
0
 

Expert Comment

by:spjuver
Comment Utility
Don't matter which 'getty' you are using. The procedure after getty is login and then a shell.

I use mingetty for my console and agetty for my null-modem-link.
0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
no you don't get it...  mgetty uses AUTOPPP (pap and chap style) so I can't run login scripts with it the same way I do with people who use terminal windows and scripts etc....
0
 
LVL 1

Expert Comment

by:c4lv1n
Comment Utility
There are many several ways to get your mail local or pseudo-local. If you use NFS to mount your user directories from the server into your workstation (this is the way I prefer) and setup up NIS for central administrating users all mail stay on the server and seems to be local.
But the most easiest way is to use fetchmail. This is a program or deamon (optionally) whitch gets your mail from all mail-accounts. Using fetchmail on the server means that the specified users can get ALL their mail from one server. Try and be glad to use Linux...
0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
I read that answer and still have no idea what to do.  Sorry, just don't understand it.  Can you explain to me how I'd go about installing your suggestion ?
0
 

Expert Comment

by:remsteve
Comment Utility
OK - I read all this carefully and here is my view...

(i) You cannot do what you are asking for 90% of your users.
(ii) You are not testing your setup properly.

(i) As you correctly say, mgetty/AutoPPP DOES NOT INVOKE  login or a shell - pppd is started directly.  Therefore all login commands/options are igonored (except maybe ppp stuff).  In a sense these users do not "login" - they merely establish a network connection.  You cannot run scripts for them at 'connect-time'.

(ii) Remember to test you changes using an AutoPPP account - it sounds to me like you are testing with a terminal!
0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
Nah.. that sounds like an observation to me anyway.. not an answer..

Can spjuver please offer an answer again . . I'll give him the points . .he's been more helpful than others... and I've not got the problem sorted out anyway.. but know more about my problem than before
0
 
LVL 2

Accepted Solution

by:
alexbik earned 100 total points
Comment Utility
Hi,

In my opinion, there are three solutions, but only one 'neat' one.

1) Disable the whole mail notification all together. There is probably a 'biff y' statement in your /etc/profile, change it to 'biff n'.

2) Install a perlscript that checks for mail on the remote server. The easiest way to do this is to make use of the finger daemon on the mailserver, in that way you don't have to know the user's password to see if he/she has mail waiting.

3) (The neat one):
As you mention that one server does the e-mail and the other is used for logins, I assume that you have some authentication protocol like NIS(+) running?
If the users on both machines are the same, you can export /var/spool/mail on the mailserver, and NFS mount it under /var/spool/mail on the other. In that way, it really doesn't mather on which machine a user is on, mail is available on all systems. Since your filesystem doesn't know usernames (only UID's), this option is only usable if all users have the same UID on both machines. This is not a bad idea anyway, and done automatically if you run NIS.

If you should choose option 2), here's an example of a shell script that does the job:

#!/bin/bash
remote_machine="mailhost.domain.com"
nomail=`finger $LOGNAME@$remote_machine | grep "No mail."`
if [ -z "$nomail" ] ; then
        echo "You have mail on server $remote_machine."
else
        echo "You have no mail."
fi

Please not that I wrot this script in a few minutes, and it does not check if the user has an account on the mailhost or not. If this situation could occour in your case, you need to add a check on this. If I understand your situation right, it should work fine for you.

Alex.
0
 
LVL 1

Author Comment

by:Q010797
Comment Utility
biff doesn't work like that . . biff is for mail notification whilst logged in . . the mail check AT login has nothing to do with biff . .

But the answer is good enough anyway :)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now