~ubuntu-branches/ubuntu/utopic/389-ds-base/utopic-proposed

« back to all changes in this revision

Viewing changes to ldap/servers/slapd/dse.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2014-02-03 11:08:50 UTC
  • mfrom: (0.2.1)
  • Revision ID: package-import@ubuntu.com-20140203110850-tjzx85elnke9fiu3
Tags: 1.3.2.9-1
* New upstream release.
  - fixes CVE-2013-0336 (Closes: #704077)
  - fixes CVE-2013-1897 (Closes: #704421)
  - fixes CVE-2013-2219 (Closes: #718325)
  - fixes CVE-2013-4283 (Closes: #721222)
  - fixes CVE-2013-4485 (Closes: #730115)
* Drop fix-CVE-2013-0312.diff, upstream.
* rules: Add new scripts to rename.
* fix-sasl-path.diff: Use a triplet path to find libsasl2. (LP:
  #1088822)
* admin_scripts.diff: Add patch from upstream #47511 to fix bashisms.
* control: Add ldap-utils to -base depends.
* rules, rename-online-scripts.diff: Some scripts with .pl suffix are
  meant for an online server, so instead of overwriting the offline
  scripts use -online suffix.
* rules: Enable parallel build, but limit the jobs to 1 for
  dh_auto_install.
* control: Bump policy to 3.9.5, no changes.
* rules: Add get-orig-source target.
* lintian-overrides: Drop obsolete entries, add comments for the rest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
#define SLAPI_DSE_TRACELEVEL    LDAP_DEBUG_TRACE
82
82
#endif /* SLAPI_DSE_DEBUG */
83
83
 
 
84
#define SCHEMA_VIOLATION -2
84
85
#define STOP_TRAVERSAL -2
85
86
 
86
87
/* This is returned by dupentry_replace if the duplicate entry was found and
610
611
        struct berval val;
611
612
        vals[0] = &val;
612
613
        vals[1] = NULL;
613
 
        sprintf(value_buffer,"%lu",current_sub_count);
 
614
        sprintf(value_buffer,"%lu",(long unsigned int)current_sub_count);
614
615
        val.bv_val = value_buffer;
615
616
        val.bv_len = strlen (val.bv_val);
616
617
        switch(mod_op)
659
660
dse_check_file(char *filename, char *backupname)
660
661
{
661
662
    int rc= 0; /* Fail */
662
 
    PRFileInfo prfinfo;
 
663
    PRFileInfo64 prfinfo;
663
664
 
664
 
    if (PR_GetFileInfo( filename, &prfinfo ) == PR_SUCCESS) {
 
665
    if (PR_GetFileInfo64( filename, &prfinfo ) == PR_SUCCESS) {
665
666
        if ( prfinfo.size > 0)
666
667
                return (1);
667
668
        else {
674
675
    else 
675
676
        return (0);
676
677
 
677
 
    if ( PR_GetFileInfo( filename, &prfinfo ) == PR_SUCCESS && prfinfo.size > 0 ) {
 
678
    if ( PR_GetFileInfo64( filename, &prfinfo ) == PR_SUCCESS && prfinfo.size > 0 ) {
678
679
        slapi_log_error(SLAPI_LOG_FATAL, "dse",
679
680
             "The configuration file %s was restored from backup %s\n", filename, backupname);
680
681
        return (1);
695
696
    char *lastp = NULL;
696
697
    int rc= 0; /* Fail */
697
698
    PRInt32 nr = 0;
698
 
    PRFileInfo prfinfo;
 
699
    PRFileInfo64 prfinfo;
699
700
    PRFileDesc *prfd = 0;
700
701
    int schema_flags = 0;
701
702
 
704
705
    if ( (NULL != pdse) && (NULL != filename) )
705
706
    {
706
707
        /* check if the "real" file exists and cam be used, if not try tmp as backup */
707
 
        rc = dse_check_file((char *)filename, pdse->dse_tmpfile);
708
 
        if (!rc) 
709
 
            rc = dse_check_file((char *)filename, pdse->dse_fileback);
 
708
        rc = dse_check_file((char *)filename, pdse->dse_tmpfile);
 
709
        if (!rc)
 
710
            rc = dse_check_file((char *)filename, pdse->dse_fileback);
710
711
 
711
 
        if ( (rc = PR_GetFileInfo( filename, &prfinfo )) != PR_SUCCESS )
 
712
        if ( (rc = PR_GetFileInfo64( filename, &prfinfo )) != PR_SUCCESS )
712
713
        {
713
714
            slapi_log_error(SLAPI_LOG_FATAL, "dse",
714
715
                            "The configuration file %s could not be accessed, error %d\n",
732
733
            if (( nr = slapi_read_buffer( prfd, buf, prfinfo.size )) < 0 )
733
734
            {
734
735
                slapi_log_error(SLAPI_LOG_FATAL, "dse",
735
 
                                "Could only read %d of %d bytes from config file %s\n",
736
 
                                nr, prfinfo.size, filename);
 
736
                                "Could only read %d of %ld bytes from config file %s\n",
 
737
                                nr, (long int)prfinfo.size, filename);
737
738
                rc = 0; /* Fail */
738
739
                done= 1;
739
740
            }
799
800
                                    DSE_FLAG_PREOP, e, NULL, &returncode,
800
801
                                    returntext) == SLAPI_DSE_CALLBACK_OK)
801
802
                        {
802
 
                            /* this will free the entry if not added, so it is
803
 
                               definitely consumed by this call */
804
 
                            dse_add_entry_pb(pdse, e, pb);
 
803
                            /*
 
804
                             * This will free the entry if not added, so it is
 
805
                             * definitely consumed by this call
 
806
                             */
 
807
                            if(dse_add_entry_pb(pdse, e, pb) == SCHEMA_VIOLATION){
 
808
                                /* schema violation, return failure */
 
809
                                rc = 0;
 
810
                            }
805
811
                        }
806
812
                        else /* free entry if not used */
807
813
                        {
1119
1125
  
1120
1126
/*
1121
1127
 * Adds an entry to the dse backend.  The passed in entry will be
1122
 
 * free'd always. */
 
1128
 * free'd always.
 
1129
 *
 
1130
 * return -1 for duplicate entry
 
1131
 * return -2 for schema violation (SCHEMA_VIOLATION)
 
1132
 */
1123
1133
static int
1124
1134
dse_add_entry_pb(struct dse* pdse, Slapi_Entry *e, Slapi_PBlock *pb)
1125
1135
{
1190
1200
                 * Verify that the new or merged entry conforms to the schema.
1191
1201
                 *              Errors are logged by slapi_entry_schema_check().
1192
1202
                 */
1193
 
                (void)slapi_entry_schema_check( pb, schemacheckentry );
 
1203
                if(slapi_entry_schema_check( pb, schemacheckentry )){
 
1204
                        rc = SCHEMA_VIOLATION;
 
1205
                }
1194
1206
                slapi_entry_free(schemacheckentry);
1195
1207
        }
1196
1208