procmail
[Top] [All Lists]

Re: Delivering mail to user's home dirs

1997-05-06 11:38:00
Devdas V <das(_at_)rri(_dot_)ernet(_dot_)in> writes:
               I have installed procmail-3.11pre6 and I am trying To
deliver mail to the user's home directory I have uncommented the define
MAILSPOOLHOME in authenticate.c and rebuilt procmail. This is by default
set to "/.mail" in which case the mail is delivered to .mail in the home
directory. What I want is the mail to be delivered to in the user's
name(as in the default /var/mail/$LOGNAME) rather than ./mail. The reason
is that when I check mail and if there is no mail, I get the message 'no
mail for .mail' rather than 'no mail for $LOGNAME' which is a bit
annoying.  I know that this is a /bin/mail problem but is there some
simple way of fixing this ? One could always inform the users about this
but there are some who wouldn't understand it at all. I also don't want to
create links in every users directory.


Well, I would suggest you deliver to a file in a subdirectory of their
account, ala:

        /path/to/my/homedir/guenther/.mail/guenther

and not just:

        /path/to/my/homedir/guenther/guenther

I really think that any file in your home directory should have an
obvious purpose given it's filename.  This is even more important given
that you're not making bloody obvious the fact that mail is stored in
home directories.  ("I don't remember creating that file...might as
well remove it").

Anyway, locate in authenticate.c the MAILSPOOLHOME define, and change
it to be what goes *after* the home directory, and *before* the
username.  It should both start and stop with a slash.  My suggestion
from above would give you a define of:

        #define MAILSPOOLHOME "/.mail/"

while if you really want it to be in their home directory itself you
would say:

        #define MAILSPOOLHOME "/"


Then, further down in authenticate.c you would locate the code that says:


#ifdef MAILSPOOLHOME
   { static const char mailfile[]=MAILSPOOLHOME;size_t i;
     if(!(pass->mbox=malloc((i=strlen(pass->pw->pw_dir))+STRLEN(mailfile)+1)))
        return "";
     strcpy(pass->mbox,pass->pw->pw_dir);
     strcpy(pass->mbox+i,mailfile);
#else


Change it to instead say:

#ifdef MAILSPOOLHOME
   { static const char mailfile[]=MAILSPOOLHOME;size_t i;
     
if(!(pass->mbox=malloc((i=strlen(pass->pw->pw_dir))+STRLEN(mailfile)+strlen(pass->pw->pw_name)+1)))
        return "";
     strcpy(pass->mbox,pass->pw->pw_dir);
     strcpy(pass->mbox+i,mailfile);
     strcpy(pass->mbox+i+STRLEN(mailfile),pass->pw->pw_name);
#else



That's all untested, but I'm fairly confident it will do what you want.


Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>