Hi,

the _url code was broken and disabled in ypldap's aldap - I fixed it
for ldap(1).  The other chunk is a DEBUG message fix, not compiled by
default.

OK?

Index: usr.sbin/ypldap/aldap.c
===================================================================
RCS file: /cvs/src/usr.sbin/ypldap/aldap.c,v
retrieving revision 1.39
diff -u -p -u -p -r1.39 aldap.c
--- usr.sbin/ypldap/aldap.c     8 Feb 2018 18:02:06 -0000       1.39
+++ usr.sbin/ypldap/aldap.c     21 Jun 2018 08:29:52 -0000
@@ -1,5 +1,5 @@
-/*     $Id: aldap.c,v 1.39 2018/02/08 18:02:06 jca Exp $ */
-/*     $OpenBSD: aldap.c,v 1.39 2018/02/08 18:02:06 jca Exp $ */
+/*     $Id: aldap.c,v 1.2 2018/06/21 08:27:35 reyk Exp $ */
+/*     $OpenBSD: aldap.c,v 1.2 2018/06/21 08:27:35 reyk Exp $ */
 
 /*
  * Copyright (c) 2008 Alexander Schrijver <aschrij...@openbsd.org>
@@ -693,16 +693,14 @@ aldap_free_attr(char **values)
        return (1);
 }
 
-#if 0
 void
 aldap_free_url(struct aldap_url *lu)
 {
        free(lu->buffer);
-       free(lu->filter);
 }
 
 int
-aldap_parse_url(char *url, struct aldap_url *lu)
+aldap_parse_url(const char *url, struct aldap_url *lu)
 {
        char            *p, *forward, *forward2;
        const char      *errstr = NULL;
@@ -712,10 +710,20 @@ aldap_parse_url(char *url, struct aldap_
                return (-1);
 
        /* protocol */
-       if (strncasecmp(LDAP_URL, p, strlen(LDAP_URL)) != 0)
-               goto fail;
-       lu->protocol = LDAP;
-       p += strlen(LDAP_URL);
+       if (strncasecmp(LDAP_URL, p, strlen(LDAP_URL)) == 0) {
+               lu->protocol = LDAP;
+               p += strlen(LDAP_URL);
+       } else if (strncasecmp(LDAPS_URL, p, strlen(LDAPS_URL)) == 0) {
+               lu->protocol = LDAPS;
+               p += strlen(LDAPS_URL);
+       } else if (strncasecmp(LDAPTLS_URL, p, strlen(LDAPTLS_URL)) == 0) {
+               lu->protocol = LDAPTLS;
+               p += strlen(LDAPTLS_URL);
+       } else if (strncasecmp(LDAPI_URL, p, strlen(LDAPI_URL)) == 0) {
+               lu->protocol = LDAPI;
+               p += strlen(LDAPI_URL);
+       } else
+               lu->protocol = -1;
 
        /* host and optional port */
        if ((forward = strchr(p, '/')) != NULL)
@@ -795,7 +803,6 @@ aldap_parse_url(char *url, struct aldap_
        if (p)
                lu->filter = p;
 done:
-       free(url);
        return (1);
 fail:
        free(lu->buffer);
@@ -805,7 +812,7 @@ fail:
 
 int
 aldap_search_url(struct aldap *ldap, char *url, int typesonly, int sizelimit,
-    int timelimit)
+    int timelimit, struct aldap_page_control *page)
 {
        struct aldap_url *lu;
 
@@ -816,7 +823,7 @@ aldap_search_url(struct aldap *ldap, cha
                goto fail;
 
        if (aldap_search(ldap, lu->dn, lu->scope, lu->filter, lu->attributes,
-           typesonly, sizelimit, timelimit) == -1)
+           typesonly, sizelimit, timelimit, page) == -1)
                goto fail;
 
        aldap_free_url(lu);
@@ -825,7 +832,6 @@ fail:
        aldap_free_url(lu);
        return (-1);
 }
-#endif /* 0 */
 
 /*
  * internal functions
@@ -1277,7 +1283,7 @@ ldap_debug_elements(struct ber_element *
                        fprintf(stderr, "<INVALID>\n");
                        break;
                }
-               fprintf(stderr, "string \"%.*s\"\n",  len, buf);
+               fprintf(stderr, "string \"%.*s\"\n",  (int)len, buf);
                break;
        case BER_TYPE_NULL:     /* no payload */
        case BER_TYPE_EOC:
Index: usr.sbin/ypldap/aldap.h
===================================================================
RCS file: /cvs/src/usr.sbin/ypldap/aldap.h,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 aldap.h
--- usr.sbin/ypldap/aldap.h     30 May 2017 09:33:31 -0000      1.10
+++ usr.sbin/ypldap/aldap.h     21 Jun 2018 08:29:52 -0000
@@ -1,5 +1,5 @@
-/*     $Id: aldap.h,v 1.10 2017/05/30 09:33:31 jmatthew Exp $ */
-/*     $OpenBSD: aldap.h,v 1.10 2017/05/30 09:33:31 jmatthew Exp $ */
+/*     $Id: aldap.h,v 1.1.1.1 2018/06/13 15:45:57 reyk Exp $ */
+/*     $OpenBSD: aldap.h,v 1.1.1.1 2018/06/13 15:45:57 reyk Exp $ */
 
 /*
  * Copyright (c) 2008 Alexander Schrijver <aschrij...@openbsd.org>
@@ -25,6 +25,10 @@
 #include "ber.h"
 
 #define LDAP_URL               "ldap://";
+#define LDAPS_URL              "ldaps://"
+#define LDAPTLS_URL            "ldap+tls://"
+#define LDAPI_URL              "ldapi://"
+
 #define LDAP_PORT              389
 #define LDAPS_PORT             636
 #define LDAP_PAGED_OID         "1.2.840.113556.1.4.319"
@@ -79,7 +83,9 @@ struct aldap_message {
 
 enum aldap_protocol {
        LDAP,
-       LDAPS
+       LDAPS,
+       LDAPTLS,
+       LDAPI
 };
 
 struct aldap_url {
@@ -222,11 +228,10 @@ char      *aldap_get_dn(struct aldap_message 
 char   *aldap_get_diagmsg(struct aldap_message *);
 char   **aldap_get_references(struct aldap_message *);
 void    aldap_free_references(char **values);
-#if 0
-int     aldap_parse_url(char *, struct aldap_url *);
+int     aldap_parse_url(const char *, struct aldap_url *);
 void    aldap_free_url(struct aldap_url *);
-int     aldap_search_url(struct aldap *, char *, int, int, int);
-#endif
+int     aldap_search_url(struct aldap *, char *, int, int, int,
+           struct aldap_page_control *);
 
 int     aldap_count_attrs(struct aldap_message *);
 int     aldap_match_attr(struct aldap_message *, char *, char ***);

Reply via email to