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

« back to all changes in this revision

Viewing changes to subversion/libsvn_client/cleanup.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:
32
32
#include "svn_client.h"
33
33
#include "svn_config.h"
34
34
#include "svn_dirent_uri.h"
 
35
#include "svn_hash.h"
35
36
#include "svn_path.h"
36
37
#include "svn_pools.h"
37
38
#include "client.h"
38
39
#include "svn_props.h"
39
40
 
40
41
#include "svn_private_config.h"
 
42
#include "private/svn_wc_private.h"
41
43
 
42
44
 
43
45
/*** Code. ***/
44
46
 
45
 
svn_error_t *
46
 
svn_client_cleanup(const char *path,
47
 
                   svn_client_ctx_t *ctx,
48
 
                   apr_pool_t *scratch_pool)
49
 
{
50
 
  const char *local_abspath;
51
 
  svn_error_t *err;
52
 
 
53
 
  if (svn_path_is_url(path))
54
 
    return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
55
 
                             _("'%s' is not a local path"), path);
56
 
 
57
 
  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, scratch_pool));
58
 
 
59
 
  err = svn_wc_cleanup3(ctx->wc_ctx, local_abspath, ctx->cancel_func,
60
 
                        ctx->cancel_baton, scratch_pool);
61
 
  svn_io_sleep_for_timestamps(path, scratch_pool);
62
 
  return svn_error_trace(err);
 
47
struct cleanup_status_walk_baton
 
48
{
 
49
  svn_boolean_t break_locks;
 
50
  svn_boolean_t fix_timestamps;
 
51
  svn_boolean_t clear_dav_cache;
 
52
  svn_boolean_t vacuum_pristines;
 
53
  svn_boolean_t remove_unversioned_items;
 
54
  svn_boolean_t remove_ignored_items;
 
55
  svn_boolean_t include_externals;
 
56
  svn_client_ctx_t *ctx;
 
57
};
 
58
 
 
59
/* Forward declararion. */
 
60
static svn_error_t *
 
61
cleanup_status_walk(void *baton,
 
62
                    const char *local_abspath,
 
63
                    const svn_wc_status3_t *status,
 
64
                    apr_pool_t *scratch_pool);
 
65
 
 
66
static svn_error_t *
 
67
do_cleanup(const char *local_abspath,
 
68
           svn_boolean_t break_locks,
 
69
           svn_boolean_t fix_timestamps,
 
70
           svn_boolean_t clear_dav_cache,
 
71
           svn_boolean_t vacuum_pristines,
 
72
           svn_boolean_t remove_unversioned_items,
 
73
           svn_boolean_t remove_ignored_items,
 
74
           svn_boolean_t include_externals,
 
75
           svn_client_ctx_t *ctx,
 
76
           apr_pool_t *scratch_pool)
 
77
{
 
78
  SVN_ERR(svn_wc_cleanup4(ctx->wc_ctx,
 
79
                          local_abspath,
 
80
                          break_locks,
 
81
                          fix_timestamps,
 
82
                          clear_dav_cache,
 
83
                          vacuum_pristines,
 
84
                          ctx->cancel_func, ctx->cancel_baton,
 
85
                          ctx->notify_func2, ctx->notify_baton2,
 
86
                          scratch_pool));
 
87
 
 
88
  if (fix_timestamps)
 
89
    svn_io_sleep_for_timestamps(local_abspath, scratch_pool);
 
90
 
 
91
  if (remove_unversioned_items || remove_ignored_items || include_externals)
 
92
    {
 
93
      struct cleanup_status_walk_baton b;
 
94
      apr_array_header_t *ignores;
 
95
 
 
96
      b.break_locks = break_locks;
 
97
      b.fix_timestamps = fix_timestamps;
 
98
      b.clear_dav_cache = clear_dav_cache;
 
99
      b.vacuum_pristines = vacuum_pristines;
 
100
      b.remove_unversioned_items = remove_unversioned_items;
 
101
      b.remove_ignored_items = remove_ignored_items;
 
102
      b.include_externals = include_externals;
 
103
      b.ctx = ctx;
 
104
 
 
105
      SVN_ERR(svn_wc_get_default_ignores(&ignores, ctx->config, scratch_pool));
 
106
 
 
107
      SVN_WC__CALL_WITH_WRITE_LOCK(
 
108
              svn_wc_walk_status(ctx->wc_ctx, local_abspath,
 
109
                                 svn_depth_infinity,
 
110
                                 TRUE,  /* get all */
 
111
                                 remove_ignored_items,
 
112
                                 TRUE,  /* ignore textmods */
 
113
                                 ignores,
 
114
                                 cleanup_status_walk, &b,
 
115
                                 ctx->cancel_func,
 
116
                                 ctx->cancel_baton,
 
117
                                 scratch_pool),
 
118
              ctx->wc_ctx,
 
119
              local_abspath,
 
120
              FALSE /* lock_anchor */,
 
121
              scratch_pool);
 
122
    }
 
123
 
 
124
  return SVN_NO_ERROR;
 
125
}
 
126
 
 
127
 
 
128
/* An implementation of svn_wc_status_func4_t. */
 
129
static svn_error_t *
 
130
cleanup_status_walk(void *baton,
 
131
                    const char *local_abspath,
 
132
                    const svn_wc_status3_t *status,
 
133
                    apr_pool_t *scratch_pool)
 
134
{
 
135
  struct cleanup_status_walk_baton *b = baton;
 
136
  svn_node_kind_t kind_on_disk;
 
137
  svn_wc_notify_t *notify;
 
138
 
 
139
  if (status->node_status == svn_wc_status_external && b->include_externals)
 
140
    {
 
141
      svn_error_t *err;
 
142
 
 
143
      SVN_ERR(svn_io_check_path(local_abspath, &kind_on_disk, scratch_pool));
 
144
      if (kind_on_disk == svn_node_dir)
 
145
        {
 
146
          if (b->ctx->notify_func2)
 
147
            {
 
148
              notify = svn_wc_create_notify(local_abspath,
 
149
                                            svn_wc_notify_cleanup_external,
 
150
                                            scratch_pool);
 
151
              b->ctx->notify_func2(b->ctx->notify_baton2, notify,
 
152
                                   scratch_pool);
 
153
            }
 
154
 
 
155
          err = do_cleanup(local_abspath,
 
156
                           b->break_locks,
 
157
                           b->fix_timestamps,
 
158
                           b->clear_dav_cache,
 
159
                           b->vacuum_pristines,
 
160
                           b->remove_unversioned_items,
 
161
                           b->remove_ignored_items,
 
162
                           TRUE /* include_externals */,
 
163
                           b->ctx, scratch_pool);
 
164
          if (err && err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY)
 
165
            {
 
166
              svn_error_clear(err);
 
167
              return SVN_NO_ERROR;
 
168
            }
 
169
          else
 
170
            SVN_ERR(err);
 
171
        }
 
172
 
 
173
      return SVN_NO_ERROR;
 
174
    }
 
175
 
 
176
  if (status->node_status == svn_wc_status_ignored)
 
177
    {
 
178
      if (!b->remove_ignored_items)
 
179
        return SVN_NO_ERROR;
 
180
    }
 
181
  else if (status->node_status == svn_wc_status_unversioned)
 
182
    {
 
183
      if (!b->remove_unversioned_items)
 
184
        return SVN_NO_ERROR;
 
185
    }
 
186
  else
 
187
    return SVN_NO_ERROR;
 
188
 
 
189
  SVN_ERR(svn_io_check_path(local_abspath, &kind_on_disk, scratch_pool));
 
190
  switch (kind_on_disk)
 
191
    {
 
192
      case svn_node_file:
 
193
      case svn_node_symlink:
 
194
        SVN_ERR(svn_io_remove_file2(local_abspath, FALSE, scratch_pool));
 
195
        break;
 
196
      case svn_node_dir:
 
197
        SVN_ERR(svn_io_remove_dir2(local_abspath, FALSE,
 
198
                                   b->ctx->cancel_func, b->ctx->cancel_baton,
 
199
                                   scratch_pool));
 
200
        break;
 
201
      case svn_node_none:
 
202
      default:
 
203
        return SVN_NO_ERROR;
 
204
    }
 
205
 
 
206
  if (b->ctx->notify_func2)
 
207
    {
 
208
      notify = svn_wc_create_notify(local_abspath, svn_wc_notify_delete,
 
209
                                    scratch_pool);
 
210
      notify->kind = kind_on_disk;
 
211
      b->ctx->notify_func2(b->ctx->notify_baton2, notify, scratch_pool);
 
212
    }
 
213
 
 
214
  return SVN_NO_ERROR;
 
215
}
 
216
 
 
217
svn_error_t *
 
218
svn_client_cleanup2(const char *dir_abspath,
 
219
                    svn_boolean_t break_locks,
 
220
                    svn_boolean_t fix_recorded_timestamps,
 
221
                    svn_boolean_t clear_dav_cache,
 
222
                    svn_boolean_t vacuum_pristines,
 
223
                    svn_boolean_t include_externals,
 
224
                    svn_client_ctx_t *ctx,
 
225
                    apr_pool_t *scratch_pool)
 
226
{
 
227
  SVN_ERR_ASSERT(svn_dirent_is_absolute(dir_abspath));
 
228
 
 
229
  SVN_ERR(do_cleanup(dir_abspath,
 
230
                     break_locks,
 
231
                     fix_recorded_timestamps,
 
232
                     clear_dav_cache,
 
233
                     vacuum_pristines,
 
234
                     FALSE /* remove_unversioned_items */,
 
235
                     FALSE /* remove_ignored_items */,
 
236
                     include_externals,
 
237
                     ctx, scratch_pool));
 
238
 
 
239
  return SVN_NO_ERROR;
 
240
}
 
241
 
 
242
svn_error_t *
 
243
svn_client_vacuum(const char *dir_abspath,
 
244
                  svn_boolean_t remove_unversioned_items,
 
245
                  svn_boolean_t remove_ignored_items,
 
246
                  svn_boolean_t fix_recorded_timestamps,
 
247
                  svn_boolean_t vacuum_pristines,
 
248
                  svn_boolean_t include_externals,
 
249
                  svn_client_ctx_t *ctx,
 
250
                  apr_pool_t *scratch_pool)
 
251
{
 
252
  SVN_ERR_ASSERT(svn_dirent_is_absolute(dir_abspath));
 
253
 
 
254
  SVN_ERR(do_cleanup(dir_abspath,
 
255
                     FALSE /* break_locks */,
 
256
                     fix_recorded_timestamps,
 
257
                     FALSE /* clear_dav_cache */,
 
258
                     vacuum_pristines,
 
259
                     remove_unversioned_items,
 
260
                     remove_ignored_items,
 
261
                     include_externals,
 
262
                     ctx, scratch_pool));
 
263
 
 
264
  return SVN_NO_ERROR;
63
265
}