summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2018-06-21 10:37:00 +0000
committerreyk <reyk@openbsd.org>2018-06-21 10:37:00 +0000
commit60f5961dc89a9b15d283a9e0405b34516681eeb7 (patch)
tree27518f75be81fcf677fc468756afd578b0ddf531
parentsplit the common half of dependencies handling into SolverBase, as PkgCreate (diff)
downloadwireguard-openbsd-60f5961dc89a9b15d283a9e0405b34516681eeb7.tar.xz
wireguard-openbsd-60f5961dc89a9b15d283a9e0405b34516681eeb7.zip
Sync aldap from ldap(1).
This also fixes the _url functions that was previously #ifdef'ed out. OK claudio@
-rw-r--r--usr.sbin/ypldap/aldap.c34
-rw-r--r--usr.sbin/ypldap/aldap.h19
2 files changed, 32 insertions, 21 deletions
diff --git a/usr.sbin/ypldap/aldap.c b/usr.sbin/ypldap/aldap.c
index 8e0357e26da..bf3a7833539 100644
--- a/usr.sbin/ypldap/aldap.c
+++ b/usr.sbin/ypldap/aldap.c
@@ -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.40 2018/06/21 10:37:00 reyk Exp $ */
+/* $OpenBSD: aldap.c,v 1.40 2018/06/21 10:37:00 reyk Exp $ */
/*
* Copyright (c) 2008 Alexander Schrijver <aschrijver@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_url *lu)
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_url *lu)
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, char *url, int typesonly, int sizelimit,
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 *root)
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:
diff --git a/usr.sbin/ypldap/aldap.h b/usr.sbin/ypldap/aldap.h
index 0ee6202c3fc..48edbd5f8af 100644
--- a/usr.sbin/ypldap/aldap.h
+++ b/usr.sbin/ypldap/aldap.h
@@ -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.11 2018/06/21 10:37:00 reyk Exp $ */
+/* $OpenBSD: aldap.h,v 1.11 2018/06/21 10:37:00 reyk Exp $ */
/*
* Copyright (c) 2008 Alexander Schrijver <aschrijver@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 ***);