<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18043">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cli: Add core dump info to core show settings.<br><br>Adds two pieces of information to the core show settings command<br>which are useful in the context of getting backtraces.<br><br>The first is to display whether or not Asterisk would generate<br>a core dump if it were to crash.<br><br>The second is to show the current running directory of Asterisk.<br><br>ASTERISK-29866 #close<br><br>Change-Id: Ic42c0a9ecc233381aad274d86c62808d1ebb4d83<br>---<br>M main/asterisk.c<br>1 file changed, 36 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/asterisk.c b/main/asterisk.c</span><br><span>index 4520318..de520a0 100644</span><br><span>--- a/main/asterisk.c</span><br><span>+++ b/main/asterisk.c</span><br><span>@@ -446,6 +446,23 @@</span><br><span>       }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Print the contents of a file */</span><br><span style="color: hsl(120, 100%, 40%);">+static int print_file(int fd, char *desc, const char *filename)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    FILE *f;</span><br><span style="color: hsl(120, 100%, 40%);">+      char c;</span><br><span style="color: hsl(120, 100%, 40%);">+       if (!(f = fopen(filename, "r"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+          return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     ast_cli(fd, "%s", desc);</span><br><span style="color: hsl(120, 100%, 40%);">+    while ((c = fgetc(f)) != EOF) {</span><br><span style="color: hsl(120, 100%, 40%);">+               ast_cli(fd, "%c", c);</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+     fclose(f);</span><br><span style="color: hsl(120, 100%, 40%);">+    /* no need for trailing new line, the file already has one */</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! \brief Give an overview of core settings */</span><br><span> static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)</span><br><span> {</span><br><span>@@ -454,6 +471,9 @@</span><br><span>  char eid_str[128];</span><br><span>   struct rlimit limits;</span><br><span>        char pbx_uuid[AST_UUID_STR_LEN];</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS)</span><br><span style="color: hsl(120, 100%, 40%);">+       char dir[PATH_MAX];</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span>      switch (cmd) {</span><br><span>       case CLI_INIT:</span><br><span>@@ -491,6 +511,8 @@</span><br><span>         ast_cli(a->fd, "  Current console verbosity:   %d\n", ast_verb_console_get());</span><br><span>  ast_cli(a->fd, "  Debug level:                 %d\n", option_debug);</span><br><span>    ast_cli(a->fd, "  Trace level:                 %d\n", option_trace);</span><br><span style="color: hsl(120, 100%, 40%);">+     ast_cli(a->fd, "  Dump core on crash:          %s\n", ast_opt_dump_core ? "Yes" : "No");</span><br><span style="color: hsl(120, 100%, 40%);">+     print_file(a->fd, "  Core dump file:              ", "/proc/sys/kernel/core_pattern");</span><br><span>        ast_cli(a->fd, "  Maximum load average:        %lf\n", ast_option_maxload);</span><br><span> #if defined(HAVE_SYSINFO)</span><br><span>        ast_cli(a->fd, "  Minimum free memory:         %ld MB\n", option_minmemfree);</span><br><span>@@ -510,6 +532,20 @@</span><br><span>    ast_cli(a->fd, "  Default language:            %s\n", ast_defaultlanguage);</span><br><span>     ast_cli(a->fd, "  Language prefix:             %s\n", ast_language_is_prefix ? "Enabled" : "Disabled");</span><br><span>     ast_cli(a->fd, "  User name and group:         %s/%s\n", ast_config_AST_RUN_USER, ast_config_AST_RUN_GROUP);</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS)</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(HAVE_EUIDACCESS) && !defined(HAVE_EACCESS)</span><br><span style="color: hsl(120, 100%, 40%);">+#define eaccess euidaccess</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+  if (!getcwd(dir, sizeof(dir))) {</span><br><span style="color: hsl(120, 100%, 40%);">+              if (eaccess(dir, R_OK | X_OK | F_OK)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                       ast_cli(a->fd, "  Running directory:           %s\n", "Unable to access");</span><br><span style="color: hsl(120, 100%, 40%);">+             } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      ast_cli(a->fd, "  Running directory:           %s (%s)\n", dir, "Unable to access");</span><br><span style="color: hsl(120, 100%, 40%);">+           }</span><br><span style="color: hsl(120, 100%, 40%);">+     } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              ast_cli(a->fd, "  Running directory:           %s\n", dir);</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS) */</span><br><span>    ast_cli(a->fd, "  Executable includes:         %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES) ? "Enabled" : "Disabled");</span><br><span>        ast_cli(a->fd, "  Transcode via SLIN:          %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN) ? "Enabled" : "Disabled");</span><br><span>   ast_cli(a->fd, "  Transmit silence during rec: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) ? "Enabled" : "Disabled");</span><br><span>@@ -3861,9 +3897,6 @@</span><br><span> </span><br><span>         {</span><br><span> #if defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-#if defined(HAVE_EUIDACCESS) && !defined(HAVE_EACCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-#define eaccess euidaccess</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span>             char dir[PATH_MAX];</span><br><span>          if (!getcwd(dir, sizeof(dir)) || eaccess(dir, R_OK | X_OK | F_OK)) {</span><br><span>                         fprintf(stderr, "Unable to access the running directory (%s).  Changing to '/' for compatibility.\n", strerror(errno));</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18043">change 18043</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/+/18043"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: Ic42c0a9ecc233381aad274d86c62808d1ebb4d83 </div>
<div style="display:none"> Gerrit-Change-Number: 18043 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>