~ubuntu-branches/ubuntu/maverick/openldap/maverick-proposed

« back to all changes in this revision

Viewing changes to servers/slapd/config.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-09-07 13:41:10 UTC
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: james.westby@ubuntu.com-20090907134110-jsdrvn0atu1fex4m
Tags: upstream-2.4.18
ImportĀ upstreamĀ versionĀ 2.4.18

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* config.c - configuration file handling routines */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/config.c,v 1.441.2.24 2009/06/02 23:41:32 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/config.c,v 1.441.2.26 2009/08/02 21:26:43 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
4
 *
5
5
 * Copyright 1998-2009 The OpenLDAP Foundation.
128
128
        int rc, arg_user, arg_type, arg_syn, iarg;
129
129
        unsigned uiarg;
130
130
        long larg;
 
131
        unsigned long ularg;
131
132
        ber_len_t barg;
132
133
        
133
134
        if(Conf->arg_type == ARG_IGNORED) {
260
261
                                        return(ARG_BAD_CONF);
261
262
                                }
262
263
                                break;
 
264
                        case ARG_ULONG:
 
265
                                if ( lutil_atoulx( &ularg, c->argv[1], 0 ) != 0 ) {
 
266
                                        snprintf( c->cr_msg, sizeof( c->cr_msg ),
 
267
                                                "<%s> unable to parse \"%s\" as unsigned long",
 
268
                                                c->argv[0], c->argv[1] );
 
269
                                        Debug(LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, "%s: %s\n",
 
270
                                                c->log, c->cr_msg, 0);
 
271
                                        return(ARG_BAD_CONF);
 
272
                                }
 
273
                                break;
263
274
                        case ARG_BER_LEN_T: {
264
275
                                unsigned long   l;
265
276
                                if ( lutil_atoulx( &l, c->argv[1], 0 ) != 0 ) {
308
319
                        case ARG_INT:           c->value_int = iarg;            break;
309
320
                        case ARG_UINT:          c->value_uint = uiarg;          break;
310
321
                        case ARG_LONG:          c->value_long = larg;           break;
 
322
                        case ARG_ULONG:         c->value_ulong = ularg;         break;
311
323
                        case ARG_BER_LEN_T:     c->value_ber_t = barg;          break;
312
324
                }
313
325
        }
359
371
                        case ARG_INT:           *(int*)ptr = c->value_int;                      break;
360
372
                        case ARG_UINT:          *(unsigned*)ptr = c->value_uint;                        break;
361
373
                        case ARG_LONG:          *(long*)ptr = c->value_long;                    break;
 
374
                        case ARG_ULONG:         *(unsigned long*)ptr = c->value_ulong;                  break;
362
375
                        case ARG_BER_LEN_T:     *(ber_len_t*)ptr = c->value_ber_t;                      break;
363
376
                        case ARG_STRING: {
364
377
                                char *cc = *(char**)ptr;
449
462
                case ARG_INT:   c->value_int = *(int *)ptr; break;
450
463
                case ARG_UINT:  c->value_uint = *(unsigned *)ptr; break;
451
464
                case ARG_LONG:  c->value_long = *(long *)ptr; break;
 
465
                case ARG_ULONG: c->value_ulong = *(unsigned long *)ptr; break;
452
466
                case ARG_BER_LEN_T:     c->value_ber_t = *(ber_len_t *)ptr; break;
453
467
                case ARG_STRING:
454
468
                        if ( *(char **)ptr )
467
481
                case ARG_INT: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%d", c->value_int); break;
468
482
                case ARG_UINT: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%u", c->value_uint); break;
469
483
                case ARG_LONG: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%ld", c->value_long); break;
 
484
                case ARG_ULONG: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%lu", c->value_ulong); break;
470
485
                case ARG_BER_LEN_T: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%ld", c->value_ber_t); break;
471
486
                case ARG_ON_OFF: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%s",
472
487
                        c->value_int ? "TRUE" : "FALSE"); break;
2111
2126
        }
2112
2127
        return rc;
2113
2128
}
 
2129
 
 
2130
/* See if the given URL (in plain and parsed form) matches
 
2131
 * any of the server's listener addresses. Return matching
 
2132
 * Listener or NULL for no match.
 
2133
 */
 
2134
Listener *config_check_my_url( const char *url, LDAPURLDesc *lud )
 
2135
{
 
2136
        Listener **l = slapd_get_listeners();
 
2137
        int i, isMe;
 
2138
 
 
2139
        /* Try a straight compare with Listener strings */
 
2140
        for ( i=0; l && l[i]; i++ ) {
 
2141
                if ( !strcasecmp( url, l[i]->sl_url.bv_val )) {
 
2142
                        return l[i];
 
2143
                }
 
2144
        }
 
2145
 
 
2146
        isMe = 0;
 
2147
        /* If hostname is empty, or is localhost, or matches
 
2148
         * our hostname, this url refers to this host.
 
2149
         * Compare it against listeners and ports.
 
2150
         */
 
2151
        if ( !lud->lud_host || !lud->lud_host[0] ||
 
2152
                !strncasecmp("localhost", lud->lud_host,
 
2153
                        STRLENOF("localhost")) ||
 
2154
                !strcasecmp( global_host, lud->lud_host )) {
 
2155
 
 
2156
                for ( i=0; l && l[i]; i++ ) {
 
2157
                        LDAPURLDesc *lu2;
 
2158
                        ldap_url_parse( l[i]->sl_url.bv_val, &lu2 );
 
2159
                        do {
 
2160
                                if ( strcasecmp( lud->lud_scheme,
 
2161
                                        lu2->lud_scheme ))
 
2162
                                        break;
 
2163
                                if ( lud->lud_port != lu2->lud_port )
 
2164
                                        break;
 
2165
                                /* Listener on ANY address */
 
2166
                                if ( !lu2->lud_host || !lu2->lud_host[0] ) {
 
2167
                                        isMe = 1;
 
2168
                                        break;
 
2169
                                }
 
2170
                                /* URL on ANY address */
 
2171
                                if ( !lud->lud_host || !lud->lud_host[0] ) {
 
2172
                                        isMe = 1;
 
2173
                                        break;
 
2174
                                }
 
2175
                                /* Listener has specific host, must
 
2176
                                 * match it
 
2177
                                 */
 
2178
                                if ( !strcasecmp( lud->lud_host,
 
2179
                                        lu2->lud_host )) {
 
2180
                                        isMe = 1;
 
2181
                                        break;
 
2182
                                }
 
2183
                        } while(0);
 
2184
                        ldap_free_urldesc( lu2 );
 
2185
                        if ( isMe ) {
 
2186
                                return l[i];
 
2187
                        }
 
2188
                }
 
2189
        }
 
2190
        return NULL;
 
2191
}