<p>lvl has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15076">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Introduce astcachedir, to be used for temporary bucket files<br><br>As described in the issue, /tmp is not a suitable location for a<br>large amount of cached media files, since most distributions make<br>/tmp a RAM-based tmpfs mount with limited capacity.<br><br>I opted for a location that can be configured separately, as opposed<br>to using a subdirectory of spooldir, given the different storage<br>profile (transient files vs files that might stay there indefinitely).<br><br>This commit just makes the cache directory configurable, but leaves<br>it at /tmp by default, to ensure backwards compatibility.<br><br>A future commit that only targets master could change the default<br>location to something more sensible such as /var/tmp/asterisk. At<br>that point, the cachedir could be created and cleaned up during<br>uninstall by the Makefile script.<br><br>ASTERISK-29143<br><br>Change-Id: Ic54e95199405abacd9e509cef5f08fa14c510b5d<br>---<br>M Makefile<br>M build_tools/install_subst<br>M build_tools/make_defaults_h<br>M build_tools/mkpkgconfig<br>M configs/samples/asterisk.conf.sample<br>M configure<br>M configure.ac<br>M include/asterisk/paths.h<br>M main/bucket.c<br>M main/options.c<br>M main/pbx_variables.c<br>M makeopts.in<br>12 files changed, 25 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/76/15076/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/Makefile b/Makefile</span><br><span>index fd1c1db..3f2f35d 100644</span><br><span>--- a/Makefile</span><br><span>+++ b/Makefile</span><br><span>@@ -49,6 +49,7 @@</span><br><span> export DESTDIR</span><br><span> </span><br><span> export INSTALL_PATH # Additional prefix for the following paths</span><br><span style="color: hsl(120, 100%, 40%);">+export ASTCACHEDIR</span><br><span> export ASTETCDIR # Path for config files</span><br><span> export ASTVARRUNDIR</span><br><span> export ASTSPOOLDIR</span><br><span>@@ -555,7 +556,7 @@</span><br><span> </span><br><span> NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))</span><br><span> OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))</span><br><span style="color: hsl(0, 100%, 40%);">-INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \</span><br><span style="color: hsl(120, 100%, 40%);">+INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTCACHEDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \</span><br><span> "$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \</span><br><span> "$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \</span><br><span> "$(ASTSPOOLDIR)/voicemail" "$(ASTSPOOLDIR)/recording" \</span><br><span>@@ -779,7 +780,8 @@</span><br><span> done ; \</span><br><span> if [ "$(OVERWRITE)" = "y" ]; then \</span><br><span> echo "Updating asterisk.conf" ; \</span><br><span style="color: hsl(0, 100%, 40%);">- sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \</span><br><span style="color: hsl(120, 100%, 40%);">+ sed -e 's|^astcachedir.*$$|astcachedir => $(ASTCACHEDIR)|' \</span><br><span style="color: hsl(120, 100%, 40%);">+ -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \</span><br><span> -e 's|^astmoddir.*$$|astmoddir => $(ASTMODDIR)|' \</span><br><span> -e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \</span><br><span> -e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \</span><br><span>diff --git a/build_tools/install_subst b/build_tools/install_subst</span><br><span>index 5b5407a..9f67a80 100755</span><br><span>--- a/build_tools/install_subst</span><br><span>+++ b/build_tools/install_subst</span><br><span>@@ -26,6 +26,7 @@</span><br><span> src="$1"</span><br><span> dst="$2"</span><br><span> sed <"$src" \</span><br><span style="color: hsl(120, 100%, 40%);">+ -e "s|__ASTERISK_CACHE_DIR__|$ASTCACHEDIR|g" \</span><br><span> -e "s|__ASTERISK_DATA_DIR__|$ASTDATADIR|g" \</span><br><span> -e "s|__ASTERISK_DB_DIR__|$ASTDBDIR|g" \</span><br><span> -e "s|__ASTERISK_ETC_DIR__|$ASTETCDIR|g" \</span><br><span>diff --git a/build_tools/make_defaults_h b/build_tools/make_defaults_h</span><br><span>index 4a9fb55..acda651 100755</span><br><span>--- a/build_tools/make_defaults_h</span><br><span>+++ b/build_tools/make_defaults_h</span><br><span>@@ -7,6 +7,7 @@</span><br><span> */</span><br><span> #define DEFAULT_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#define DEFAULT_CACHE_DIR "${INSTALL_PATH}${ASTCACHEDIR}"</span><br><span> #define DEFAULT_CONFIG_DIR "${INSTALL_PATH}${ASTETCDIR}"</span><br><span> #define DEFAULT_MODULE_DIR "${INSTALL_PATH}${ASTMODDIR}"</span><br><span> #define DEFAULT_AGI_DIR "${INSTALL_PATH}${AGI_DIR}"</span><br><span>diff --git a/build_tools/mkpkgconfig b/build_tools/mkpkgconfig</span><br><span>index 9d29b9e..12dbd4e 100755</span><br><span>--- a/build_tools/mkpkgconfig</span><br><span>+++ b/build_tools/mkpkgconfig</span><br><span>@@ -32,6 +32,7 @@</span><br><span> cat <<EOF > "$PPATH/asterisk.pc"</span><br><span> install_prefix=$INSTALL_PREFIX</span><br><span> version_number=$ASTERISKVERSIONNUM</span><br><span style="color: hsl(120, 100%, 40%);">+cachedir=$ASTCACHEDIR</span><br><span> etcdir=$ASTETCDIR</span><br><span> libdir=$ASTLIBDIR</span><br><span> varlibdir=$ASTVARLIBDIR</span><br><span>diff --git a/configs/samples/asterisk.conf.sample b/configs/samples/asterisk.conf.sample</span><br><span>index 3c1a403..efb3386 100644</span><br><span>--- a/configs/samples/asterisk.conf.sample</span><br><span>+++ b/configs/samples/asterisk.conf.sample</span><br><span>@@ -1,4 +1,5 @@</span><br><span> [directories](!)</span><br><span style="color: hsl(120, 100%, 40%);">+astcachedir => /tmp</span><br><span> astetcdir => /etc/asterisk</span><br><span> astmoddir => /usr/lib/asterisk/modules</span><br><span> astvarlibdir => /var/lib/asterisk</span><br><span>diff --git a/configure b/configure</span><br><span>index f6e38b6..cd3c7c1 100755</span><br><span>--- a/configure</span><br><span>+++ b/configure</span><br><span>@@ -1287,6 +1287,7 @@</span><br><span> BUILD_VENDOR</span><br><span> BUILD_CPU</span><br><span> BUILD_PLATFORM</span><br><span style="color: hsl(120, 100%, 40%);">+astcachedir</span><br><span> astvarrundir</span><br><span> astlogdir</span><br><span> astspooldir</span><br><span>@@ -4652,6 +4653,7 @@</span><br><span> </span><br><span> # System default paths</span><br><span> astsbindir='${sbindir}'</span><br><span style="color: hsl(120, 100%, 40%);">+astcachedir='/tmp'</span><br><span> astetcdir='${sysconfdir}/asterisk'</span><br><span> astheaderdir='${includedir}/asterisk'</span><br><span> astlibdir='${libdir}'</span><br><span>@@ -4720,6 +4722,7 @@</span><br><span> ;;</span><br><span> solaris*)</span><br><span> if test ${prefix} = 'NONE'; then</span><br><span style="color: hsl(120, 100%, 40%);">+ astcachedir=/tmp</span><br><span> astetcdir=/var/etc/asterisk</span><br><span> astsbindir=/opt/asterisk/sbin</span><br><span> astlibdir=/opt/asterisk/lib</span><br><span>diff --git a/configure.ac b/configure.ac</span><br><span>index a9302b7..62d02ec 100644</span><br><span>--- a/configure.ac</span><br><span>+++ b/configure.ac</span><br><span>@@ -34,6 +34,7 @@</span><br><span> </span><br><span> # System default paths</span><br><span> AC_SUBST([astsbindir], ['${sbindir}'])dnl</span><br><span style="color: hsl(120, 100%, 40%);">+AC_SUBST([astcachedir], ['/tmp'])dnl</span><br><span> AC_SUBST([astetcdir], ['${sysconfdir}/asterisk'])dnl</span><br><span> AC_SUBST([astheaderdir], ['${includedir}/asterisk'])dnl</span><br><span> AC_SUBST([astlibdir], ['${libdir}'])dnl</span><br><span>@@ -98,6 +99,7 @@</span><br><span> ;;</span><br><span> solaris*)</span><br><span> if test ${prefix} = 'NONE'; then</span><br><span style="color: hsl(120, 100%, 40%);">+ astcachedir=/tmp</span><br><span> astetcdir=/var/etc/asterisk</span><br><span> astsbindir=/opt/asterisk/sbin</span><br><span> astlibdir=/opt/asterisk/lib</span><br><span>diff --git a/include/asterisk/paths.h b/include/asterisk/paths.h</span><br><span>index de28c75..e6f8c9f 100644</span><br><span>--- a/include/asterisk/paths.h</span><br><span>+++ b/include/asterisk/paths.h</span><br><span>@@ -18,6 +18,7 @@</span><br><span> #ifndef _ASTERISK_PATHS_H</span><br><span> #define _ASTERISK_PATHS_H</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+extern const char *ast_config_AST_CACHE_DIR;</span><br><span> extern const char *ast_config_AST_CONFIG_DIR;</span><br><span> extern const char *ast_config_AST_CONFIG_FILE;</span><br><span> extern const char *ast_config_AST_MODULE_DIR;</span><br><span>diff --git a/main/bucket.c b/main/bucket.c</span><br><span>index 8f6eafa..3e86996 100644</span><br><span>--- a/main/bucket.c</span><br><span>+++ b/main/bucket.c</span><br><span>@@ -73,6 +73,7 @@</span><br><span> #include "asterisk/json.h"</span><br><span> #include "asterisk/file.h"</span><br><span> #include "asterisk/module.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk/paths.h"</span><br><span> </span><br><span> /*! \brief Number of buckets for the container of schemes */</span><br><span> #define SCHEME_BUCKETS 53</span><br><span>@@ -899,7 +900,7 @@</span><br><span> {</span><br><span> int fd;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_string(file->path, "/tmp/bucket-XXXXXX", sizeof(file->path));</span><br><span style="color: hsl(120, 100%, 40%);">+ snprintf(file->path, sizeof(file->path), "%s/bucket-XXXXXX", ast_config_AST_CACHE_DIR);</span><br><span> </span><br><span> fd = mkstemp(file->path);</span><br><span> if (fd < 0) {</span><br><span>diff --git a/main/options.c b/main/options.c</span><br><span>index fc68c6d..593b908 100644</span><br><span>--- a/main/options.c</span><br><span>+++ b/main/options.c</span><br><span>@@ -98,6 +98,7 @@</span><br><span> char ast_defaultlanguage[MAX_LANGUAGE] = DEFAULT_LANGUAGE;</span><br><span> </span><br><span> struct _cfg_paths {</span><br><span style="color: hsl(120, 100%, 40%);">+ char cache_dir[PATH_MAX];</span><br><span> char config_dir[PATH_MAX];</span><br><span> char module_dir[PATH_MAX];</span><br><span> char spool_dir[PATH_MAX];</span><br><span>@@ -125,6 +126,7 @@</span><br><span> };</span><br><span> </span><br><span> static struct _cfg_paths cfg_paths = {</span><br><span style="color: hsl(120, 100%, 40%);">+ .cache_dir = DEFAULT_CACHE_DIR,</span><br><span> .config_dir = DEFAULT_CONFIG_DIR,</span><br><span> .module_dir = DEFAULT_MODULE_DIR,</span><br><span> .spool_dir = DEFAULT_SPOOL_DIR,</span><br><span>@@ -145,6 +147,7 @@</span><br><span> .ctl_file = "asterisk.ctl",</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+const char *ast_config_AST_CACHE_DIR = cfg_paths.cache_dir;</span><br><span> const char *ast_config_AST_CONFIG_DIR = cfg_paths.config_dir;</span><br><span> const char *ast_config_AST_CONFIG_FILE = cfg_paths.config_file;</span><br><span> const char *ast_config_AST_MODULE_DIR = cfg_paths.module_dir;</span><br><span>@@ -254,7 +257,9 @@</span><br><span> }</span><br><span> </span><br><span> for (v = ast_variable_browse(cfg, "directories"); v; v = v->next) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (!strcasecmp(v->name, "astetcdir")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!strcasecmp(v->name, "astcachedir")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(cfg_paths.cache_dir, v->value, sizeof(cfg_paths.cache_dir));</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!strcasecmp(v->name, "astetcdir")) {</span><br><span> ast_copy_string(cfg_paths.config_dir, v->value, sizeof(cfg_paths.config_dir));</span><br><span> } else if (!strcasecmp(v->name, "astspooldir")) {</span><br><span> ast_copy_string(cfg_paths.spool_dir, v->value, sizeof(cfg_paths.spool_dir));</span><br><span>diff --git a/main/pbx_variables.c b/main/pbx_variables.c</span><br><span>index e3c26f8..91b5bbb 100644</span><br><span>--- a/main/pbx_variables.c</span><br><span>+++ b/main/pbx_variables.c</span><br><span>@@ -327,6 +327,8 @@</span><br><span> s = ast_str_buffer(*str);</span><br><span> } else if (!strcmp(var, "SYSTEMNAME")) {</span><br><span> s = ast_config_AST_SYSTEM_NAME;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!strcmp(var, "ASTCACHEDIR")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ s = ast_config_AST_CACHE_DIR;</span><br><span> } else if (!strcmp(var, "ASTETCDIR")) {</span><br><span> s = ast_config_AST_CONFIG_DIR;</span><br><span> } else if (!strcmp(var, "ASTMODDIR")) {</span><br><span>diff --git a/makeopts.in b/makeopts.in</span><br><span>index 0d69fc8..27a5bdc 100644</span><br><span>--- a/makeopts.in</span><br><span>+++ b/makeopts.in</span><br><span>@@ -97,6 +97,7 @@</span><br><span> ASTMANDIR = @astmandir@</span><br><span> astvarlibdir = @astvarlibdir@</span><br><span> ASTVARLIBDIR = @astvarlibdir@</span><br><span style="color: hsl(120, 100%, 40%);">+ASTCACHEDIR = @astcachedir@</span><br><span> ASTDATADIR = @astdatadir@</span><br><span> ASTDBDIR = @astdbdir@</span><br><span> ASTKEYDIR = @astkeydir@</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15076">change 15076</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/15076"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Ic54e95199405abacd9e509cef5f08fa14c510b5d </div>
<div style="display:none"> Gerrit-Change-Number: 15076 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: lvl <digium@lvlconsultancy.nl> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>