add a switch that enables/disables reverse lookups if configured with rlookups

This commit is contained in:
Pierangelo Masarati 2002-04-03 15:40:49 +00:00
parent b0b8546f05
commit f4dba925ff
3 changed files with 69 additions and 108 deletions

View file

@ -59,6 +59,12 @@ int nSaslRegexp = 0;
SaslRegexp_t *SaslRegexp = NULL; SaslRegexp_t *SaslRegexp = NULL;
int sasl_external_x509dn_convert; int sasl_external_x509dn_convert;
#ifdef SLAPD_RLOOKUPS
int use_reverse_lookup = 1;
#else /* !SLAPD_RLOOKUPS */
int use_reverse_lookup = 0;
#endif /* !SLAPD_RLOOKUPS */
static char *fp_getline(FILE *fp, int *lineno); static char *fp_getline(FILE *fp, int *lineno);
static void fp_getline_init(int *lineno); static void fp_getline_init(int *lineno);
static int fp_parse_line(char *line, int *argcp, char **argv); static int fp_parse_line(char *line, int *argcp, char **argv);
@ -2240,6 +2246,54 @@ read_config( const char *fname )
#endif #endif
} else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
#ifdef SLAPD_RLOOKUPS
if ( cargc < 2 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_INFO,
"%s: line %d: reverse-lookup: "
"missing \"on\" or \"off\"\n",
fname, lineno ));
#else
Debug( LDAP_DEBUG_ANY,
"%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
fname, lineno, 0 );
#endif
return( 1 );
}
if ( !strcasecmp( cargv[1], "on" ) ) {
use_reverse_lookup = 1;
} else if ( !strcasecmp( cargv[1], "off" ) ) {
use_reverse_lookup = 0;
} else {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_INFO,
"%s: line %d: reverse-lookup: "
"must be \"on\" (default) "
"or \"off\"\n",
fname, lineno ));
#else
Debug( LDAP_DEBUG_ANY,
"%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
fname, lineno, 0 );
#endif
return( 1 );
}
#else /* !SLAPD_RLOOKUPS */
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_INFO,
"%s: line %d: reverse lookups "
"are not configured (ignored).\n",
fname, lineno ));
#else
Debug( LDAP_DEBUG_ANY,
"%s: line %d: reverse lookups are not configured (ignored).\n",
fname, lineno, 0 );
#endif
#endif /* !SLAPD_RLOOKUPS */
/* pass anything else to the current backend info/db config routine */ /* pass anything else to the current backend info/db config routine */
} else { } else {
if ( bi != NULL ) { if ( bi != NULL ) {

View file

@ -330,102 +330,6 @@ static int get_url_perms(
if ( strncasecmp( type, LDAPI_MOD_URLEXT "=", sizeof(LDAPI_MOD_URLEXT "=") - 1 ) == 0 ) { if ( strncasecmp( type, LDAPI_MOD_URLEXT "=", sizeof(LDAPI_MOD_URLEXT "=") - 1 ) == 0 ) {
char *value = type + sizeof(LDAPI_MOD_URLEXT "=") - 1; char *value = type + sizeof(LDAPI_MOD_URLEXT "=") - 1;
mode_t p = 0; mode_t p = 0;
#if 0
if ( strlen( value ) != 9 ) {
return LDAP_OTHER;
}
switch ( value[ 0 ] ) {
case 'r':
p |= S_IRUSR;
break;
case '-':
break;
default:
return LDAP_OTHER;
}
switch ( value[ 1 ] ) {
case 'w':
p |= S_IWUSR;
break;
case '-':
break;
default:
return LDAP_OTHER;
}
switch ( value[ 2 ] ) {
case 'x':
p |= S_IXUSR;
break;
case '-':
break;
default:
return LDAP_OTHER;
}
switch ( value[ 3 ] ) {
case 'r':
p |= S_IRGRP;
break;
case '-':
break;
default:
return LDAP_OTHER;
}
switch ( value[ 4 ] ) {
case 'w':
p |= S_IWGRP;
break;
case '-':
break;
default:
return LDAP_OTHER;
}
switch ( value[ 5 ] ) {
case 'x':
p |= S_IXGRP;
break;
case '-':
break;
default:
return LDAP_OTHER;
}
switch ( value[ 6 ] ) {
case 'r':
p |= S_IROTH;
break;
case '-':
break;
default:
return LDAP_OTHER;
}
switch ( value[ 7 ] ) {
case 'w':
p |= S_IWOTH;
break;
case '-':
break;
default:
return LDAP_OTHER;
}
switch ( value[ 8 ] ) {
case 'x':
p |= S_IXOTH;
break;
case '-':
break;
default:
return LDAP_OTHER;
}
#else
int j; int j;
if ( strlen(value) != 3 ) { if ( strlen(value) != 3 ) {
@ -446,7 +350,6 @@ static int get_url_perms(
return LDAP_OTHER; return LDAP_OTHER;
} }
} }
#endif
*crit = c; *crit = c;
*perms = p; *perms = p;
@ -1518,6 +1421,7 @@ slapd_daemon_task(
#endif #endif
) { ) {
#ifdef SLAPD_RLOOKUPS #ifdef SLAPD_RLOOKUPS
if ( use_reverse_lookup ) {
# ifdef LDAP_PF_INET6 # ifdef LDAP_PF_INET6
if ( from.sa_addr.sa_family == AF_INET6 ) if ( from.sa_addr.sa_family == AF_INET6 )
hp = gethostbyaddr( hp = gethostbyaddr(
@ -1531,6 +1435,7 @@ slapd_daemon_task(
sizeof(from.sa_in_addr.sin_addr), sizeof(from.sa_in_addr.sin_addr),
AF_INET ); AF_INET );
dnsname = hp ? ldap_pvt_str2lower( hp->h_name ) : NULL; dnsname = hp ? ldap_pvt_str2lower( hp->h_name ) : NULL;
}
#else #else
dnsname = NULL; dnsname = NULL;
#endif /* SLAPD_RLOOKUPS */ #endif /* SLAPD_RLOOKUPS */

View file

@ -1039,6 +1039,8 @@ LDAP_SLAPD_V (AccessControl *) global_acl;
LDAP_SLAPD_V (ber_socket_t) dtblsize; LDAP_SLAPD_V (ber_socket_t) dtblsize;
LDAP_SLAPD_V (int) use_reverse_lookup;
/* /*
* operations * operations
*/ */