~ttx/openldap/lucid-gssapi-495418

« back to all changes in this revision

Viewing changes to servers/slapd/slapcommon.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug, Steve Langasek, Mathias Gug
  • Date: 2009-07-30 16:42:58 UTC
  • mfrom: (0.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090730164258-r282hhchgzytxm00
Tags: 2.4.17-1ubuntu1

[ Steve Langasek ]
* Fix up the lintian warnings:
  - add missing misc-depends on all packages
  - slapd, libldap-2.4-2-dbg sections changed to 'debug' to match archive
    overrides
  - bump Standards-Version to 3.8.2, no changes required.

[ Mathias Gug ]
* Resynchronise with Debian. Remaining changes:
  - AppArmor support:
    - debian/apparmor-profile: add AppArmor profile
    - updated debian/slapd.README.Debian for note on AppArmor
    - debian/slapd.dirs: add etc/apparmor.d/force-complain
    - debian/slapd.postrm: remove symlink in force-complain/ on purge
    - debian/rules: install apparmor profile.
  - Don't use local statement in config script as it fails if /bin/sh
    points to bash.
  - debian/slapd.postinst, debian/slapd.script-common: set correct
    ownership and permissions on /var/lib/ldap, /etc/ldap/slapd.d (group
    readable) and /var/run/slapd (world readable).
  - Enable nssoverlay:
    - debian/patches/nssov-build, debian/rules: Build and package the nss
      overlay.
    - debian/schema/misc.ldif: add ldif file for the misc schema which
      defines rfc822MailMember (required by the nss overlay).
  - debian/{control,rules}: enable PIE hardening
  - Use cn=config as the default configuration backend instead of
    slapd.conf. Migrate slapd.conf file to /etc/ldap/slapd.d/ on upgrade
    asking the end user to enter a new password to control the access to
    the cn=config tree.
  - debian/slapd.postinst: create /var/run/slapd before updating its
    permissions.
  - debian/slapd.init: Correctly set slapd config backend option even if
    the pidfile is configured in slapd default file.
* Dropped:
  - Merged in Debian:
    - Update priority of libldap-2.4-2 to match the archive override.
    - Add the missing ldapexop and ldapurl tools to ldap-utils, as well as
      the ldapurl(1) manpage.
    - Bump build-dependency on debhelper to 6 instead of 5, since that's
      what we're using.
    - Set the default SLAPD_SERVICES to ldap:/// ldapi:///, instead of using
      the built-in default of ldap:/// only.
  - Fixed in upstream release:
    - debian/patches/fix-ldap_back_entry_get_rwa.patch: fix test-0034
      failure when built with PIE.
    - debian/patches/gnutls-enable-v1-ca-certs: Enable V1 CA certs to be
      trusted.
  - Update Apparmor profile support: don't support upgrade from pre-hardy
    systems:
    - debian/slapd.postinst: Reload AA profile on configuration
    - debian/control: Recommends apparmor >= 2.1+1075-0ubuntu6
    - debian/control: Conflicts with apparmor-profiles <<
      2.1+1075-0ubuntu4 to make sure that if earlier version of
      apparmor-profiles gets installed it won't overwrite our profile.
    - follow ApparmorProfileMigration and force apparmor complain mode on
      some upgrades
    - debian/slapd.preinst: create symlink for force-complain on
      pre-feisty upgrades, upgrades where apparmor-profiles profile is
      unchanged (ie non-enforcing) and upgrades where apparmor profile
      does not exist.
  - debian/patches/autogen.sh: no longer needed with karmic libtool.
    - Call libtoolize with the --install option to install
      config.{guess,sub} files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* slapcommon.c - common routine for the slap tools */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/slapcommon.c,v 1.73.2.10 2009/02/06 01:03:12 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/slapcommon.c,v 1.73.2.16 2009/07/08 00:28:21 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.
80
80
 
81
81
        case SLAPCAT:
82
82
                options = " [-c]\n\t[-g] [-n databasenumber | -b suffix]"
83
 
                        " [-l ldiffile] [-a filter]\n";
 
83
                        " [-l ldiffile] [-a filter] [-s subtree]\n";
84
84
                break;
85
85
 
86
86
        case SLAPDN:
94
94
        case SLAPTEST:
95
95
                options = " [-u]\n";
96
96
                break;
 
97
 
 
98
        case SLAPSCHEMA:
 
99
                options = " [-c]\n\t[-g] [-n databasenumber | -b suffix]"
 
100
                        " [-l errorfile] [-a filter] [-s subtree]\n";
 
101
                break;
97
102
        }
98
103
 
99
104
        if ( options != NULL ) {
218
223
        char *subtree = NULL;
219
224
        char *ldiffile  = NULL;
220
225
        char **debug_unknowns = NULL;
221
 
        int rc, i, dbnum;
 
226
        int rc, i;
222
227
        int mode = SLAP_TOOL_MODE;
223
228
        int truncatemode = 0;
224
229
        int use_glue = 1;
 
230
        int writer;
225
231
 
226
232
#ifdef LDAP_DEBUG
227
233
        /* tools default to "none", so that at least LDAP_DEBUG_ANY 
228
234
         * messages show up; use -d 0 to reset */
229
235
        slap_debug = LDAP_DEBUG_NONE;
 
236
        ldif_debug = slap_debug;
230
237
#endif
231
238
        ldap_syslog = 0;
232
239
 
237
244
                leakfile = stderr;
238
245
        }
239
246
        free( leakfilename );
 
247
        leakfilename = NULL;
240
248
#endif
241
249
 
242
250
        switch( tool ) {
254
262
                mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
255
263
                break;
256
264
 
 
265
        case SLAPSCHEMA:
 
266
                options = "a:b:cd:f:F:gl:n:o:s:v";
 
267
                mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
 
268
                break;
 
269
 
257
270
        case SLAPTEST:
258
271
                options = "d:f:F:o:Quv";
259
272
                mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
353
366
                        break;
354
367
 
355
368
                case 'n':       /* which config file db to index */
356
 
                        if ( lutil_atoi( &dbnum, optarg ) ) {
 
369
                        if ( lutil_atoi( &dbnum, optarg ) || dbnum < 0 ) {
357
370
                                usage( tool, progname );
358
371
                        }
359
372
                        break;
395
408
                case 's':       /* dump subtree */
396
409
                        if ( tool == SLAPADD )
397
410
                                mode |= SLAP_TOOL_NO_SCHEMA_CHECK;
398
 
                        else if ( tool == SLAPCAT )
 
411
                        else if ( tool == SLAPCAT || tool == SLAPSCHEMA )
399
412
                                subtree = ch_strdup( optarg );
400
413
                        break;
401
414
 
447
460
#endif
448
461
#ifdef HAVE_EBCDIC
449
462
                free( logName );
 
463
                logName = NULL;
450
464
#endif
451
465
        }
452
466
#endif /* LDAP_DEBUG && LDAP_SYSLOG */
453
467
 
454
468
        switch ( tool ) {
 
469
        case SLAPCAT:
 
470
        case SLAPSCHEMA:
 
471
                writer = 1;
 
472
                break;
 
473
 
 
474
        default:
 
475
                writer = 0;
 
476
                break;
 
477
        }
 
478
 
 
479
        switch ( tool ) {
455
480
        case SLAPADD:
456
481
        case SLAPCAT:
 
482
        case SLAPSCHEMA:
457
483
                if ( ( argc != optind ) || (dbnum >= 0 && base.bv_val != NULL ) ) {
458
484
                        usage( tool, progname );
459
485
                }
500
526
        }
501
527
 
502
528
        if ( ldiffile == NULL ) {
503
 
                dummy.fp = tool == SLAPCAT ? stdout : stdin;
 
529
                dummy.fp = writer ? stdout : stdin;
504
530
                ldiffp = &dummy;
505
531
 
506
 
        } else if ((ldiffp = ldif_open( ldiffile, tool == SLAPCAT ? "w" : "r" ))
 
532
        } else if ((ldiffp = ldif_open( ldiffile, writer ? "w" : "r" ))
507
533
                == NULL )
508
534
        {
509
535
                perror( ldiffile );
552
578
        case SLAPADD:
553
579
        case SLAPCAT:
554
580
        case SLAPINDEX:
 
581
        case SLAPSCHEMA:
555
582
                if ( !nbackends ) {
556
583
                        fprintf( stderr, "No databases found "
557
584
                                        "in config file\n" );
598
625
                        fprintf( stderr, "Invalid filter '%s'\n", filterstr );
599
626
                        exit( EXIT_FAILURE );
600
627
                }
 
628
 
 
629
                ch_free( filterstr );
 
630
                filterstr = NULL;
601
631
        }
602
632
 
603
633
        if( subtree ) {
613
643
                        base = val;
614
644
                } else {
615
645
                        free( subtree );
 
646
                        subtree = NULL;
616
647
                }
617
648
        }
618
649
 
628
659
 
629
660
                be = select_backend( &nbase, 0 );
630
661
                ber_memfree( nbase.bv_val );
 
662
                BER_BVZERO( &nbase );
631
663
 
632
664
                switch ( tool ) {
633
665
                case SLAPACL:
649
681
                        nosubordinates = 1;
650
682
                }
651
683
 
 
684
                ch_free( base.bv_val );
 
685
                BER_BVZERO( &base );
 
686
 
652
687
        } else if ( dbnum == -1 ) {
653
688
                /* no suffix and no dbnum specified, just default to
654
689
                 * the first available database
689
724
                                progname, dbnum, 0 );
690
725
                }
691
726
 
692
 
        } else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
 
727
        } else if ( dbnum >= nbackends ) {
693
728
                fprintf( stderr,
694
729
                        "Database number selected via -n is out of range\n"
695
730
                        "Must be in the range 0 to %d"
696
 
                        " (number of configured databases)\n",
697
 
                        nbackends-1 );
 
731
                        " (the number of configured databases)\n",
 
732
                        nbackends - 1 );
698
733
                exit( EXIT_FAILURE );
699
734
 
700
735
        } else {
705
740
        }
706
741
 
707
742
startup:;
 
743
        if ( be ) {
 
744
                BackendDB *bdtmp;
 
745
 
 
746
                dbnum = 0;
 
747
                LDAP_STAILQ_FOREACH( bdtmp, &backendDB, be_next ) {
 
748
                        if ( bdtmp == be ) break;
 
749
                        dbnum++;
 
750
                }
 
751
        }
708
752
 
709
753
#ifdef CSRIMALLOC
710
754
        mal_leaktrace(1);
712
756
 
713
757
        if ( conffile != NULL ) {
714
758
                ch_free( conffile );
 
759
                conffile = NULL;
715
760
        }
716
761
 
717
762
        if ( ldiffile != NULL ) {
718
763
                ch_free( ldiffile );
 
764
                ldiffile = NULL;
719
765
        }
720
766
 
721
767
        /* slapdn doesn't specify a backend to startup */
770
816
 
771
817
        if ( !BER_BVISNULL( &authcDN ) ) {
772
818
                ch_free( authcDN.bv_val );
 
819
                BER_BVZERO( &authcDN );
773
820
        }
774
821
 
775
822
        if ( ldiffp && ldiffp != &dummy ) {