~ttx/openldap/lucid-gssapi-495418

« back to all changes in this revision

Viewing changes to servers/slapd/bconfig.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-07-28 10:17:15 UTC
  • mto: (0.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20090728101715-g0isvetelfeqm48k
Tags: upstream-2.4.17
ImportĀ upstreamĀ versionĀ 2.4.17

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* bconfig.c - the config backend */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/bconfig.c,v 1.202.2.59 2009/02/13 03:16:59 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/bconfig.c,v 1.202.2.68 2009/06/08 18:24:59 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
4
 *
5
5
 * Copyright 2005-2009 The OpenLDAP Foundation.
320
320
                &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
321
321
                        "EQUALITY caseIgnoreMatch "
322
322
                        "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
323
 
        { "authz-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
 
323
        { "authz-regexp", "regexp> <DN", 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
324
324
                &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
325
325
                        "EQUALITY caseIgnoreMatch "
326
326
                        "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
455
455
        { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
456
456
                &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
457
457
                        "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
458
 
        { "password-hash", "hash", 2, 2, 0, ARG_MAGIC,
 
458
        { "password-hash", "hash", 2, 0, 0, ARG_MAGIC,
459
459
                &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
460
460
                        "EQUALITY caseIgnoreMatch "
461
461
                        "SYNTAX OMsDirectoryString )", NULL, NULL },
530
530
                        "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
531
531
        { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
532
532
                &config_generic, NULL, NULL, NULL },
 
533
        { "sasl-auxprops", NULL, 2, 0, 0,
 
534
#ifdef HAVE_CYRUS_SASL
 
535
                ARG_STRING|ARG_UNIQUE, &slap_sasl_auxprops,
 
536
#else
 
537
                ARG_IGNORED, NULL,
 
538
#endif
 
539
                "( OLcfgGlAt:89 NAME 'olcSaslAuxprops' "
 
540
                        "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
533
541
        { "sasl-host", "host", 2, 2, 0,
534
542
#ifdef HAVE_CYRUS_SASL
535
543
                ARG_STRING|ARG_UNIQUE, &sasl_host,
706
714
                &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
707
715
                        "EQUALITY caseIgnoreMatch "
708
716
                        "SUP labeledURI )", NULL, NULL },
 
717
        { "writetimeout", "timeout", 2, 2, 0, ARG_INT,
 
718
                &global_writetimeout, "( OLcfgGlAt:88 NAME 'olcWriteTimeout' "
 
719
                        "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
709
720
        { NULL, NULL, 0, 0, 0, ARG_IGNORED,
710
721
                NULL, NULL, NULL, NULL }
711
722
};
757
768
                 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
758
769
                 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
759
770
                 "olcRootDSE $ "
760
 
                 "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
 
771
                 "olcSaslAuxprops $ olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
761
772
                 "olcSecurity $ olcServerID $ olcSizeLimit $ "
762
773
                 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ "
763
774
                 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
764
775
                 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
765
776
                 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
766
777
                 "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFile $ "
767
 
                 "olcTLSCRLFile $ olcToolThreads $ "
 
778
                 "olcTLSCRLFile $ olcToolThreads $ olcWriteTimeout $ "
768
779
                 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
769
780
                 "olcDitContentRules $ olcLdapSyntaxes ) )", Cft_Global },
770
781
        { "( OLcfgGlOc:2 "
893
904
                        if ( !c->rvalue_vals ) rc = 1;
894
905
                        break;
895
906
                case CFG_RO:
896
 
                        c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_OP_WRITES) ==
897
 
                                SLAP_RESTRICT_OP_WRITES;
 
907
                        c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_READONLY);
898
908
                        break;
899
909
                case CFG_AZPOLICY:
900
910
                        c->value_string = ch_strdup( slap_sasl_getpolicy());
1378
1388
 
1379
1389
                case CFG_LIMITS:
1380
1390
                        /* FIXME: there is no limits_free function */
 
1391
                        if ( c->valx < 0 ) {
 
1392
                                limits_destroy( c->be->be_limits );
 
1393
                                c->be->be_limits = NULL;
 
1394
 
 
1395
                        } else {
 
1396
                                int cnt, num = -1;
 
1397
 
 
1398
                                if ( c->be->be_limits ) {
 
1399
                                        for ( num = 0; c->be->be_limits[ num ]; num++ )
 
1400
                                                /* just count */ ;
 
1401
                                }
 
1402
 
 
1403
                                if ( c->valx >= num ) {
 
1404
                                        return 1;
 
1405
                                }
 
1406
 
 
1407
                                if ( num == 1 ) {
 
1408
                                        limits_destroy( c->be->be_limits );
 
1409
                                        c->be->be_limits = NULL;
 
1410
 
 
1411
                                } else {
 
1412
                                        limits_free_one( c->be->be_limits[ c->valx ] );
 
1413
 
 
1414
                                        for ( cnt = c->valx; cnt < num; cnt++ ) {
 
1415
                                                c->be->be_limits[ cnt ] = c->be->be_limits[ cnt + 1 ];
 
1416
                                        }
 
1417
                                }
 
1418
                        }
 
1419
                        break;
 
1420
 
1381
1421
                case CFG_ATOPT:
1382
1422
                        /* FIXME: there is no ad_option_free function */
1383
1423
                case CFG_ROOTDSE:
1466
1506
 
1467
1507
                case CFG_RO:
1468
1508
                        if(c->value_int)
1469
 
                                c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
 
1509
                                c->be->be_restrictops |= SLAP_RESTRICT_READONLY;
1470
1510
                        else
1471
 
                                c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
 
1511
                                c->be->be_restrictops &= ~SLAP_RESTRICT_READONLY;
1472
1512
                        break;
1473
1513
 
1474
1514
                case CFG_AZPOLICY:
2887
2927
                int     level;
2888
2928
 
2889
2929
                if ( isdigit((unsigned char)c->argv[i][0]) || c->argv[i][0] == '-' ) {
2890
 
                        if( lutil_atoi( &level, c->argv[i] ) != 0 ) {
 
2930
                        if( lutil_atoix( &level, c->argv[i], 0 ) != 0 ) {
2891
2931
                                snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse level", c->argv[0] );
2892
2932
                                Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2893
2933
                                        c->log, c->cr_msg, c->argv[i]);
3191
3231
 
3192
3232
#ifdef HAVE_TLS
3193
3233
static int
 
3234
config_tls_cleanup(ConfigArgs *c) {
 
3235
        int rc = 0;
 
3236
 
 
3237
        if ( slap_tls_ld ) {
 
3238
                int opt = 1;
 
3239
 
 
3240
                ldap_pvt_tls_ctx_free( slap_tls_ctx );
 
3241
 
 
3242
                /* Force new ctx to be created */
 
3243
                rc = ldap_pvt_tls_set_option( slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
 
3244
                if( rc == 0 ) {
 
3245
                        /* The ctx's refcount is bumped up here */
 
3246
                        ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
 
3247
                        /* This is a no-op if it's already loaded */
 
3248
                        load_extop( &slap_EXOP_START_TLS, 0, starttls_extop );
 
3249
                }
 
3250
        }
 
3251
        return rc;
 
3252
}
 
3253
 
 
3254
static int
3194
3255
config_tls_option(ConfigArgs *c) {
3195
3256
        int flag;
3196
3257
        LDAP *ld = slap_tls_ld;
3213
3274
        if (c->op == SLAP_CONFIG_EMIT) {
3214
3275
                return ldap_pvt_tls_get_option( ld, flag, &c->value_string );
3215
3276
        } else if ( c->op == LDAP_MOD_DELETE ) {
 
3277
                c->cleanup = config_tls_cleanup;
3216
3278
                return ldap_pvt_tls_set_option( ld, flag, NULL );
3217
3279
        }
3218
3280
        ch_free(c->value_string);
 
3281
        c->cleanup = config_tls_cleanup;
3219
3282
        return(ldap_pvt_tls_set_option(ld, flag, c->argv[1]));
3220
3283
}
3221
3284
 
3237
3300
                return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
3238
3301
        } else if ( c->op == LDAP_MOD_DELETE ) {
3239
3302
                int i = 0;
 
3303
                c->cleanup = config_tls_cleanup;
3240
3304
                return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
3241
3305
        }
3242
3306
        ch_free( c->value_string );
 
3307
        c->cleanup = config_tls_cleanup;
3243
3308
        if ( isdigit( (unsigned char)c->argv[1][0] ) ) {
3244
3309
                if ( lutil_atoi( &i, c->argv[1] ) != 0 ) {
3245
3310
                        Debug(LDAP_DEBUG_ANY, "%s: "
4718
4783
                }
4719
4784
        }
4720
4785
 
 
4786
        if ( op->o_abandon ) {
 
4787
                rs->sr_err = SLAPD_ABANDON;
 
4788
                goto out;
 
4789
        }
4721
4790
        ldap_pvt_thread_pool_pause( &connection_pool );
4722
4791
 
4723
4792
        /* Strategy:
5158
5227
 
5159
5228
        slap_mods_opattrs( op, &op->orm_modlist, 1 );
5160
5229
 
5161
 
        if ( do_pause )
 
5230
        if ( do_pause ) {
 
5231
                if ( op->o_abandon ) {
 
5232
                        rs->sr_err = SLAPD_ABANDON;
 
5233
                        goto out;
 
5234
                }
5162
5235
                ldap_pvt_thread_pool_pause( &connection_pool );
 
5236
        }
5163
5237
 
5164
5238
        /* Strategy:
5165
5239
         * 1) perform the Modify on the cached Entry.
5323
5397
                goto out;
5324
5398
        }
5325
5399
 
 
5400
        if ( op->o_abandon ) {
 
5401
                rs->sr_err = SLAPD_ABANDON;
 
5402
                goto out;
 
5403
        }
5326
5404
        ldap_pvt_thread_pool_pause( &connection_pool );
5327
5405
 
5328
5406
        if ( ce->ce_type == Cft_Schema ) {
5412
5490
                rs->sr_err = LDAP_NO_SUCH_OBJECT;
5413
5491
        } else if ( ce->ce_kids ) {
5414
5492
                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
 
5493
        } else if ( op->o_abandon ) {
 
5494
                rs->sr_err = SLAPD_ABANDON;
5415
5495
        } else if ( ce->ce_type == Cft_Overlay ){
5416
5496
                char *iptr;
5417
5497
                int count, ixold;