]> git.sur5r.net Git - openldap/commitdiff
allow clients to set USERNAME in session tracking control request (6779); plug minor...
authorPierangelo Masarati <ando@openldap.org>
Wed, 5 Jan 2011 22:54:20 +0000 (22:54 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 5 Jan 2011 22:54:20 +0000 (22:54 +0000)
clients/tools/common.c
doc/man/man1/ldapcompare.1
doc/man/man1/ldapdelete.1
doc/man/man1/ldapexop.1
doc/man/man1/ldapmodify.1
doc/man/man1/ldapmodrdn.1
doc/man/man1/ldappasswd.1
doc/man/man1/ldapsearch.1
doc/man/man1/ldapurl.1
doc/man/man1/ldapwhoami.1

index 7a7bb9ff38ac48a961fb80dec7b7019d75da1071..5ef5b4fa91ac2eeaa13ce4641e55a803ee1486b2 100644 (file)
@@ -120,6 +120,7 @@ static int  chainingContinuation = -1;
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
 #ifdef LDAP_CONTROL_X_SESSION_TRACKING
 static int     sessionTracking = 0;
+static char    *sessionTrackingName;
 struct berval  stValue;
 #endif /* LDAP_CONTROL_X_SESSION_TRACKING */
 ber_int_t vlvPos;
@@ -207,6 +208,9 @@ st_value( LDAP *ld, struct berval *value )
                }
        }
 
+       if ( sessionTrackingName != NULL ) {
+               ber_str2bv( sessionTrackingName , 0, 0, &id );
+       } else
 #ifdef HAVE_CYRUS_SASL
        if ( sasl_authz_id != NULL ) {
                ber_str2bv( sasl_authz_id, 0, 0, &id );
@@ -277,6 +281,13 @@ tool_destroy( void )
                BER_BVZERO( &passwd );
        }
 
+#ifdef HAVE_CYRUS_SASL
+       if ( sasl_mech != NULL ) {
+               ber_memfree( sasl_mech );
+               sasl_mech = NULL;
+       }
+#endif /* HAVE_CYRUS_SASL */
+
        if ( infile != NULL ) {
                ber_memfree( infile );
                infile = NULL;
@@ -306,6 +317,18 @@ tool_destroy( void )
                ber_memfree( postread_attrs );
                postread_attrs = NULL;
        }
+
+#ifdef LDAP_CONTROL_X_SESSION_TRACKING
+       if ( !BER_BVISNULL( &stValue ) ) {
+               ber_memfree( stValue.bv_val );
+               BER_BVZERO( &stValue );
+       }
+
+       if ( sessionTrackingName ) {
+               ber_memfree( sessionTrackingName );
+               sessionTrackingName = NULL;
+       }
+#endif /* LDAP_CONTROL_X_SESSION_TRACKING */
 }
 
 void
@@ -338,7 +361,7 @@ N_("             [!]postread[=<attrs>]  (RFC 4527; comma-separated attr list)\n"
 N_("             [!]preread[=<attrs>]   (RFC 4527; comma-separated attr list)\n")
 N_("             [!]relax\n")
 #ifdef LDAP_CONTROL_X_SESSION_TRACKING
-N_("             [!]sessiontracking\n")
+N_("             [!]sessiontracking[=<username>]\n")
 #endif /* LDAP_CONTROL_X_SESSION_TRACKING */
 N_("             abandon, cancel, ignore (SIGINT sends abandon/cancel,\n"
    "             or ignores response; if critical, doesn't wait for SIGINT.\n"
@@ -671,10 +694,13 @@ tool_args( int argc, char **argv )
                                        exit( EXIT_FAILURE );
                                }
                                sessionTracking = 1;
-                               if( crit ) {
+                               if ( crit ) {
                                        fprintf( stderr, "sessiontracking: critical flag not allowed\n" );
                                        usage();
                                }
+                               if ( cvalue ) {
+                                       sessionTrackingName = ber_strdup( cvalue );
+                               }
 #endif /* LDAP_CONTROL_X_SESSION_TRACKING */
 
                        /* this shouldn't go here, really; but it's a feature... */
@@ -1471,13 +1497,13 @@ tool_bind( LDAP *ld )
        if ( sessionTracking ) {
                LDAPControl c;
 
-               if (stValue.bv_val == NULL && st_value( ld, &stValue ) ) {
+               if ( BER_BVISNULL( &stValue) && st_value( ld, &stValue ) ) {
                        exit( EXIT_FAILURE );
                }
 
                c.ldctl_oid = LDAP_CONTROL_X_SESSION_TRACKING;
                c.ldctl_iscritical = 0;
-               ber_dupbv( &c.ldctl_value, &stValue );
+               c.ldctl_value = stValue;
 
                sctrl[nsctrls] = c;
                sctrls[nsctrls] = &sctrl[nsctrls];
@@ -1904,13 +1930,13 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
 
 #ifdef LDAP_CONTROL_X_SESSION_TRACKING
        if ( sessionTracking ) {
-               if ( stValue.bv_val == NULL && st_value( ld, &stValue ) ) {
+               if ( BER_BVISNULL( &stValue ) && st_value( ld, &stValue ) ) {
                        exit( EXIT_FAILURE );
                }
 
                c[i].ldctl_oid = LDAP_CONTROL_X_SESSION_TRACKING;
                c[i].ldctl_iscritical = 0;
-               ber_dupbv( &c[i].ldctl_value, &stValue );
+               c[i].ldctl_value = stValue;
 
                ctrls[i] = &c[i];
                i++;
index 75260d1b97080a58d1b16651a98e071deeba7143..18b1ef13d0698700b15507f153bf3b2d6569c000 100644 (file)
@@ -163,7 +163,7 @@ General extensions:
   [!]postread[=<attrs>] (a comma-separated attribute list)
   [!]preread[=<attrs>]  (a comma-separated attribute list)
   [!]relax
-  sessiontracking
+  sessiontracking[=<username>]
   abandon,cancel,ignore (SIGINT sends abandon/cancel,
   or ignores response; if critical, doesn't wait for SIGINT.
   not really controls)
index ffb5da5a4738b5cc75d418e62e92ff642b79623c..cf5878a008b9d5f76d2622afe6652184cc052cb5 100644 (file)
@@ -158,7 +158,7 @@ General extensions:
   [!]postread[=<attrs>] (a comma-separated attribute list)
   [!]preread[=<attrs>]  (a comma-separated attribute list)
   [!]relax
-  sessiontracking
+  sessiontracking[=<username>]
   abandon,cancel,ignore (SIGINT sends abandon/cancel,
   or ignores response; if critical, doesn't wait for SIGINT.
   not really controls)
index d20907cfa750c0884375dd98b7eaecd8a004d815..f14401327ccd512c7bdecb7c0fc77d2c70c9f330 100644 (file)
@@ -140,7 +140,7 @@ Specify general extensions.  \'!\' indicates criticality.
   [!]postread[=<attrs>] (a comma-separated attribute list)
   [!]preread[=<attrs>]  (a comma-separated attribute list)
   [!]relax
-  sessiontracking
+  sessiontracking[=<username>]
   abandon,cancel,ignore (SIGINT sends abandon/cancel,
   or ignores response; if critical, doesn't wait for SIGINT.
   not really controls)
index 8bddc963fe3e65a9bdcd0b29c136fc3ad1a6a89b..026801294699a43bffba4a853d4e280d27c86d4f 100644 (file)
@@ -225,7 +225,7 @@ General extensions:
   [!]postread[=<attrs>] (a comma-separated attribute list)
   [!]preread[=<attrs>]  (a comma-separated attribute list)
   [!]relax
-  sessiontracking
+  sessiontracking[=<username>]
   abandon,cancel,ignore (SIGINT sends abandon/cancel,
   or ignores response; if critical, doesn't wait for SIGINT.
   not really controls)
index d0a20cac314fcccf286ab190c8053b370e1e7d3e..560b078f855e2c6ca810b5982d634363f198529c 100644 (file)
@@ -167,7 +167,7 @@ General extensions:
   [!]postread[=<attrs>] (a comma-separated attribute list)
   [!]preread[=<attrs>]  (a comma-separated attribute list)
   [!]relax
-  sessiontracking
+  sessiontracking[=<username>]
   abandon,cancel,ignore (SIGINT sends abandon/cancel,
   or ignores response; if critical, doesn't wait for SIGINT.
   not really controls)
index a9f597f4023e5e2a40461ccc485a903642a96e64..365a364e7a72b08f5da20e2206c3707c048c4e02 100644 (file)
@@ -164,7 +164,7 @@ General extensions:
   [!]postread[=<attrs>] (a comma-separated attribute list)
   [!]preread[=<attrs>]  (a comma-separated attribute list)
   [!]relax
-  sessiontracking
+  sessiontracking[=<username>]
   abandon,cancel,ignore (SIGINT sends abandon/cancel,
   or ignores response; if critical, doesn't wait for SIGINT.
   not really controls)
index 8d65fc3b90a322598d272521cb80ab778425ae8f..66bd726ed7f3724d661bad588e889dcef9f71fc3 100644 (file)
@@ -272,7 +272,7 @@ General extensions:
   [!]postread[=<attrs>] (a comma-separated attribute list)
   [!]preread[=<attrs>]  (a comma-separated attribute list)
   [!]relax
-  sessiontracking
+  sessiontracking[=<username>]
   abandon,cancel,ignore (SIGINT sends abandon/cancel,
   or ignores response; if critical, doesn't wait for SIGINT.
   not really controls)
index 4466f4e76522a57d57e7d97c6437860649ca5784..f27438f27b12a7905dfdbf4d2e903c23c83c70aa 100644 (file)
@@ -76,7 +76,7 @@ General extensions:
   [!]postread[=<attrs>] (a comma-separated attribute list)
   [!]preread[=<attrs>]  (a comma-separated attribute list)
   [!]relax
-  sessiontracking
+  sessiontracking[=<username>]
   abandon,cancel,ignore (SIGINT sends abandon/cancel,
   or ignores response; if critical, doesn't wait for SIGINT.
   not really controls)
index 23aa2e1c93149448396cabde77ffb50f6768381e..9d2462863d9638aeace6b8f941cda2789a4103d4 100644 (file)
@@ -125,7 +125,7 @@ General extensions:
   [!]postread[=<attrs>] (a comma-separated attribute list)
   [!]preread[=<attrs>]  (a comma-separated attribute list)
   [!]relax
-  sessiontracking
+  sessiontracking[=<username>]
   abandon,cancel,ignore (SIGINT sends abandon/cancel,
   or ignores response; if critical, doesn't wait for SIGINT.
   not really controls)