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

« back to all changes in this revision

Viewing changes to subversion/libsvn_client/commit_util.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:
40
40
#include "svn_hash.h"
41
41
 
42
42
#include <assert.h>
43
 
#include <stdlib.h>  /* for qsort() */
44
43
 
45
44
#include "svn_private_config.h"
46
45
#include "private/svn_wc_private.h"
47
46
#include "private/svn_client_private.h"
 
47
#include "private/svn_sorts_private.h"
48
48
 
49
49
/*** Uncomment this to turn on commit driver debugging. ***/
50
50
/*
62
62
                   apr_pool_t *scratch_pool)
63
63
{
64
64
  if (err->apr_err == SVN_ERR_FS_NOT_FOUND
 
65
      || err->apr_err == SVN_ERR_FS_CONFLICT
65
66
      || err->apr_err == SVN_ERR_FS_ALREADY_EXISTS
66
67
      || err->apr_err == SVN_ERR_FS_TXN_OUT_OF_DATE
67
68
      || err->apr_err == SVN_ERR_RA_DAV_PATH_NOT_FOUND
68
69
      || err->apr_err == SVN_ERR_RA_DAV_ALREADY_EXISTS
 
70
      || err->apr_err == SVN_ERR_RA_DAV_PRECONDITION_FAILED
69
71
      || svn_error_find_cause(err, SVN_ERR_RA_OUT_OF_DATE))
70
72
    {
71
73
      if (ctx->notify_func2)
102
104
    }
103
105
  else if (svn_error_find_cause(err, SVN_ERR_FS_NO_LOCK_TOKEN)
104
106
           || err->apr_err == SVN_ERR_FS_LOCK_OWNER_MISMATCH
 
107
           || err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN
105
108
           || err->apr_err == SVN_ERR_RA_NOT_LOCKED)
106
109
    {
107
110
      if (ctx->notify_func2)
464
467
  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
465
468
  int i;
466
469
 
 
470
  SVN_ERR_ASSERT(commit_relpath != NULL);
 
471
 
467
472
  /* A function to retrieve not present children would be nice to have */
468
 
  SVN_ERR(svn_wc__node_get_children_of_working_node(
469
 
                                    &children, wc_ctx, local_abspath, TRUE,
470
 
                                    scratch_pool, iterpool));
 
473
  SVN_ERR(svn_wc__node_get_not_present_children(&children, wc_ctx,
 
474
                                                local_abspath,
 
475
                                                scratch_pool, iterpool));
471
476
 
472
477
  for (i = 0; i < children->nelts; i++)
473
478
    {
483
488
                                          this_abspath, FALSE, scratch_pool));
484
489
 
485
490
      if (!not_present)
486
 
        continue;
 
491
        continue; /* Node is replaced */
487
492
 
488
 
      if (commit_relpath == NULL)
489
 
        this_commit_relpath = NULL;
490
 
      else
491
 
        this_commit_relpath = svn_relpath_join(commit_relpath, name,
492
 
                                              iterpool);
 
493
      this_commit_relpath = svn_relpath_join(commit_relpath, name,
 
494
                                             iterpool);
493
495
 
494
496
      /* We should check if we should really add a delete operation */
495
497
      if (check_url_func)
502
504
          /* Determine from what parent we would be the deleted child */
503
505
          SVN_ERR(svn_wc__node_get_origin(
504
506
                              NULL, &parent_rev, &parent_repos_relpath,
505
 
                              &parent_repos_root_url, NULL, NULL,
 
507
                              &parent_repos_root_url, NULL, NULL, NULL,
506
508
                              wc_ctx,
507
509
                              svn_dirent_dirname(this_abspath,
508
510
                                                  scratch_pool),
768
770
           && !(state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE))
769
771
    {
770
772
      svn_revnum_t dir_rev = SVN_INVALID_REVNUM;
 
773
      const char *dir_repos_relpath = NULL;
771
774
 
772
 
      if (!copy_mode_root && !status->switched && !is_added)
773
 
        SVN_ERR(svn_wc__node_get_base(NULL, &dir_rev, NULL, NULL, NULL, NULL,
 
775
      if (!copy_mode_root && !is_added)
 
776
        SVN_ERR(svn_wc__node_get_base(NULL, &dir_rev, &dir_repos_relpath, NULL,
 
777
                                      NULL, NULL,
774
778
                                      wc_ctx, svn_dirent_dirname(local_abspath,
775
779
                                                                 scratch_pool),
776
780
                                      FALSE /* ignore_enoent */,
777
 
                                      FALSE /* show_hidden */,
778
781
                                      scratch_pool, scratch_pool));
779
782
 
780
783
      if (copy_mode_root || status->switched || node_rev != dir_rev)
794
797
              cf_rev = status->revision;
795
798
              cf_relpath = status->repos_relpath;
796
799
            }
 
800
 
 
801
          if (!copy_mode_root && !is_added && baton->check_url_func
 
802
              && dir_repos_relpath)
 
803
            {
 
804
              svn_node_kind_t me_kind;
 
805
              /* Maybe we need to issue an delete (mixed rev/switched) */
 
806
 
 
807
              SVN_ERR(baton->check_url_func(
 
808
                            baton->check_url_baton, &me_kind,
 
809
                            svn_path_url_add_component2(repos_root_url,
 
810
                                        svn_relpath_join(dir_repos_relpath,
 
811
                                            svn_dirent_basename(local_abspath,
 
812
                                                                NULL),
 
813
                                            scratch_pool),
 
814
                                        scratch_pool),
 
815
                                        dir_rev, scratch_pool));
 
816
              if (me_kind != svn_node_none)
 
817
                state_flags |= SVN_CLIENT_COMMIT_ITEM_DELETE;
 
818
            }
797
819
        }
798
820
    }
799
821
 
919
941
           * directory. In either case, we require the op-root of the parent
920
942
           * to be part of the commit. See issue #4059. */
921
943
          SVN_ERR(svn_wc__node_get_origin(&parent_is_copy, NULL, NULL, NULL,
922
 
                                          NULL, &copy_root_abspath,
 
944
                                          NULL, NULL, &copy_root_abspath,
923
945
                                          wc_ctx, parent_abspath,
924
946
                                          FALSE, scratch_pool, scratch_pool));
925
947
 
1233
1255
  /* Make sure that every path in danglers is part of the commit. */
1234
1256
  for (hi = apr_hash_first(scratch_pool, danglers); hi; hi = apr_hash_next(hi))
1235
1257
    {
1236
 
      const char *dangling_parent = svn__apr_hash_index_key(hi);
 
1258
      const char *dangling_parent = apr_hash_this_key(hi);
1237
1259
 
1238
1260
      svn_pool_clear(iterpool);
1239
1261
 
1240
1262
      if (! look_up_committable(*committables, dangling_parent, iterpool))
1241
1263
        {
1242
 
          const char *dangling_child = svn__apr_hash_index_val(hi);
 
1264
          const char *dangling_child = apr_hash_this_val(hi);
1243
1265
 
1244
1266
          if (ctx->notify_func2 != NULL)
1245
1267
            {
1357
1379
}
1358
1380
 
1359
1381
 
1360
 
int svn_client__sort_commit_item_urls(const void *a, const void *b)
 
1382
/* A svn_sort__array()/qsort()-compatible sort routine for sorting
 
1383
   an array of svn_client_commit_item_t *'s by their URL member. */
 
1384
static int
 
1385
sort_commit_item_urls(const void *a, const void *b)
1361
1386
{
1362
1387
  const svn_client_commit_item3_t *item1
1363
1388
    = *((const svn_client_commit_item3_t * const *) a);
1381
1406
  SVN_ERR_ASSERT(ci && ci->nelts);
1382
1407
 
1383
1408
  /* Sort our commit items by their URLs. */
1384
 
  qsort(ci->elts, ci->nelts,
1385
 
        ci->elt_size, svn_client__sort_commit_item_urls);
 
1409
  svn_sort__array(ci, sort_commit_item_urls);
1386
1410
 
1387
1411
  /* Loop through the URLs, finding the longest usable ancestor common
1388
1412
     to all of them, and making sure there are no duplicate URLs.  */
1470
1494
{
1471
1495
  const svn_client_commit_item3_t *item;
1472
1496
  void *file_baton;
 
1497
  apr_pool_t *file_pool;
1473
1498
};
1474
1499
 
1475
1500
 
1535
1560
  else
1536
1561
    file_pool = pool;
1537
1562
 
 
1563
  /* Subpools are cheap, but memory isn't */
 
1564
  file_pool = svn_pool_create(file_pool);
 
1565
 
1538
1566
  /* Call the cancellation function. */
1539
1567
  if (ctx->cancel_func)
1540
1568
    SVN_ERR(ctx->cancel_func(ctx->cancel_baton));
1618
1646
      else
1619
1647
        notify = NULL;
1620
1648
 
 
1649
 
1621
1650
      if (notify)
1622
1651
        {
1623
1652
          notify->kind = item->kind;
1624
1653
          notify->path_prefix = icb->notify_path_prefix;
1625
 
          (*ctx->notify_func2)(ctx->notify_baton2, notify, pool);
 
1654
          ctx->notify_func2(ctx->notify_baton2, notify, pool);
1626
1655
        }
1627
1656
    }
1628
1657
 
1783
1812
      /* Add this file mod to the FILE_MODS hash. */
1784
1813
      mod->item = item;
1785
1814
      mod->file_baton = file_baton;
 
1815
      mod->file_pool = file_pool;
1786
1816
      svn_hash_sets(file_mods, item->session_relpath, mod);
1787
1817
    }
1788
1818
  else if (file_baton)
1790
1820
      /* Close any outstanding file batons that didn't get caught by
1791
1821
         the "has local mods" conditional above. */
1792
1822
      err = editor->close_file(file_baton, NULL, file_pool);
1793
 
 
 
1823
      svn_pool_destroy(file_pool);
1794
1824
      if (err)
1795
1825
        goto fixup_error;
1796
1826
    }
1858
1888
       hi;
1859
1889
       hi = apr_hash_next(hi))
1860
1890
    {
1861
 
      struct file_mod_t *mod = svn__apr_hash_index_val(hi);
 
1891
      struct file_mod_t *mod = apr_hash_this_val(hi);
1862
1892
      const svn_client_commit_item3_t *item = mod->item;
1863
1893
      const svn_checksum_t *new_text_base_md5_checksum;
1864
1894
      const svn_checksum_t *new_text_base_sha1_checksum;
1905
1935
 
1906
1936
      if (sha1_checksums)
1907
1937
        svn_hash_sets(*sha1_checksums, item->path, new_text_base_sha1_checksum);
 
1938
 
 
1939
      svn_pool_destroy(mod->file_pool);
 
1940
    }
 
1941
 
 
1942
  if (ctx->notify_func2)
 
1943
    {
 
1944
      svn_wc_notify_t *notify;
 
1945
      notify = svn_wc_create_notify_url(base_url,
 
1946
                                        svn_wc_notify_commit_finalizing,
 
1947
                                        iterpool);
 
1948
      ctx->notify_func2(ctx->notify_baton2, notify, iterpool);
1908
1949
    }
1909
1950
 
1910
1951
  svn_pool_destroy(iterpool);