From c56564e2b56e8c636a5f37d0f94354aea9724c59 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 4 Jan 2007 20:17:53 +0000 Subject: [PATCH] disconnect without notice --- doc/man/man5/slapo-retcode.5 | 16 +++++++++++++- servers/slapd/overlays/retcode.c | 37 +++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/doc/man/man5/slapo-retcode.5 b/doc/man/man5/slapo-retcode.5 index 1de17fdefd..81a3faa760 100644 --- a/doc/man/man5/slapo-retcode.5 +++ b/doc/man/man5/slapo-retcode.5 @@ -58,7 +58,7 @@ If not defined, the suffix of the database is used. .hy 0 .B retcode\-item [op=] [text=] .B [ref=] [sleeptime=] [matched=] -.B [unsolicited=[:]] +.B [unsolicited=[:]] [flags=disconnect[,...]] .RS A dynamically generated entry, located below \fBretcode\-parent\fP. The \fBerrCode\fP is the number of the response code; @@ -79,6 +79,9 @@ The \fBunsolicited\fP field can be used to cause the return of an RFC 4511 unsolicited response message; if \fBOID\fP is not "0", an extended response is generated, with the optional \fBdata\fP appended. +If \fBflags\fP contains \fBdisconnect\fP, +.BR slapd (8) +disconnects abruptly, without notice. .RE .TP .B retcode\-indir @@ -181,6 +184,17 @@ in RFC 4511 unsolicited response: SINGLE-VALUE ) .RE .LP +If TRUE, +.BR slapd (8) +disconnects abruptly without notice: +.RS 4 +( 1.3.6.1.4.1.4203.666.11.4.1.8 + NAME ( 'errDisconnect' ) + DESC 'Disconnect without notice' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 + SINGLE-VALUE ) +.RE +.LP The abstract class that triggers the overlay: .RS 4 ( 1.3.6.1.4.1.4203.666.11.4.3.0 diff --git a/servers/slapd/overlays/retcode.c b/servers/slapd/overlays/retcode.c index a92430a904..198709febe 100644 --- a/servers/slapd/overlays/retcode.c +++ b/servers/slapd/overlays/retcode.c @@ -43,6 +43,8 @@ static AttributeDescription *ad_errSleepTime; static AttributeDescription *ad_errMatchedDN; static AttributeDescription *ad_errUnsolicitedOID; static AttributeDescription *ad_errUnsolicitedData; +static AttributeDescription *ad_errDisconnect; + static ObjectClass *oc_errAbsObject; static ObjectClass *oc_errObject; static ObjectClass *oc_errAuxObject; @@ -75,6 +77,10 @@ typedef struct retcode_item_t { slap_mask_t rdi_mask; struct berval rdi_unsolicited_oid; struct berval rdi_unsolicited_data; + + unsigned rdi_flags; +#define RDI_DISCONNECT (0x1U) + struct retcode_item_t *rdi_next; } retcode_item_t; @@ -407,6 +413,10 @@ retcode_op_func( Operation *op, SlapReply *rs ) rs->sr_text = "retcode not found"; } else { + if ( rdi->rdi_flags & RDI_DISCONNECT ) { + return rs->sr_err = SLAPD_DISCONNECT; + } + rs->sr_err = rdi->rdi_err; rs->sr_text = rdi->rdi_text.bv_val; rs->sr_matched = rdi->rdi_matched.bv_val; @@ -560,6 +570,12 @@ retcode_entry_response( Operation *op, SlapReply *rs, BackendInfo *bi, Entry *e } } + /* disconnect */ + a = attr_find( e->e_attrs, ad_errDisconnect ); + if ( a != NULL && bvmatch( &a->a_nvals[ 0 ], &slap_true_bv ) ) { + return rs->sr_err = SLAPD_DISCONNECT; + } + /* error code */ a = attr_find( e->e_attrs, ad_errCode ); if ( a == NULL ) { @@ -983,10 +999,22 @@ retcode_db_config( &rdi.rdi_unsolicited_oid ); } + } else if ( strncasecmp( argv[ i ], "flags=", STRLENOF( "flags=" ) ) == 0 ) + { + if ( strcasecmp( &argv[ i ][ STRLENOF( "flags=" ) ], "disconnect" ) == 0 ) { + rdi.rdi_flags |= RDI_DISCONNECT; + + } else { + fprintf( stderr, "%s: line %d: retcode: " + "unknown flag \"%s\".\n", + fname, lineno, &argv[ i ][ STRLENOF( "flags=" ) ] ); + return 1; + } + } else { fprintf( stderr, "%s: line %d: retcode: " "unknown option \"%s\".\n", - fname, lineno, argv[ i ] ); + fname, lineno, argv[ i ] ); return 1; } } @@ -1269,6 +1297,12 @@ retcode_initialize( void ) "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 " "SINGLE-VALUE )", &ad_errUnsolicitedData }, + { "( 1.3.6.1.4.1.4203.666.11.4.1.8 " + "NAME ( 'errDisconnect' ) " + "DESC 'Disconnect without notice' " + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 " + "SINGLE-VALUE )", + &ad_errDisconnect }, { NULL } }; @@ -1289,6 +1323,7 @@ retcode_initialize( void ) "$ errMatchedDN " "$ errUnsolicitedOID " "$ errUnsolicitedData " + "$ errDisconnect " ") )", &oc_errAbsObject }, { "( 1.3.6.1.4.1.4203.666.11.4.3.1 " -- 2.39.5