]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
version checking and empty nvals fix
authorKurt Zeilenga <kurt@openldap.org>
Mon, 10 Feb 2003 20:16:05 +0000 (20:16 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 10 Feb 2003 20:16:05 +0000 (20:16 +0000)
clients/tools/Makefile.in
clients/tools/common.c
clients/tools/ldapsearch.c

index 83c83d12fd9a1c293a7cd6f8f6561761ac6f630a..7685d1292e8bcf550544ad588a425f4322f8b082 100644 (file)
@@ -18,7 +18,7 @@ XXLIBS        = $(SECURITY_LIBS) $(LDIF_LIBS) $(LUTIL_LIBS)
 XSRCS  = ldsversion.c ldmversion.c lddversion.c ldrversion.c \
        ldpversion.c ldwversion.c ldcversion.c
 
-PROGRAMS = ldapsearch ldapmodify ldapdelete ldapmodrdn ldapadd \
+PROGRAMS = ldapsearch ldapmodify ldapdelete ldapmodrdn \
        ldappasswd ldapwhoami ldapcompare
 
 
@@ -43,11 +43,6 @@ ldapwhoami:  ldwversion.o
 ldapcompare: ldcversion.o
        $(LTLINK) -o $@ ldapcompare.o common.o ldcversion.o $(LIBS)
 
-ldapadd:       ldapmodify
-       @-$(RM) $@$(EXEEXT)
-       $(LN_H) ldapmodify$(EXEEXT) ldapadd$(EXEEXT)
-
-
 ldsversion.c: ldapsearch.o common.o $(XLIBS)
        @-$(RM) $@
        $(MKVERSION) $(MKVOPTS) ldapsearch > $@
index 3b4983336c0b544b48e9949e90db27b6c3b180ad..2600d67a9e3e32513eac2a6a2b34be3b4180f86d 100644 (file)
@@ -455,9 +455,52 @@ tool_args( int argc, char **argv )
                }
     }
 
-       if (version) {
-               fprintf( stderr, "%s: %s", prog, __Version );
-               if (version > 1) exit( EXIT_SUCCESS );
+       {
+               /* prevent bad linking */
+               LDAPAPIInfo api;
+               api.ldapai_info_version = LDAP_API_INFO_VERSION;
+
+               if ( ldap_get_option(NULL, LDAP_OPT_API_INFO, &api)
+                       != LDAP_OPT_SUCCESS )
+               {
+                       fprintf( stderr, "%s: ldap_get_option(API_INFO) failed\n", prog );
+                       exit( EXIT_FAILURE );
+               }
+
+               if (api.ldapai_info_version != LDAP_API_INFO_VERSION) {
+                       fprintf( stderr, "LDAP APIInfo version mismatch: "
+                               "got %d, expected %d\n",
+                               api.ldapai_info_version, LDAP_API_INFO_VERSION );
+                       exit( EXIT_FAILURE );
+       }
+
+               if( api.ldapai_api_version != LDAP_API_VERSION ) {
+                       fprintf( stderr, "LDAP API version mismatch: "
+                               "got %d, expected %d\n",
+                               api.ldapai_api_version, LDAP_API_VERSION );
+                       exit( EXIT_FAILURE );
+               }
+
+               if( strcmp(api.ldapai_vendor_name, LDAP_VENDOR_NAME ) != 0 ) {
+                       fprintf( stderr, "LDAP vendor name mismatch: "
+                               "got %s, expected %s\n",
+                               api.ldapai_vendor_name, LDAP_VENDOR_NAME );
+                       exit( EXIT_FAILURE );
+               }
+
+               if( api.ldapai_vendor_version != LDAP_VENDOR_VERSION ) {
+                       fprintf( stderr, "LDAP vendor version mismatch: "
+                               "got %d, expected %d\n",
+                               api.ldapai_vendor_version, LDAP_VENDOR_VERSION );
+                       exit( EXIT_FAILURE );
+               }
+
+               if (version) {
+                       fprintf( stderr, "%s: %s\t(LDAP library: %s %d)\n",
+                               prog, __Version,
+                               LDAP_VENDOR_NAME, LDAP_VENDOR_VERSION );
+                       if (version > 1) exit( EXIT_SUCCESS );
+               }
        }
 
        if (protocol == -1)
index ee7611c6a4fc75816eb2e0964c8813c0cd48118b..67beac471e0279102fcccb337d3abc356e82c3c0 100644 (file)
@@ -1313,7 +1313,7 @@ print_entry(
        {
                if (bv.bv_val == NULL) break;
 
-               if ( attrsonly ) {
+               if ( attrsonly || !bvals ) {
                        write_ldif( LDIF_PUT_NOVALUE, bv.bv_val, NULL, 0 );
 
                } else {