From 85b935b3dfc74c4f37758349b54eb0947973ad41 Mon Sep 17 00:00:00 2001 From: "Paul J. Reder" Date: Thu, 24 Jan 2008 00:24:01 +0000 Subject: [PATCH] Reduced the bumpiness (from major to minor) and utilized #defines throughout (per Ruediger's suggestions). Still looking at the dir merge. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@614747 13f79535-47bb-0310-9956-ffa450edef68 --- include/util_ldap.h | 10 ++++++++-- modules/ldap/util_ldap.c | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/util_ldap.h b/include/util_ldap.h index 1b48ca55fb..e782276fd7 100644 --- a/include/util_ldap.h +++ b/include/util_ldap.h @@ -93,6 +93,11 @@ typedef enum { always=LDAP_DEREF_ALWAYS } deref_options; +#define AP_LDAP_DEFAULT_HOPLIMIT 5 /* make sure these two stay */ +#define AP_LDAP_DEFAULT_HOPLIMIT_STR "5" /* in synch with each other! */ +#define AP_LDAP_CHASEREFERRALS_OFF 0 +#define AP_LDAP_CHASEREFERRALS_ON 1 + /* Structure representing an LDAP connection */ typedef struct util_ldap_connection_t { LDAP *ldap; @@ -113,12 +118,13 @@ typedef struct util_ldap_connection_t { apr_array_header_t *client_certs; /* Client certificates on this connection */ const char *reason; /* Reason for an error failure */ - int ChaseReferrals; /* [on|off] (on=1, off=0, default = On)*/ - int ReferralHopLimit; /* # of referral hops to follow (default = 5) */ struct util_ldap_connection_t *next; struct util_ldap_state_t *st; /* The LDAP vhost config this connection belongs to */ int keep; /* Will this connection be kept when it's unlocked */ + + int ChaseReferrals; /* [on|off] (default = AP_LDAP_CHASEREFERRALS_ON)*/ + int ReferralHopLimit; /* # of referral hops to follow (default = AP_LDAP_DEFAULT_HOPLIMIT) */ } util_ldap_connection_t; typedef struct util_ldap_config_t { diff --git a/modules/ldap/util_ldap.c b/modules/ldap/util_ldap.c index 234a133a25..d007ee5cad 100644 --- a/modules/ldap/util_ldap.c +++ b/modules/ldap/util_ldap.c @@ -350,22 +350,23 @@ static int uldap_connection_init(request_rec *r, /* Set options for rebind and referrals. */ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "LDAP: Setting referrals to %s.", - (ldc->ChaseReferrals ? "On" : "Off")); + ((ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) ? "On" : "Off")); apr_ldap_set_option(r->pool, ldc->ldap, APR_LDAP_OPT_REFERRALS, - (void *)(ldc->ChaseReferrals ? LDAP_OPT_ON : LDAP_OPT_OFF), + (void *)((ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) ? + LDAP_OPT_ON : LDAP_OPT_OFF), &(result)); if (result->rc != LDAP_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Unable to set LDAP_OPT_REFERRALS option to %s: %d.", - (ldc->ChaseReferrals ? "On" : "Off"), + ((ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) ? "On" : "Off"), result->rc); result->reason = "Unable to set LDAP_OPT_REFERRALS."; uldap_connection_unbind(ldc); return(result->rc); } - if (ldc->ChaseReferrals) { + if (ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) { /* Referral hop limit - only if referrals are enabled */ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Setting referral hop limit to %d.", @@ -2348,7 +2349,7 @@ static const char *util_ldap_set_chase_referrals(cmd_parms *cmd, ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, cmd->server, "LDAP: Setting refferal chasing %s", - mode?"ON":"OFF"); + (mode == AP_LDAP_CHASEREFERRALS_ON) ? "ON" : "OFF"); dc->ChaseReferrals = mode; @@ -2374,8 +2375,9 @@ static void *util_ldap_create_dir_config(apr_pool_t *p, char *d) { util_ldap_config_t *dc = (util_ldap_config_t *) apr_pcalloc(p,sizeof(util_ldap_config_t)); - dc->ChaseReferrals = 1; /* default is to turn referral chasing on. */ - dc->ReferralHopLimit = 5; /* default is to chase a max of 5 hops. */ + /* defaults are AP_LDAP_CHASEREFERRALS_ON and AP_LDAP_DEFAULT_HOPLIMIT */ + dc->ChaseReferrals = AP_LDAP_CHASEREFERRALS_ON; + dc->ReferralHopLimit = AP_LDAP_DEFAULT_HOPLIMIT; return dc; } @@ -2717,7 +2719,7 @@ static const command_rec util_ldap_cmds[] = { AP_INIT_TAKE1("LDAPReferralHopLimit", util_ldap_set_referral_hop_limit, NULL, OR_AUTHCFG, "Limit the number of referral hops that LDAP can follow. " - "(Integer value, default=5)"), + "(Integer value, default=" AP_LDAP_DEFAULT_HOPLIMIT_STR ")"), {NULL} }; -- 2.40.0