Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

smmapd: matching NOTFOUND

14 views
Skip to first unread message

Eugene Grosbein

unread,
Nov 5, 2008, 1:27:05 AM11/5/08
to
Hi!

There is a code in sendmail.cf to work with cyrus' smmapd:

LOCAL_CONFIG
# Cyrus smmapd(8)'s map for verifying mailboxes of local recipients
Kcyrus socket -a<OK> -T<TMPF> CYRUS_SMMAPD_SOCKET

[skip]

#Cyrus OK, skip
R<!> $* $| $* <OK> $@ $1
#Non-existing user
R<!> $* $| $* <NOTFOUND> $# error $@ 5.1.1 $: "550 Mailbox does not exist."
#Over quota or lookup failure
R<!> $* $| $* <TMPF> $# error $@ 4.3.0 $: "451 TEMPFAIL."
#ACL forbids posting
R<!> $* $| $* $# error $@ 5.1.1 $: "550 Mailbox is not available."

This basically works but not line containing NOTFOUND,
it never matches due to wrong rule. Please show me how to rewrite
this line so it would match cyrus reply:

31:NOTFOUND Mailbox does not exist,

Eugene Grosbein

Andrzej Adam Filip

unread,
Nov 5, 2008, 2:17:16 AM11/5/08
to

Post also "R" line containing the lookup - $(cyrus .... $)

I suspect most likely you should change something like
$(cyrus $1 $)
into
$(cyrus $1 $: $1 <NOTFOUND> $)
to specify sendmail's rewrite in case of 'no match'='not found'

"31:NOTFOUND Mailbox does not exist" reply is "translated" by sendmail.
NOTFOUND marks "type/class of reply", not the reply itself.

P.S.
Have you seen sendmail&cyrus integration for virtual cyrus domains with
support for aliases:
http://open-sendmail.sourceforge.net/rtcyrus3/
or set of older solutions:
http://anfi.homeunix.org/sendmail/rtcyrus2.html

--
[pl>en Andrew] Andrzej Adam Filip : an...@onet.eu : an...@xl.wp.pl
Whether you can hear it or not,
The Universe is laughing behind your back.
-- National Lampoon, "Deteriorata"

Eugene Grosbein

unread,
Nov 5, 2008, 2:30:36 AM11/5/08
to
05 ноя 2008, среда, в 14:17 KRAT, Andrzej Adam Filip написал(а):

>> There is a code in sendmail.cf to work with cyrus' smmapd:
>>
>> LOCAL_CONFIG
>> # Cyrus smmapd(8)'s map for verifying mailboxes of local recipients
>> Kcyrus socket -a<OK> -T<TMPF> CYRUS_SMMAPD_SOCKET

AAF> Post also "R" line containing the lookup - $(cyrus .... $)

Sorry, here is full ruleset, a version I've come to
for now:

Sckuser_cyrus
#Query smmapd(8)
R$+ $: <!> $1 $| $(cyrus $1 $: $)


#Cyrus OK, skip
R<!> $* $| $* <OK> $@ $1

#Over quota or lookup failure
R<!> $* $| $* <TMPF> $# error $@ 4.3.0 $: "451 TEMPFAIL."

#Non-existing user
R<!> $* $| $@ $# error $@ 5.1.1 $: "550 Mailbox does not exist."
#Mailbox doesn't exist or its ACL forbids posting


R<!> $* $| $* $# error $@ 5.1.1 $: "550 Mailbox is not available.

Still does not work.

AAF> I suspect most likely you should change something like
AAF> $(cyrus $1 $)
AAF> into
AAF> $(cyrus $1 $: $1 <NOTFOUND> $)
AAF> to specify sendmail's rewrite in case of 'no match'='not found'

Would not it insert <NOTFOUND> in all cases, not just if 'no match'?

AAF> Have you seen sendmail&cyrus integration for virtual cyrus domains with
AAF> support for aliases:
AAF> http://open-sendmail.sourceforge.net/rtcyrus3/
AAF> or set of older solutions:
AAF> http://anfi.homeunix.org/sendmail/rtcyrus2.html

I've glanced at this. Now I use simplier ckuser_cyrus.m4 by Mike Boev
inspired by yours mrs_cyrus.m4 :-) As I do not need virtual domains etc.,
just user existance and quota checks at SMTP session stage.

Eugene
--
Дьявол в мелочах

Andrzej Adam Filip

unread,
Nov 5, 2008, 2:47:45 AM11/5/08
to
Eugene Grosbein <eu...@grosbein.pp.ru> wrote:

> 05 ноя 2008, среда, в 14:17 KRAT, Andrzej Adam Filip написал(а):
>
> >> There is a code in sendmail.cf to work with cyrus' smmapd:
> >>
> >> LOCAL_CONFIG
> >> # Cyrus smmapd(8)'s map for verifying mailboxes of local recipients
> >> Kcyrus socket -a<OK> -T<TMPF> CYRUS_SMMAPD_SOCKET
>
> AAF> Post also "R" line containing the lookup - $(cyrus .... $)
>
> Sorry, here is full ruleset, a version I've come to
> for now:
>
> Sckuser_cyrus
> #Query smmapd(8)
> R$+ $: <!> $1 $| $(cyrus $1 $: $)
> #Cyrus OK, skip
> R<!> $* $| $* <OK> $@ $1
> #Over quota or lookup failure
> R<!> $* $| $* <TMPF> $# error $@ 4.3.0 $: "451 TEMPFAIL."
> #Non-existing user
> R<!> $* $| $@ $# error $@ 5.1.1 $: "550 Mailbox does not exist."
> #Mailbox doesn't exist or its ACL forbids posting
> R<!> $* $| $* $# error $@ 5.1.1 $: "550 Mailbox is not available.
>
> Still does not work.

test it using the commands below

1) shorter debug output
echo '5 mailbox-name' | sendmail -d21.12 -d60.5 -C sendmail-test.cf -bt

As I understand your rule will get mailbox name without domain
[ with stripped domain part ]

2) longer debug output
sendmail -d21.12 -d60.5 -C sendmail-test.cf -bv user@domain

> AAF> I suspect most likely you should change something like
> AAF> $(cyrus $1 $)
> AAF> into
> AAF> $(cyrus $1 $: $1 <NOTFOUND> $)
> AAF> to specify sendmail's rewrite in case of 'no match'='not found'
>
> Would not it insert <NOTFOUND> in all cases, not just if 'no match'?

The part after $: specifies what the lookup should return
in "no match" cache.

> AAF> Have you seen sendmail&cyrus integration for virtual cyrus domains with
> AAF> support for aliases:
> AAF> http://open-sendmail.sourceforge.net/rtcyrus3/
> AAF> or set of older solutions:
> AAF> http://anfi.homeunix.org/sendmail/rtcyrus2.html
>
> I've glanced at this. Now I use simplier ckuser_cyrus.m4 by Mike Boev
> inspired by yours mrs_cyrus.m4 :-) As I do not need virtual domains etc.,
> just user existance and quota checks at SMTP session stage.

One more warning:
It is implemented via rule set 5 - sendmail *ignores* temporary error
codes generated in ruleset 5.

--
[pl>en Andrew] Andrzej Adam Filip : an...@onet.eu : an...@xl.wp.pl

A large number of installed systems work by fiat.
That is, they work by being declared to work.
-- Anatol Holt

Eugene Grosbein

unread,
Nov 6, 2008, 12:47:22 AM11/6/08
to
05 ноя 2008, среда, в 14:47 KRAT, Andrzej Adam Filip написал(а):

AAF>> I suspect most likely you should change something like
AAF>> $(cyrus $1 $)
AAF>> into
AAF>> $(cyrus $1 $: $1 <NOTFOUND> $)
AAF>> to specify sendmail's rewrite in case of 'no match'='not found'
>> Would not it insert <NOTFOUND> in all cases, not just if 'no match'?

AAF> The part after $: specifies what the lookup should return
AAF> in "no match" cache.

It does not distinguish NOTFOUND from PERM case.

AAF> One more warning:
AAF> It is implemented via rule set 5 - sendmail *ignores* temporary error
AAF> codes generated in ruleset 5.

I do not need temporary errors from Cyrus really.
In setup it returns permanent errors for quota overflow too.
But I need to distinguish NOTFOUND permanent error from other
permanent errors.

For now, I've patched sendmail 8.14.3 sources to support new flag
-F<NOTFOUND> for socket maps just like it supports -T<TMPF>.

So, I've got what I need with this configuration:

LOCAL_CONFIG
Kcyrus socket -a<OK> -F<NOTFOUND> -T<TMPF> local:/var/imap/socket/smmapd

LOCAL_RULESETS
SLocal_localaddr

R$+ $: $> "ckuser_cyrus" $1


Sckuser_cyrus
#Query smmapd(8)
R$+ $: <!> $1 $| $(cyrus $1 $: $)
#Cyrus OK, skip
R<!> $* $| $* <OK> $@ $1

#Non-existing user
R<!> $* $| $* <NOTFOUND> $# error $@ 5.1.1 $: "550 Mailbox does not exist."


#Over quota or lookup failure
R<!> $* $| $* <TMPF> $# error $@ 4.3.0 $: "451 TEMPFAIL."

#ACL forbids posting


R<!> $* $| $* $# error $@ 5.1.1 $: "550 Mailbox is not available."

The patch follows:

--- sendmail.h.orig 2008-11-05 14:50:21.000000000 +0700
+++ sendmail.h 2008-11-05 14:50:41.000000000 +0700
@@ -1212,6 +1212,7 @@
short map_specificity; /* specificity of aliases */
MAP *map_stack[MAXMAPSTACK]; /* list for stacked maps */
short map_return[MAXMAPACTIONS]; /* return bitmaps for stacked maps */
+ char *map_napp; /* to append to "notfound" matches */
};


--- map.c.orig 2008-11-05 14:51:13.000000000 +0700
+++ map.c 2008-11-05 14:56:01.000000000 +0700
@@ -204,6 +204,10 @@
map->map_app = ++p;
break;

+ case 'F':
+ map->map_napp = ++p;
+ break;
+
case 'T':
map->map_tapp = ++p;
break;
@@ -265,6 +269,8 @@
}
if (map->map_app != NULL)
map->map_app = newstr(map->map_app);
+ if (map->map_napp != NULL)
+ map->map_napp = newstr(map->map_napp);
if (map->map_tapp != NULL)
map->map_tapp = newstr(map->map_tapp);
if (map->map_keycolnm != NULL)
--- parseaddr.c.orig 2008-11-05 14:53:11.000000000 +0700
+++ parseaddr.c 2008-11-05 14:54:03.000000000 +0700
@@ -1875,6 +1875,25 @@
rwbuf);
return rwbuf;
}
+ if (status == EX_NOTFOUND && map->map_napp != NULL)
+ {
+ size_t i = strlen(key) + strlen(map->map_napp) + 1;
+ static char *rwbuf = NULL;
+ static size_t rwbuflen = 0;
+
+ if (i > rwbuflen)
+ {
+ if (rwbuf != NULL)
+ sm_free(rwbuf);
+ rwbuflen = i;
+ rwbuf = (char *) sm_pmalloc_x(rwbuflen);
+ }
+ (void) sm_strlcpyn(rwbuf, rwbuflen, 2, key, map->map_napp);
+ if (tTd(60, 4))
+ sm_dprintf("map_lookup notfound: returning \"%s\"\n",
+ rwbuf);
+ return rwbuf;
+ }
return replac;
}
/*

Eugene
--
Choose no career

0 new messages