Introduce astcachedir, to be used for temporary bucket files

As described in the issue, /tmp is not a suitable location for a
large amount of cached media files, since most distributions make
/tmp a RAM-based tmpfs mount with limited capacity.

I opted for a location that can be configured separately, as opposed
to using a subdirectory of spooldir, given the different storage
profile (transient files vs files that might stay there indefinitely).

This commit just makes the cache directory configurable, but leaves
it at /tmp by default, to ensure backwards compatibility.

A future commit that only targets master could change the default
location to something more sensible such as /var/tmp/asterisk. At
that point, the cachedir could be created and cleaned up during
uninstall by the Makefile script.

ASTERISK-29143

Change-Id: Ic54e95199405abacd9e509cef5f08fa14c510b5d
This commit is contained in:
lvl
2020-10-29 12:25:27 +01:00
committed by George Joseph
parent f39d5ea7cd
commit 92fcd4edba
13 changed files with 31 additions and 4 deletions

View File

@@ -98,6 +98,7 @@ char record_cache_dir[AST_CACHE_DIR_LEN] = DEFAULT_TMP_DIR;
char ast_defaultlanguage[MAX_LANGUAGE] = DEFAULT_LANGUAGE;
struct _cfg_paths {
char cache_dir[PATH_MAX];
char config_dir[PATH_MAX];
char module_dir[PATH_MAX];
char spool_dir[PATH_MAX];
@@ -125,6 +126,7 @@ struct _cfg_paths {
};
static struct _cfg_paths cfg_paths = {
.cache_dir = DEFAULT_CACHE_DIR,
.config_dir = DEFAULT_CONFIG_DIR,
.module_dir = DEFAULT_MODULE_DIR,
.spool_dir = DEFAULT_SPOOL_DIR,
@@ -145,6 +147,7 @@ static struct _cfg_paths cfg_paths = {
.ctl_file = "asterisk.ctl",
};
const char *ast_config_AST_CACHE_DIR = cfg_paths.cache_dir;
const char *ast_config_AST_CONFIG_DIR = cfg_paths.config_dir;
const char *ast_config_AST_CONFIG_FILE = cfg_paths.config_file;
const char *ast_config_AST_MODULE_DIR = cfg_paths.module_dir;
@@ -254,7 +257,9 @@ void load_asterisk_conf(void)
}
for (v = ast_variable_browse(cfg, "directories"); v; v = v->next) {
if (!strcasecmp(v->name, "astetcdir")) {
if (!strcasecmp(v->name, "astcachedir")) {
ast_copy_string(cfg_paths.cache_dir, v->value, sizeof(cfg_paths.cache_dir));
} else if (!strcasecmp(v->name, "astetcdir")) {
ast_copy_string(cfg_paths.config_dir, v->value, sizeof(cfg_paths.config_dir));
} else if (!strcasecmp(v->name, "astspooldir")) {
ast_copy_string(cfg_paths.spool_dir, v->value, sizeof(cfg_paths.spool_dir));