Solved

mail check at login

Posted on 1998-02-19
27
650 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
ID: 1631370
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
ID: 1631371
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
ID: 1631372
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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 1

Author Comment

by:Q010797
ID: 1631373
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
ID: 1631374
> 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
ID: 1631375
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
ID: 1631376
Right sp.juver. I forgot that we are in a Linux (not UNIX) topic ;-)
0
 
LVL 1

Author Comment

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

Expert Comment

by:spjuver
ID: 1631378
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
ID: 1631379
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
ID: 1631380
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
ID: 1631381
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
ID: 1631382
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
 
LVL 1

Author Comment

by:Q010797
ID: 1631383
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
ID: 1631384
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
ID: 1631385
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
ID: 1631386
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
ID: 1631387
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
ID: 1631388
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
ID: 1631389
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
ID: 1631390
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
ID: 1631391
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
ID: 1631392
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
ID: 1631393
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
ID: 1631394
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
ID: 1631395
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
ID: 1631396
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

860 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