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

« back to all changes in this revision

Viewing changes to subversion/libsvn_fs_base/fs.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:
65
65
 
66
66
#include "../libsvn_fs/fs-loader.h"
67
67
#include "private/svn_fs_util.h"
68
 
#include "private/svn_subr_private.h"
69
 
 
70
68
 
71
69
 
72
70
/* Checking for return values, and reporting errors.  */
473
471
}
474
472
 
475
473
static svn_error_t *
 
474
base_bdb_info_format(int *fs_format,
 
475
                     svn_version_t **supports_version,
 
476
                     svn_fs_t *fs,
 
477
                     apr_pool_t *result_pool,
 
478
                     apr_pool_t *scratch_pool)
 
479
{
 
480
  base_fs_data_t *bfd = fs->fsap_data;
 
481
 
 
482
  *fs_format = bfd->format;
 
483
  *supports_version = apr_palloc(result_pool, sizeof(svn_version_t));
 
484
 
 
485
  (*supports_version)->major = SVN_VER_MAJOR;
 
486
  (*supports_version)->minor = 0;
 
487
  (*supports_version)->patch = 0;
 
488
  (*supports_version)->tag = "";
 
489
 
 
490
  switch (bfd->format)
 
491
    {
 
492
    case 1:
 
493
      break;
 
494
    case 2:
 
495
      (*supports_version)->minor = 4;
 
496
      break;
 
497
    case 3:
 
498
      (*supports_version)->minor = 5;
 
499
      break;
 
500
    case 4:
 
501
      (*supports_version)->minor = 6;
 
502
      break;
 
503
#ifdef SVN_DEBUG
 
504
# if SVN_FS_BASE__FORMAT_NUMBER != 4
 
505
#  error "Need to add a 'case' statement here"
 
506
# endif
 
507
#endif
 
508
    }
 
509
 
 
510
  return SVN_NO_ERROR;
 
511
}
 
512
 
 
513
static svn_error_t *
 
514
base_bdb_info_config_files(apr_array_header_t **files,
 
515
                           svn_fs_t *fs,
 
516
                           apr_pool_t *result_pool,
 
517
                           apr_pool_t *scratch_pool)
 
518
{
 
519
  *files = apr_array_make(result_pool, 1, sizeof(const char *));
 
520
  APR_ARRAY_PUSH(*files, const char *) = svn_dirent_join(fs->path,
 
521
                                                         BDB_CONFIG_FILE,
 
522
                                                         result_pool);
 
523
  return SVN_NO_ERROR;
 
524
}
 
525
 
 
526
static svn_error_t *
476
527
base_bdb_verify_root(svn_fs_root_t *root,
477
528
                     apr_pool_t *scratch_pool)
478
529
{
509
560
  svn_fs_base__unlock,
510
561
  svn_fs_base__get_lock,
511
562
  svn_fs_base__get_locks,
 
563
  base_bdb_info_format,
 
564
  base_bdb_info_config_files,
 
565
  NULL /* info_fsap */,
512
566
  base_bdb_verify_root,
513
567
  base_bdb_freeze,
514
568
  base_bdb_set_errcall,
675
729
}
676
730
 
677
731
static svn_error_t *
678
 
base_create(svn_fs_t *fs, const char *path, apr_pool_t *pool,
 
732
base_create(svn_fs_t *fs,
 
733
            const char *path,
 
734
            svn_mutex__t *common_pool_lock,
 
735
            apr_pool_t *pool,
679
736
            apr_pool_t *common_pool)
680
737
{
681
738
  int format = SVN_FS_BASE__FORMAT_NUMBER;
684
741
  /* See if compatibility with older versions was explicitly requested. */
685
742
  if (fs->config)
686
743
    {
687
 
      if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_4_COMPATIBLE))
688
 
        format = 1;
689
 
      else if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_5_COMPATIBLE))
690
 
        format = 2;
691
 
      else if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_6_COMPATIBLE))
692
 
        format = 3;
 
744
      svn_version_t *compatible_version;
 
745
      SVN_ERR(svn_fs__compatible_version(&compatible_version, fs->config,
 
746
                                         pool));
 
747
 
 
748
      /* select format number */
 
749
      switch(compatible_version->minor)
 
750
        {
 
751
          case 0:
 
752
          case 1:
 
753
          case 2:
 
754
          case 3: format = 1;
 
755
                  break;
 
756
 
 
757
          case 4: format = 2;
 
758
                  break;
 
759
 
 
760
          case 5: format = 3;
 
761
                  break;
 
762
 
 
763
          default:format = SVN_FS_BASE__FORMAT_NUMBER;
 
764
        }
693
765
    }
694
766
 
695
767
  /* Create the environment and databases. */
711
783
  return SVN_NO_ERROR;;
712
784
 
713
785
error:
714
 
  svn_error_clear(cleanup_fs(fs));
715
 
  return svn_err;
 
786
  return svn_error_compose_create(svn_err,
 
787
                                  svn_error_trace(cleanup_fs(fs)));
716
788
}
717
789
 
718
790
 
751
823
}
752
824
 
753
825
static svn_error_t *
754
 
base_open(svn_fs_t *fs, const char *path, apr_pool_t *pool,
 
826
base_open(svn_fs_t *fs,
 
827
          const char *path,
 
828
          svn_mutex__t *common_pool_lock,
 
829
          apr_pool_t *pool,
755
830
          apr_pool_t *common_pool)
756
831
{
757
832
  int format;
796
871
  return SVN_NO_ERROR;
797
872
 
798
873
 error:
799
 
  svn_error_clear(cleanup_fs(fs));
800
 
  return svn_err;
 
874
  return svn_error_compose_create(svn_err,
 
875
                                  svn_error_trace(cleanup_fs(fs)));
801
876
}
802
877
 
803
878
 
834
909
}
835
910
 
836
911
static svn_error_t *
837
 
base_open_for_recovery(svn_fs_t *fs, const char *path, apr_pool_t *pool,
 
912
base_open_for_recovery(svn_fs_t *fs,
 
913
                       const char *path,
 
914
                       svn_mutex__t *common_pool_lock,
 
915
                       apr_pool_t *pool,
838
916
                       apr_pool_t *common_pool)
839
917
{
840
918
  /* Just stash the path in the fs pointer - it's all we really need. */
844
922
}
845
923
 
846
924
static svn_error_t *
847
 
base_upgrade(svn_fs_t *fs, const char *path, apr_pool_t *pool,
 
925
base_upgrade(svn_fs_t *fs,
 
926
             const char *path,
 
927
             svn_fs_upgrade_notify_t notify_func,
 
928
             void *notify_baton,
 
929
             svn_cancel_func_t cancel_func,
 
930
             void *cancel_baton,
 
931
             svn_mutex__t *common_pool_lock,
 
932
             apr_pool_t *pool,
848
933
             apr_pool_t *common_pool)
849
934
{
850
935
  const char *version_file_path;
867
952
  /* Bump the format file's stored version number. */
868
953
  SVN_ERR(svn_io_write_version_file(version_file_path,
869
954
                                    SVN_FS_BASE__FORMAT_NUMBER, pool));
 
955
  if (notify_func)
 
956
    SVN_ERR(notify_func(notify_baton, SVN_FS_BASE__FORMAT_NUMBER,
 
957
                        svn_fs_upgrade_format_bumped, pool));
870
958
 
871
959
  /* Check and see if we need to record the "bump" revision. */
872
960
  if (old_format_number < SVN_FS_BASE__MIN_FORWARD_DELTAS_FORMAT)
883
971
         But it's better to use the existing encapsulation of "opening
884
972
         the filesystem" rather than duplicating (or worse, partially
885
973
         duplicating) that logic here.  */
886
 
      SVN_ERR(base_open(fs, path, subpool, common_pool));
 
974
      SVN_ERR(base_open(fs, path, common_pool_lock, subpool, common_pool));
887
975
 
888
976
      /* Fetch the youngest rev, and record it */
889
977
      SVN_ERR(svn_fs_base__youngest_rev(&youngest_rev, fs, subpool));
905
993
            void *notify_baton,
906
994
            svn_cancel_func_t cancel_func,
907
995
            void *cancel_baton,
 
996
            svn_mutex__t *common_pool_lock,
908
997
            apr_pool_t *pool,
909
998
            apr_pool_t *common_pool)
910
999
{
929
1018
              void *notify_baton,
930
1019
              svn_cancel_func_t cancel,
931
1020
              void *cancel_baton,
 
1021
              svn_mutex__t *common_pool_lock,
932
1022
              apr_pool_t *pool,
933
1023
              apr_pool_t *common_pool)
934
1024
{
994
1084
 
995
1085
  {  /* Process unused logs from live area */
996
1086
    int idx;
997
 
    apr_pool_t *sub_pool = svn_pool_create(pool);
 
1087
    apr_pool_t *subpool = svn_pool_create(pool);
998
1088
 
999
1089
    /* Process log files. */
1000
1090
    for (idx = 0; idx < logfiles->nelts; idx++)
1003
1093
        const char *live_log_path;
1004
1094
        const char *backup_log_path;
1005
1095
 
1006
 
        svn_pool_clear(sub_pool);
1007
 
        live_log_path = svn_dirent_join(live_path, log_file, sub_pool);
1008
 
        backup_log_path = svn_dirent_join(backup_path, log_file, sub_pool);
 
1096
        svn_pool_clear(subpool);
 
1097
        live_log_path = svn_dirent_join(live_path, log_file, subpool);
 
1098
        backup_log_path = svn_dirent_join(backup_path, log_file, subpool);
1009
1099
 
1010
1100
        { /* Compare files. No point in using MD5 and wasting CPU cycles as we
1011
1101
             got full copies of both logs */
1022
1112
            SVN_ERR(svn_io_files_contents_same_p(&files_match,
1023
1113
                                                 live_log_path,
1024
1114
                                                 backup_log_path,
1025
 
                                                 sub_pool));
 
1115
                                                 subpool));
1026
1116
 
1027
1117
          /* If log files do not match, go to the next log file. */
1028
1118
          if (!files_match)
1029
1119
            continue;
1030
1120
        }
1031
1121
 
1032
 
        SVN_ERR(svn_io_remove_file2(live_log_path, FALSE, sub_pool));
 
1122
        SVN_ERR(svn_io_remove_file2(live_log_path, FALSE, subpool));
1033
1123
      }
1034
1124
 
1035
 
    svn_pool_destroy(sub_pool);
 
1125
    svn_pool_destroy(subpool);
1036
1126
  }
1037
1127
 
1038
1128
  return SVN_NO_ERROR;
1201
1291
             const char *dest_path,
1202
1292
             svn_boolean_t clean_logs,
1203
1293
             svn_boolean_t incremental,
 
1294
             svn_fs_hotcopy_notify_t notify_func,
 
1295
             void *notify_baton,
1204
1296
             svn_cancel_func_t cancel_func,
1205
1297
             void *cancel_baton,
1206
 
             apr_pool_t *pool)
 
1298
             svn_mutex__t *common_pool_lock,
 
1299
             apr_pool_t *pool,
 
1300
             apr_pool_t *common_pool)
1207
1301
{
1208
1302
  svn_error_t *err;
1209
1303
  u_int32_t pagesize;
1388
1482
                     svn_error_t *(*svn_fs_open_)(svn_fs_t **,
1389
1483
                                                  const char *,
1390
1484
                                                  apr_hash_t *,
 
1485
                                                  apr_pool_t *,
1391
1486
                                                  apr_pool_t *))
1392
1487
{
1393
1488
  return SVN_NO_ERROR;
1409
1504
  base_bdb_pack,
1410
1505
  base_bdb_logfiles,
1411
1506
  svn_fs_base__id_parse,
1412
 
  base_set_svn_fs_open
 
1507
  base_set_svn_fs_open,
 
1508
  NULL /* info_fsap_dup */
1413
1509
};
1414
1510
 
1415
1511
svn_error_t *
1420
1516
    {
1421
1517
      { "svn_subr",  svn_subr_version },
1422
1518
      { "svn_delta", svn_delta_version },
 
1519
      { "svn_fs_util", svn_fs_util__version },
1423
1520
      { NULL, NULL }
1424
1521
    };
1425
1522