From: Howard Chu Date: Thu, 12 Jun 2025 16:38:32 +0000 (+0100) Subject: ITS#10356 libldap: implement LDAP_OPT_REFHOPLIMIT X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=76e149280958c5d9fd9587d1d3ba26130eb3966c;p=thirdparty%2Fopenldap.git ITS#10356 libldap: implement LDAP_OPT_REFHOPLIMIT --- diff --git a/doc/man/man3/ldap_get_option.3 b/doc/man/man3/ldap_get_option.3 index 67d38886b1..45e91a28e5 100644 --- a/doc/man/man3/ldap_get_option.3 +++ b/doc/man/man3/ldap_get_option.3 @@ -295,10 +295,17 @@ or .BR outvalue must be .BR "int *" . -.\".TP -.\".B LDAP_OPT_REFHOPLIMIT -.\"This option is OpenLDAP specific. -.\"It is not currently implemented. +.TP +.B LDAP_OPT_REFHOPLIMIT +Set the maximum number of referrals to chase for a request. +.BR invalue +must be +.BR "const int *" ; +.BR outvalue +must be a +.BR "int *" . +They cannot be NULL. +This option is OpenLDAP specific. .TP .B LDAP_OPT_RESTART Determines whether the library should implicitly restart connections (FIXME). diff --git a/doc/man/man5/ldap.conf.5 b/doc/man/man5/ldap.conf.5 index d47481d6ed..c1b0eaa06f 100644 --- a/doc/man/man5/ldap.conf.5 +++ b/doc/man/man5/ldap.conf.5 @@ -208,6 +208,10 @@ Note that the command line tools .\".B RESTART .\"Determines whether the library should implicitly restart connections (FIXME). .TP +.B REFHOPLIMIT +Specified the maximum number of referrals to follow when performing a +request. The number should be a positive integer. The default is 5. +.TP .B SIZELIMIT Specifies a size limit (number of entries) to use when performing searches. The number should be a non-negative integer. \fISIZELIMIT\fP of zero (0) diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c index 90fc34c5a6..4195142d41 100644 --- a/libraries/libldap/init.c +++ b/libraries/libldap/init.c @@ -82,6 +82,8 @@ static const struct ol_attribute { {0, ATTR_OPT_INT, "VERSION", NULL, LDAP_OPT_PROTOCOL_VERSION}, {0, ATTR_KV, "DEREF", deref_kv, /* or &deref_kv[0] */ offsetof(struct ldapoptions, ldo_deref)}, + {0, ATTR_INT, "REFHOPLIMIT", NULL, + offsetof(struct ldapoptions, ldo_refhoplimit)}, {0, ATTR_INT, "SIZELIMIT", NULL, offsetof(struct ldapoptions, ldo_sizelimit)}, {0, ATTR_INT, "TIMELIMIT", NULL, diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c index 218d5445a7..a7798d4135 100644 --- a/libraries/libldap/options.c +++ b/libraries/libldap/options.c @@ -216,6 +216,11 @@ ldap_get_option( rc = LDAP_OPT_SUCCESS; break; + case LDAP_OPT_REFHOPLIMIT: + * (int *) outvalue = lo->ldo_refhoplimit; + rc = LDAP_OPT_SUCCESS; + break; + case LDAP_OPT_SIZELIMIT: * (int *) outvalue = lo->ldo_sizelimit; rc = LDAP_OPT_SUCCESS; @@ -836,6 +841,7 @@ ldap_set_option( /* options which cannot withstand invalue == NULL */ case LDAP_OPT_DEREF: + case LDAP_OPT_REFHOPLIMIT: case LDAP_OPT_SIZELIMIT: case LDAP_OPT_TIMELIMIT: case LDAP_OPT_PROTOCOL_VERSION: @@ -881,6 +887,11 @@ ldap_set_option( rc = LDAP_OPT_SUCCESS; break; + case LDAP_OPT_REFHOPLIMIT: + lo->ldo_refhoplimit = * (const int *) invalue; + rc = LDAP_OPT_SUCCESS; + break; + case LDAP_OPT_SIZELIMIT: /* FIXME: check value for protocol compliance? */ lo->ldo_sizelimit = * (const int *) invalue;