~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/libsvn_wc/questions.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
  apr_hash_t *keywords;
118
118
  svn_boolean_t special = FALSE;
119
119
  svn_boolean_t need_translation;
 
120
  svn_stream_t *v_stream; /* versioned_file */
120
121
 
121
122
  SVN_ERR_ASSERT(svn_dirent_is_absolute(versioned_file_abspath));
122
123
 
150
151
 
151
152
  /* ### Other checks possible? */
152
153
 
153
 
  if (need_translation)
154
 
    {
155
 
      /* Reading files is necessary. */
156
 
      svn_stream_t *v_stream;  /* versioned_file */
157
 
 
158
 
      if (special)
159
 
        {
160
 
          SVN_ERR(svn_subst_read_specialfile(&v_stream, versioned_file_abspath,
161
 
                                             scratch_pool, scratch_pool));
162
 
        }
163
 
      else
164
 
        {
165
 
          SVN_ERR(svn_stream_open_readonly(&v_stream, versioned_file_abspath,
166
 
                                           scratch_pool, scratch_pool));
167
 
 
168
 
          if (!exact_comparison && need_translation)
 
154
  /* Reading files is necessary. */
 
155
  if (special && need_translation)
 
156
    {
 
157
      SVN_ERR(svn_subst_read_specialfile(&v_stream, versioned_file_abspath,
 
158
                                          scratch_pool, scratch_pool));
 
159
    }
 
160
  else
 
161
    {
 
162
      /* We don't use APR-level buffering because the comparison function
 
163
       * will do its own buffering. */
 
164
      apr_file_t *file;
 
165
      SVN_ERR(svn_io_file_open(&file, versioned_file_abspath, APR_READ,
 
166
                               APR_OS_DEFAULT, scratch_pool));
 
167
      v_stream = svn_stream_from_aprfile2(file, FALSE, scratch_pool);
 
168
 
 
169
      if (need_translation)
 
170
        {
 
171
          if (!exact_comparison)
169
172
            {
170
173
              if (eol_style == svn_subst_eol_style_native)
171
174
                eol_str = SVN_SUBST_NATIVE_EOL_STR;
183
186
                                                     FALSE /* expand */,
184
187
                                                     scratch_pool);
185
188
            }
186
 
          else if (need_translation)
 
189
          else
187
190
            {
188
191
              /* Wrap base stream to translate into working copy form, and
189
192
               * arrange to throw an error if its EOL style is inconsistent. */
193
196
                                                            scratch_pool);
194
197
            }
195
198
        }
196
 
 
197
 
      SVN_ERR(svn_stream_contents_same2(&same, pristine_stream, v_stream,
198
 
                                        scratch_pool));
199
 
    }
200
 
  else
201
 
    {
202
 
      /* Translation would be a no-op, so compare the original file. */
203
 
      svn_stream_t *v_stream;  /* versioned_file */
204
 
 
205
 
      SVN_ERR(svn_stream_open_readonly(&v_stream, versioned_file_abspath,
206
 
                                       scratch_pool, scratch_pool));
207
 
 
208
 
      SVN_ERR(svn_stream_contents_same2(&same, pristine_stream, v_stream,
209
 
                                        scratch_pool));
210
 
    }
 
199
    }
 
200
 
 
201
  SVN_ERR(svn_stream_contents_same2(&same, pristine_stream, v_stream,
 
202
                                    scratch_pool));
211
203
 
212
204
  *modified_p = (! same);
213
205
 
377
369
  svn_boolean_t resolved_text = FALSE;
378
370
  svn_boolean_t resolved_props = FALSE;
379
371
 
380
 
  SVN_ERR(svn_wc__db_read_conflict(&conflicts, db, local_abspath,
 
372
  SVN_ERR(svn_wc__db_read_conflict(&conflicts, NULL, NULL,
 
373
                                   db, local_abspath,
381
374
                                   scratch_pool, scratch_pool));
382
375
 
383
376
  if (!conflicts)
604
597
}
605
598
 
606
599
 
 
600
/* A baton for use with modcheck_found_entry(). */
 
601
typedef struct modcheck_baton_t {
 
602
  svn_boolean_t ignore_unversioned;
 
603
  svn_boolean_t found_mod;  /* whether a modification has been found */
 
604
  svn_boolean_t found_not_delete;  /* Found a not-delete modification */
 
605
} modcheck_baton_t;
 
606
 
 
607
/* An implementation of svn_wc_status_func4_t. */
 
608
static svn_error_t *
 
609
modcheck_callback(void *baton,
 
610
                  const char *local_abspath,
 
611
                  const svn_wc_status3_t *status,
 
612
                  apr_pool_t *scratch_pool)
 
613
{
 
614
  modcheck_baton_t *mb = baton;
 
615
 
 
616
  switch (status->node_status)
 
617
    {
 
618
      case svn_wc_status_normal:
 
619
      case svn_wc_status_ignored:
 
620
      case svn_wc_status_none:
 
621
      case svn_wc_status_external:
 
622
        break;
 
623
 
 
624
      case svn_wc_status_incomplete:
 
625
        if ((status->text_status != svn_wc_status_normal
 
626
             && status->text_status != svn_wc_status_none)
 
627
            || (status->prop_status != svn_wc_status_normal
 
628
                && status->prop_status != svn_wc_status_none))
 
629
          {
 
630
            mb->found_mod = TRUE;
 
631
            mb->found_not_delete = TRUE;
 
632
            /* Incomplete, but local modifications */
 
633
            return svn_error_create(SVN_ERR_CEASE_INVOCATION, NULL, NULL);
 
634
          }
 
635
        break;
 
636
 
 
637
      case svn_wc_status_deleted:
 
638
        mb->found_mod = TRUE;
 
639
        if (!mb->ignore_unversioned
 
640
            && status->actual_kind != svn_node_none
 
641
            && status->actual_kind != svn_node_unknown)
 
642
          {
 
643
            /* The delete is obstructed by something unversioned */
 
644
            mb->found_not_delete = TRUE;
 
645
            return svn_error_create(SVN_ERR_CEASE_INVOCATION, NULL, NULL);
 
646
          }
 
647
        break;
 
648
 
 
649
      case svn_wc_status_unversioned:
 
650
        if (mb->ignore_unversioned)
 
651
          break;
 
652
        /* else fall through */
 
653
      case svn_wc_status_missing:
 
654
      case svn_wc_status_obstructed:
 
655
        mb->found_mod = TRUE;
 
656
        mb->found_not_delete = TRUE;
 
657
        /* Exit from the status walker: We know what we want to know */
 
658
        return svn_error_create(SVN_ERR_CEASE_INVOCATION, NULL, NULL);
 
659
 
 
660
      default:
 
661
      case svn_wc_status_added:
 
662
      case svn_wc_status_replaced:
 
663
      case svn_wc_status_modified:
 
664
        mb->found_mod = TRUE;
 
665
        mb->found_not_delete = TRUE;
 
666
        /* Exit from the status walker: We know what we want to know */
 
667
        return svn_error_create(SVN_ERR_CEASE_INVOCATION, NULL, NULL);
 
668
    }
 
669
 
 
670
  return SVN_NO_ERROR;
 
671
}
 
672
 
 
673
 
 
674
/* Set *MODIFIED to true iff there are any local modifications within the
 
675
 * tree rooted at LOCAL_ABSPATH, using DB. If *MODIFIED
 
676
 * is set to true and all the local modifications were deletes then set
 
677
 * *ALL_EDITS_ARE_DELETES to true, set it to false otherwise.  LOCAL_ABSPATH
 
678
 * may be a file or a directory. */
 
679
svn_error_t *
 
680
svn_wc__node_has_local_mods(svn_boolean_t *modified,
 
681
                            svn_boolean_t *all_edits_are_deletes,
 
682
                            svn_wc__db_t *db,
 
683
                            const char *local_abspath,
 
684
                            svn_boolean_t ignore_unversioned,
 
685
                            svn_cancel_func_t cancel_func,
 
686
                            void *cancel_baton,
 
687
                            apr_pool_t *scratch_pool)
 
688
{
 
689
  modcheck_baton_t modcheck_baton = { FALSE, FALSE, FALSE };
 
690
  svn_error_t *err;
 
691
 
 
692
  if (!all_edits_are_deletes)
 
693
    {
 
694
      SVN_ERR(svn_wc__db_has_db_mods(modified, db, local_abspath,
 
695
                                     scratch_pool));
 
696
 
 
697
      if (*modified)
 
698
        return SVN_NO_ERROR;
 
699
    }
 
700
 
 
701
  modcheck_baton.ignore_unversioned = ignore_unversioned;
 
702
 
 
703
  /* Walk the WC tree for status with depth infinity, looking for any local
 
704
   * modifications. If it's a "sparse" directory, that's OK: there can be
 
705
   * no local mods in the pieces that aren't present in the WC. */
 
706
 
 
707
  err = svn_wc__internal_walk_status(db, local_abspath,
 
708
                                     svn_depth_infinity,
 
709
                                     FALSE, FALSE, FALSE, NULL,
 
710
                                     modcheck_callback, &modcheck_baton,
 
711
                                     cancel_func, cancel_baton,
 
712
                                     scratch_pool);
 
713
 
 
714
  if (err && err->apr_err == SVN_ERR_CEASE_INVOCATION)
 
715
    svn_error_clear(err);
 
716
  else
 
717
    SVN_ERR(err);
 
718
 
 
719
  *modified = modcheck_baton.found_mod;
 
720
  if (all_edits_are_deletes)
 
721
    *all_edits_are_deletes = (modcheck_baton.found_mod
 
722
                              && !modcheck_baton.found_not_delete);
 
723
 
 
724
  return SVN_NO_ERROR;
 
725
}
 
726
 
607
727
svn_error_t *
608
728
svn_wc__has_local_mods(svn_boolean_t *is_modified,
609
729
                       svn_wc_context_t *wc_ctx,
610
730
                       const char *local_abspath,
 
731
                       svn_boolean_t ignore_unversioned,
611
732
                       svn_cancel_func_t cancel_func,
612
733
                       void *cancel_baton,
613
734
                       apr_pool_t *scratch_pool)
614
735
{
615
 
  return svn_error_trace(svn_wc__db_has_local_mods(is_modified,
616
 
                                                   wc_ctx->db,
617
 
                                                   local_abspath,
618
 
                                                   cancel_func,
619
 
                                                   cancel_baton,
620
 
                                                   scratch_pool));
 
736
  svn_boolean_t modified;
 
737
 
 
738
  SVN_ERR(svn_wc__node_has_local_mods(&modified, NULL,
 
739
                                      wc_ctx->db, local_abspath,
 
740
                                      ignore_unversioned,
 
741
                                      cancel_func, cancel_baton,
 
742
                                      scratch_pool));
 
743
 
 
744
  *is_modified = modified;
 
745
  return SVN_NO_ERROR;
621
746
}