Configure sandbox using consdiffmgr; free cdm on exit.

This commit is contained in:
Nick Mathewson 2017-04-25 19:52:34 -04:00
parent 2655a72d89
commit 24f7059704
5 changed files with 30 additions and 0 deletions

View File

@ -77,6 +77,17 @@ consensus_cache_open(const char *subdir, int max_entries)
return cache;
}
/**
* Tell the sandbox (if any) configured by <b>cfg</b> to allow the
* operations that <b>cache</b> will need.
*/
int
consensus_cache_register_with_sandbox(consensus_cache_t *cache,
struct sandbox_cfg_elem **cfg)
{
return storage_dir_register_with_sandbox(cache->dir, cfg);
}
/**
* Helper: clear all entries from <b>cache</b> (but do not delete
* any that aren't marked for removal

View File

@ -13,6 +13,9 @@ HANDLE_DECL(consensus_cache_entry, consensus_cache_entry_t, )
consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries);
void consensus_cache_free(consensus_cache_t *cache);
struct sandbox_cfg_elem;
int consensus_cache_register_with_sandbox(consensus_cache_t *cache,
struct sandbox_cfg_elem **cfg);
void consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff);
void consensus_cache_delete_pending(consensus_cache_t *cache);
consensus_cache_entry_t *consensus_cache_add(consensus_cache_t *cache,

View File

@ -627,6 +627,16 @@ consdiffmgr_configure(const consdiff_cfg_t *cfg)
(void) cdm_cache_get();
}
/**
* Tell the sandbox (if any) configured by <b>cfg</b> to allow the
* operations that the consensus diff manager will need.
*/
int
consdiffmgr_register_with_sandbox(struct sandbox_cfg_elem **cfg)
{
return consensus_cache_register_with_sandbox(cdm_cache_get(), cfg);
}
/**
* Scan the consensus diff manager's cache for any grossly malformed entries,
* and mark them as deletable. Return 0 if no problems were found; 1

View File

@ -32,6 +32,8 @@ consdiff_status_t consdiffmgr_find_diff_from(
void consdiffmgr_rescan(void);
int consdiffmgr_cleanup(void);
void consdiffmgr_configure(const consdiff_cfg_t *cfg);
struct sandbox_cfg_elem;
int consdiffmgr_register_with_sandbox(struct sandbox_cfg_elem **cfg);
void consdiffmgr_free_all(void);
int consdiffmgr_validate(void);

View File

@ -64,6 +64,7 @@
#include "connection.h"
#include "connection_edge.h"
#include "connection_or.h"
#include "consdiffmgr.h"
#include "control.h"
#include "cpuworker.h"
#include "crypto_s2k.h"
@ -3162,6 +3163,7 @@ tor_free_all(int postfork)
sandbox_free_getaddrinfo_cache();
protover_free_all();
bridges_free_all();
consdiffmgr_free_all();
if (!postfork) {
config_free_all();
or_state_free_all();
@ -3584,6 +3586,8 @@ sandbox_init_filter(void)
OPEN_DATADIR("stats");
STAT_DATADIR("stats");
STAT_DATADIR2("stats", "dirreq-stats");
consdiffmgr_register_with_sandbox(&cfg);
}
init_addrinfo();