View | Details | Raw Unified | Return to bug 60610
Collapse All | Expand All

(-)subversion/mod_dav_svn/deadprops.c (-18 / +49 lines)
Lines 30-35 Link Here
30
#include "svn_dav.h"
30
#include "svn_dav.h"
31
#include "svn_base64.h"
31
#include "svn_base64.h"
32
32
33
/* Private header included just for 1.0.7 revprops security fix. */
34
#include "../libsvn_repos/repos.h"
33
35
34
struct dav_db {
36
struct dav_db {
35
  const dav_resource *resource;
37
  const dav_resource *resource;
Lines 41-46 Link Here
41
43
42
  /* used for constructing repos-local names for properties */
44
  /* used for constructing repos-local names for properties */
43
  svn_stringbuf_t *work;
45
  svn_stringbuf_t *work;
46
47
  /* passed to svn_repos_ funcs that fetch revprops. */
48
  svn_repos_authz_func_t authz_read_func;
49
  void *authz_read_baton;
44
};
50
};
45
51
46
struct dav_deadprop_rollback {
52
struct dav_deadprop_rollback {
Lines 102-110 Link Here
102
      serr = svn_fs_txn_prop(pvalue, db->resource->info->root.txn,
108
      serr = svn_fs_txn_prop(pvalue, db->resource->info->root.txn,
103
                             propname, db->p);
109
                             propname, db->p);
104
    else
110
    else
105
      serr = svn_fs_revision_prop(pvalue, db->resource->info->repos->fs,
111
      serr = svn_repos__fs_revision_prop
106
                                  db->resource->info->root.rev,
112
        (pvalue,
107
                                  propname, db->p);
113
         db->resource->info-> repos->repos,
114
         db->resource->info->root.rev, propname,
115
         db->authz_read_func,
116
         db->authz_read_baton, db->p);
108
  else
117
  else
109
    serr = svn_fs_node_prop(pvalue, db->resource->info->root.root,
118
    serr = svn_fs_node_prop(pvalue, db->resource->info->root.root,
110
                            get_repos_path(db->resource->info),
119
                            get_repos_path(db->resource->info),
Lines 148-157 Link Here
148
         not a working resource!  But this is how we currently
157
         not a working resource!  But this is how we currently
149
         (hackily) allow the svn client to change unversioned rev
158
         (hackily) allow the svn client to change unversioned rev
150
         props.  See issue #916. */
159
         props.  See issue #916. */
151
      serr = svn_repos_fs_change_rev_prop(db->resource->info->repos->repos,
160
      serr = svn_repos__fs_change_rev_prop2
152
                                          db->resource->info->root.rev,
161
        (db->resource->info->repos->repos,
153
                                          db->resource->info->repos->username,
162
         db->resource->info->root.rev,
154
                                          propname, value, db->resource->pool);
163
         db->resource->info->repos->username,
164
         propname, value,
165
         db->authz_read_func,
166
         db->authz_read_baton,
167
         db->resource->pool);
155
  else
168
  else
156
    serr = svn_repos_fs_change_node_prop(db->resource->info->root.root,
169
    serr = svn_repos_fs_change_node_prop(db->resource->info->root.root,
157
                                         get_repos_path(db->resource->info),
170
                                         get_repos_path(db->resource->info),
Lines 171-176 Link Here
171
                                  int ro, dav_db **pdb)
184
                                  int ro, dav_db **pdb)
172
{
185
{
173
  dav_db *db;
186
  dav_db *db;
187
  dav_svn_authz_read_baton *arb;
174
188
175
  /* Some resource types do not have deadprop databases. Specifically:
189
  /* Some resource types do not have deadprop databases. Specifically:
176
     REGULAR, VERSION, and WORKING resources have them. (SVN does not
190
     REGULAR, VERSION, and WORKING resources have them. (SVN does not
Lines 205-210 Link Here
205
  /* ### temp hack */
219
  /* ### temp hack */
206
  db->work = svn_stringbuf_ncreate("", 0, db->p);
220
  db->work = svn_stringbuf_ncreate("", 0, db->p);
207
221
222
  /* make our path-based authz callback available to svn_repos_* funcs. */
223
  arb = apr_pcalloc(p, sizeof(*arb));
224
  arb->r = resource->info->r;
225
  arb->repos = resource->info->repos;
226
  db->authz_read_baton = arb;
227
  db->authz_read_func = dav_svn_authz_read;
228
208
  /* ### use RO and node's mutable status to look for an error? */
229
  /* ### use RO and node's mutable status to look for an error? */
209
230
210
  *pdb = db;
231
  *pdb = db;
Lines 364-373 Link Here
364
         not a working resource!  But this is how we currently
385
         not a working resource!  But this is how we currently
365
         (hackily) allow the svn client to change unversioned rev
386
         (hackily) allow the svn client to change unversioned rev
366
         props.  See issue #916. */
387
         props.  See issue #916. */
367
      serr = svn_repos_fs_change_rev_prop(db->resource->info->repos->repos,
388
      serr = svn_repos__fs_change_rev_prop2
368
                                          db->resource->info->root.rev,
389
        (db->resource->info->repos->repos,
369
                                          db->resource->info->repos->username,
390
         db->resource->info->root.rev,
370
                                          propname, NULL, db->resource->pool);
391
         db->resource->info->repos->username,
392
         propname, NULL,
393
         db->authz_read_func,
394
         db->authz_read_baton,
395
         db->resource->pool);
371
  else
396
  else
372
    serr = svn_repos_fs_change_node_prop(db->resource->info->root.root,
397
    serr = svn_repos_fs_change_node_prop(db->resource->info->root.root,
373
                                         get_repos_path(db->resource->info),
398
                                         get_repos_path(db->resource->info),
Lines 402-410 Link Here
402
      serr = svn_fs_txn_prop(&propval, db->resource->info->root.txn,
427
      serr = svn_fs_txn_prop(&propval, db->resource->info->root.txn,
403
                             propname, db->p);
428
                             propname, db->p);
404
    else
429
    else
405
      serr = svn_fs_revision_prop(&propval, db->resource->info->repos->fs,
430
      serr = svn_repos__fs_revision_prop(&propval,
406
                                  db->resource->info->root.rev,
431
                                         db->resource->info->repos->repos,
407
                                  propname, db->p);
432
                                         db->resource->info->root.rev,
433
                                         propname,
434
                                         db->authz_read_func,
435
                                         db->authz_read_baton, db->p);
408
  else
436
  else
409
    serr = svn_fs_node_prop(&propval, db->resource->info->root.root,
437
    serr = svn_fs_node_prop(&propval, db->resource->info->root.root,
410
                            get_repos_path(db->resource->info),
438
                            get_repos_path(db->resource->info),
Lines 457-466 Link Here
457
                                       db->resource->info->root.txn,
485
                                       db->resource->info->root.txn,
458
                                       db->p);
486
                                       db->p);
459
          else
487
          else
460
            serr = svn_fs_revision_proplist(&db->props,
488
            serr = svn_repos__fs_revision_proplist
461
                                            db->resource->info->repos->fs,
489
              (&db->props,
462
                                            db->resource->info->root.rev, 
490
               db->resource->info->repos->repos,
463
                                            db->p);
491
               db->resource->info->root.rev,
492
               db->authz_read_func,
493
               db->authz_read_baton,
494
               db->p);
464
        }
495
        }
465
      else
496
      else
466
        {
497
        {
(-)subversion/mod_dav_svn/liveprops.c (-8 / +23 lines)
Lines 31-37 Link Here
31
#include "svn_dav.h"
31
#include "svn_dav.h"
32
#include "svn_md5.h"
32
#include "svn_md5.h"
33
33
34
/* Private header included just for 1.0.7 revprops security fix. */
35
#include "../libsvn_repos/repos.h"
34
36
37
35
/*
38
/*
36
** The namespace URIs that we use. This list and the enumeration must
39
** The namespace URIs that we use. This list and the enumeration must
37
** stay in sync.
40
** stay in sync.
Lines 117-122 Link Here
117
  apr_pool_t *p = resource->info->pool;
120
  apr_pool_t *p = resource->info->pool;
118
  const dav_liveprop_spec *info;
121
  const dav_liveprop_spec *info;
119
  int global_ns;
122
  int global_ns;
123
  dav_svn_authz_read_baton arb;
120
  svn_error_t *serr;
124
  svn_error_t *serr;
121
125
122
  /*
126
  /*
Lines 130-135 Link Here
130
  if (!resource->exists)
134
  if (!resource->exists)
131
    return DAV_PROP_INSERT_NOTSUPP;
135
    return DAV_PROP_INSERT_NOTSUPP;
132
136
137
  /* Build a baton for path-based authz function (dav_svn_authz_read) */
138
  arb.r = resource->info->r;
139
  arb.repos = resource->info->repos;
140
133
  /* ### we may want to respond to DAV_PROPID_resourcetype for PRIVATE
141
  /* ### we may want to respond to DAV_PROPID_resourcetype for PRIVATE
134
     ### resources. need to think on "proper" interaction with mod_dav */
142
     ### resources. need to think on "proper" interaction with mod_dav */
135
143
Lines 218-227 Link Here
218
          }
226
          }
219
        
227
        
220
        /* Get the date property of the created revision. */
228
        /* Get the date property of the created revision. */
221
        serr = svn_fs_revision_prop(&last_author,
229
        serr = svn_repos__fs_revision_prop(&last_author,
222
                                    resource->info->repos->fs,
230
                                           resource->info->repos->repos,
223
                                    committed_rev,
231
                                           committed_rev,
224
                                    SVN_PROP_REVISION_AUTHOR, p);
232
                                           SVN_PROP_REVISION_AUTHOR,
233
                                           dav_svn_authz_read, &arb, p);
225
        if (serr != NULL)
234
        if (serr != NULL)
226
          {
235
          {
227
            /* ### what to do? */
236
            /* ### what to do? */
Lines 651-657 Link Here
651
  svn_string_t *committed_date = NULL;
660
  svn_string_t *committed_date = NULL;
652
  svn_error_t *serr;
661
  svn_error_t *serr;
653
  apr_time_t timeval_tmp;
662
  apr_time_t timeval_tmp;
663
  dav_svn_authz_read_baton arb;
654
  
664
  
665
  arb.r = resource->info->r;
666
  arb.repos = resource->info->repos;
667
655
  if ((datestring == NULL) && (timeval == NULL))
668
  if ((datestring == NULL) && (timeval == NULL))
656
    return 0;
669
    return 0;
657
670
Lines 677-686 Link Here
677
    }
690
    }
678
691
679
  /* Get the svn:date property of the CR */
692
  /* Get the svn:date property of the CR */
680
  serr = svn_fs_revision_prop(&committed_date,
693
  serr = svn_repos__fs_revision_prop(&committed_date,
681
                              resource->info->repos->fs,
694
                                     resource->info->repos->repos,
682
                              committed_rev,
695
                                     committed_rev,
683
                              SVN_PROP_REVISION_DATE, pool);
696
                                     SVN_PROP_REVISION_DATE,
697
                                     dav_svn_authz_read, &arb,
698
                                     pool);
684
  if (serr != NULL)
699
  if (serr != NULL)
685
    return 1;
700
    return 1;
686
  
701
  
(-)subversion/libsvn_repos/fs-wrap.c (-9 / +200 lines)
Lines 138-144 Link Here
138
138
139
139
140
140
141
/*** Property change wrappers ***/
141
/*** Property wrappers ***/
142
142
143
/* Validate that property NAME is valid for use in a Subversion
143
/* Validate that property NAME is valid for use in a Subversion
144
   repository. */
144
   repository. */
Lines 182-188 Link Here
182
}
182
}
183
183
184
184
185
/* A revision's changed paths are either all readable, all unreadable,
186
   or a mixture of the two. */
187
enum rev_readability_level
188
{
189
  rev_readable = 1,
190
  rev_partially_readable,
191
  rev_unreadable
192
};
193
194
195
/* Helper func: examine the changed-paths of REV in FS using
196
   AUTHZ_READ_FUNC.  Set *CAN_READ to one of the three
197
   readability_level enum values.  Use POOL for invoking the authz func. */
198
static svn_error_t *
199
get_readability (int *can_read,
200
                 svn_fs_t *fs,
201
                 svn_revnum_t rev,
202
                 svn_repos_authz_func_t authz_read_func,
203
                 void *authz_read_baton,
204
                 apr_pool_t *pool)
205
{
206
  svn_fs_root_t *root;
207
  apr_hash_t *changes;
208
  apr_hash_index_t *hi;
209
  apr_pool_t *subpool = svn_pool_create (pool);
210
  svn_boolean_t found_readable = FALSE, found_unreadable = FALSE;
211
212
  SVN_ERR (svn_fs_revision_root (&root, fs, rev, pool));
213
  SVN_ERR (svn_fs_paths_changed (&changes, root, pool));
214
215
  if (apr_hash_count (changes) == 0)
216
    {
217
      /* No paths changed in this revision?  Uh, sure, I guess the
218
         revision is readable, then.  */
219
      *can_read = rev_readable;
220
      return SVN_NO_ERROR;
221
    }
222
223
  for (hi = apr_hash_first (pool, changes); hi; hi = apr_hash_next (hi))
224
    {
225
      const void *key;
226
      const char *path;
227
      svn_boolean_t readable;
228
229
      svn_pool_clear (subpool);
230
231
      apr_hash_this (hi, &key, NULL, NULL);
232
      path = (const char *) key;
233
234
      SVN_ERR (authz_read_func (&readable, root, path,
235
                                authz_read_baton, subpool));
236
      if (readable)
237
        found_readable = TRUE;
238
      else
239
        found_unreadable = TRUE;
240
    }
241
242
  svn_pool_destroy (subpool);
243
244
  if (found_unreadable && (! found_readable))
245
    *can_read = rev_unreadable;
246
  else if (found_readable && (! found_unreadable))
247
    *can_read = rev_readable;
248
  else  /* found both readable and unreadable */
249
    *can_read = rev_partially_readable;
250
251
  return SVN_NO_ERROR;
252
}
253
254
185
svn_error_t *
255
svn_error_t *
256
svn_repos__fs_change_rev_prop2 (svn_repos_t *repos,
257
                                svn_revnum_t rev,
258
                                const char *author,
259
                                const char *name,
260
                                const svn_string_t *new_value,
261
                                svn_repos_authz_func_t authz_read_func,
262
                                void *authz_read_baton,
263
                                apr_pool_t *pool)
264
{
265
  svn_string_t *old_value;
266
  int readability = rev_readable;
267
268
  if (authz_read_func)
269
    SVN_ERR (get_readability (&readability, repos->fs, rev,
270
                              authz_read_func, authz_read_baton, pool));    
271
  if (readability == rev_readable)
272
    {
273
      SVN_ERR (validate_prop (name, pool));
274
      SVN_ERR (svn_fs_revision_prop (&old_value, repos->fs, rev, name, pool));
275
      SVN_ERR (svn_repos__hooks_pre_revprop_change (repos, rev, author, name, 
276
                                                    new_value, pool));
277
      SVN_ERR (svn_fs_change_rev_prop (repos->fs, rev, name, new_value, pool));
278
      SVN_ERR (svn_repos__hooks_post_revprop_change (repos, rev, author, 
279
                                                     name, old_value, pool));
280
    }
281
  else  /* rev is either unreadable or only partially readable */
282
    {
283
      return svn_error_createf 
284
        (APR_EGENERAL, NULL,
285
         "Write denied:  not authorized to read all of revision %ld.", rev);
286
    }
287
288
  return SVN_NO_ERROR;
289
}
290
291
292
293
svn_error_t *
186
svn_repos_fs_change_rev_prop (svn_repos_t *repos,
294
svn_repos_fs_change_rev_prop (svn_repos_t *repos,
187
                              svn_revnum_t rev,
295
                              svn_revnum_t rev,
188
                              const char *author,
296
                              const char *author,
Lines 190-212 Link Here
190
                              const svn_string_t *new_value,
298
                              const svn_string_t *new_value,
191
                              apr_pool_t *pool)
299
                              apr_pool_t *pool)
192
{
300
{
193
  svn_string_t *old_value;
301
  return svn_repos__fs_change_rev_prop2 (repos, rev, author, name, new_value,
302
                                         NULL, NULL, pool);  
303
}     
194
304
195
  SVN_ERR (validate_prop (name, pool));
196
  SVN_ERR (svn_fs_revision_prop (&old_value, repos->fs, rev, name, pool));
197
  SVN_ERR (svn_repos__hooks_pre_revprop_change (repos, rev, author, name, 
198
                                                new_value, pool));
199
  SVN_ERR (svn_fs_change_rev_prop (repos->fs, rev, name, new_value, pool));
200
  SVN_ERR (svn_repos__hooks_post_revprop_change (repos, rev, author, 
201
                                                 name, old_value, pool));
202
305
306
307
svn_error_t *
308
svn_repos__fs_revision_prop (svn_string_t **value_p,
309
                             svn_repos_t *repos,
310
                             svn_revnum_t rev,
311
                             const char *propname,
312
                             svn_repos_authz_func_t authz_read_func,
313
                             void *authz_read_baton,
314
                             apr_pool_t *pool)
315
{
316
  int readability = rev_readable;
317
318
  if (authz_read_func)
319
    SVN_ERR (get_readability (&readability, repos->fs, rev,
320
                              authz_read_func, authz_read_baton, pool));    
321
322
  if (readability == rev_unreadable)
323
    {
324
      /* Property?  What property? */
325
      *value_p = NULL;
326
    }
327
  else if (readability == rev_partially_readable)
328
    {      
329
      /* Only svn:author and svn:date are fetchable. */
330
      if ((strncmp (propname, SVN_PROP_REVISION_AUTHOR,
331
                    strlen(SVN_PROP_REVISION_AUTHOR)) != 0)
332
          && (strncmp (propname, SVN_PROP_REVISION_DATE,
333
                       strlen(SVN_PROP_REVISION_DATE)) != 0))
334
        *value_p = NULL;
335
336
      else
337
        SVN_ERR (svn_fs_revision_prop (value_p, repos->fs,
338
                                       rev, propname, pool));
339
    }
340
  else /* wholly readable revision */
341
    {
342
      SVN_ERR (svn_fs_revision_prop (value_p, repos->fs, rev, propname, pool));
343
    }
344
203
  return SVN_NO_ERROR;
345
  return SVN_NO_ERROR;
204
}
346
}
205
347
206
348
207
349
350
svn_error_t *
351
svn_repos__fs_revision_proplist (apr_hash_t **table_p,
352
                                 svn_repos_t *repos,
353
                                 svn_revnum_t rev,
354
                                 svn_repos_authz_func_t authz_read_func,
355
                                 void *authz_read_baton,
356
                                 apr_pool_t *pool)
357
{
358
  int readability = rev_readable;
208
359
360
  if (authz_read_func)
361
    SVN_ERR (get_readability (&readability, repos->fs, rev,
362
                              authz_read_func, authz_read_baton, pool));    
209
363
364
  if (readability == rev_unreadable)
365
    {
366
      /* Return an empty hash. */
367
      *table_p = apr_hash_make (pool);
368
    }
369
  else if (readability == rev_partially_readable)
370
    {      
371
      apr_hash_t *tmphash;
372
      svn_string_t *value;
373
374
      /* Produce two property hashtables, both in POOL. */
375
      SVN_ERR (svn_fs_revision_proplist (&tmphash, repos->fs, rev, pool));
376
      *table_p = apr_hash_make (pool);
377
378
      /* If they exist, we only copy svn:author and svn:date into the
379
         'real' hashtable being returned. */
380
      value = apr_hash_get (tmphash, SVN_PROP_REVISION_AUTHOR,
381
                            APR_HASH_KEY_STRING);
382
      if (value)
383
        apr_hash_set (*table_p, SVN_PROP_REVISION_AUTHOR,
384
                      APR_HASH_KEY_STRING, value);
385
386
      value = apr_hash_get (tmphash, SVN_PROP_REVISION_DATE,
387
                            APR_HASH_KEY_STRING);
388
      if (value)
389
        apr_hash_set (*table_p, SVN_PROP_REVISION_DATE,
390
                      APR_HASH_KEY_STRING, value);
391
    }
392
  else /* wholly readable revision */
393
    {
394
      SVN_ERR (svn_fs_revision_proplist (table_p, repos->fs, rev, pool));
395
    }
396
397
  return SVN_NO_ERROR;
398
}
399
400
210
401
211
/* 
402
/* 
212
 * vim:ts=4:sw=4:expandtab:tw=80:fo=tcroq 
403
 * vim:ts=4:sw=4:expandtab:tw=80:fo=tcroq 
(-)subversion/libsvn_repos/repos.h (+39 lines)
Lines 164-169 Link Here
164
                                      apr_pool_t *pool);
164
                                      apr_pool_t *pool);
165
165
166
166
167
/* Included only for 1.0.7 security fix.  Allows use of
168
   authz_read_func, which is supplied by mod_dav_svn. */
169
svn_error_t *
170
svn_repos__fs_revision_prop (svn_string_t **value_p,
171
                             svn_repos_t *repos,
172
                             svn_revnum_t rev,
173
                             const char *propname,
174
                             svn_repos_authz_func_t
175
                             authz_read_func,
176
                             void *authz_read_baton,
177
                             apr_pool_t *pool);
178
179
180
/* Included only for 1.0.7 security fix.  Allows use of
181
   authz_read_func, which is supplied by mod_dav_svn. */
182
svn_error_t *
183
svn_repos__fs_revision_proplist (apr_hash_t **table_p,
184
                                 svn_repos_t *repos,
185
                                 svn_revnum_t rev,
186
                                 svn_repos_authz_func_t
187
                                 authz_read_func,
188
                                 void *authz_read_baton,
189
                                 apr_pool_t *pool);
190
191
192
/* Included only for 1.0.7 security fix.  Allows use of
193
   authz_read_func, which is supplied by mod_dav_svn. */
194
svn_error_t *
195
svn_repos__fs_change_rev_prop2 (svn_repos_t *repos,
196
                                svn_revnum_t rev,
197
                                const char *author,
198
                                const char *name,
199
                                const svn_string_t *new_value,
200
                                svn_repos_authz_func_t
201
                                authz_read_func,
202
                                void *authz_read_baton,
203
                                apr_pool_t *pool);
204
  
205
167
#ifdef __cplusplus
206
#ifdef __cplusplus
168
}
207
}
169
#endif /* __cplusplus */
208
#endif /* __cplusplus */

Return to bug 60610