[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Access conttrol as an overlay function

> Kurt D. Zeilenga wrote:
>> However,
>> in responses, the information (such as entry data) can be
>> shared (as managed by the backend).  So, send_entry functions
>> MUST NOT alter the entry struct referenced by sr_entry.
>> They however can alter sr_entry to point to a different entry.
>> If you do provide a replacement entry, then you need to
>> tell send_entry to free it (REP_ENTRY_MUSTBEFREED)
> This is setting rs->sr_flags = REP_ENTRY_MUSTBEFREED ?

you should rather | (OR) the flags with that; essentially,
look at rwm overlay, which is the one that drove the
need for that flag.

Before modifying an entry, do

        Entry *e = rs->sr_entry;
        if ( !( rs->sr_flags & REP_ENTRY_MODIFIABLE ) ) {
                e = entry_dup( e );
                if ( e == NULL ) {
                        goto fail;
                rs->sr_flags |=

>> or not
>> (and, if not, manage the replacement entry memory by other
>> means).  And if its to be freed, you cannot copy by reference
>> from the original entry.
> So what if the complete entry should be removed from the response ?
> Should I just set rs->sr_entry = 0 ? Is that safe?

You need to trap the send_search_entry() before it gets sent,
by simply returning 0 (which means success, but don't do
anything more) from the overlay's response handler instead
of SLAP_CB_CONTINUE (which means everything was fine, keep
on going thru overlays)

> And what happens with the old entry is it magically freed by the memory
> system ?

It is freed only if it was marked as REP_ENTRY_MUSTBEFREED;
this simply tells the response procedure to free it; if you need
to modify it, it must be marked with REP_ENTRY_MODIFIABLE;
if it is not marked with REP_ENTRY_MUSTBEFREED, the system doesn't
do anything, and in that case, a temporary entry must be freed
by your overlay, by means of the sc_cleanup member of the struct

I really suggest you look at the available examples after reading


Pierangelo Masarati

    SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497