procmail
[Top] [All Lists]

Re: lookup in other base the user ?

1999-12-10 05:50:38
thanks the code work very well ...

I have another question.

I have a mail in nfs partition. And want
to delivery to directory mail users (like q-mail).

If my nfs partition don't mount with sub-dirs ...

How disable the option of procmail to delivery to
inbox when not found the directory ?

And how return a error o queue action to sendmail?

thanks in advance ...


At 09:48 PM 12/9/99 -0600, Philip Guenther wrote:
mtoro <mtoro(_at_)chat(_dot_)cl> writes:
>           I'm want authenticate a user in other file ,
>distinct of /etc/passwd, for example /etc/poppasswd.
>
>Exist any patch for make this ?

Procmail's user database (a.k.a. passwd file) lookups are all abstracted
to the interface declared in src/authenticate.h and implemented in
the stock distribution in src/authenticate.c.  If you want to use a
non-standard user database like /etc/poppasswd, you'll need to implement
your own versions of auth_finduser() and auth_finduid() that perform the
necessary lookups.  Hmm, since the normal versions of those functions
leave the actual passwd lookups to cgetpwnam() and cgetpwuid(), functions
local to src/authenticate.c that are simple frontends to getpwnam()
and getpwuid(), you should be able to just replace those two functions
with something like:


#include <stdio.h>
#define POPPWDB         "/etc/poppasswd"
static FILE*popfh=0;

static int setpopdb P((void))
{ return popfh?seek(popfh,0,SEEK_SET):!(popfh=fopen(POPPWDB,"r"));
}

static const struct passwd*cgetpwnam(user,sock)const char*const user;
 const int sock;
{ const struct passwd*pw=0;
  if(!setpopdb())
     while(pw=fgetpwent(popfh))
        if(!strcmp(pw->pw_name,user))
           break;
  return pw;
}

static const struct passwd*cgetpwuid(uid,sock)const uid_t uid;const int sock;
{ const struct passwd*pw=0;
  if(!setpopdb())
     while(pw=fgetpwent(popfh))
        if(pw->pw_uid==uid)
           break;
  return pw;
}


Oh, and add the lines
  if(popfh)
     fclose(popfh),popfh=0;

to the auth_end() function.


That's all *completely* untested, so use at your own risk, The Management
Accepts No Liability, etc...


Philip Guenther

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