@@ -446,6 +446,23 @@ void ast_unregister_thread(void *id)
446446 }
447447}
448448
449+ /*! \brief Print the contents of a file */
450+ static int print_file (int fd , char * desc , const char * filename )
451+ {
452+ FILE * f ;
453+ char c ;
454+ if (!(f = fopen (filename , "r" ))) {
455+ return -1 ;
456+ }
457+ ast_cli (fd , "%s" , desc );
458+ while ((c = fgetc (f )) != EOF ) {
459+ ast_cli (fd , "%c" , c );
460+ }
461+ fclose (f );
462+ /* no need for trailing new line, the file already has one */
463+ return 0 ;
464+ }
465+
449466/*! \brief Give an overview of core settings */
450467static char * handle_show_settings (struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
451468{
@@ -454,6 +471,9 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c
454471 char eid_str [128 ];
455472 struct rlimit limits ;
456473 char pbx_uuid [AST_UUID_STR_LEN ];
474+ #if defined(HAVE_EACCESS ) || defined(HAVE_EUIDACCESS )
475+ char dir [PATH_MAX ];
476+ #endif
457477
458478 switch (cmd ) {
459479 case CLI_INIT :
@@ -491,6 +511,8 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c
491511 ast_cli (a -> fd , " Current console verbosity: %d\n" , ast_verb_console_get ());
492512 ast_cli (a -> fd , " Debug level: %d\n" , option_debug );
493513 ast_cli (a -> fd , " Trace level: %d\n" , option_trace );
514+ ast_cli (a -> fd , " Dump core on crash: %s\n" , ast_opt_dump_core ? "Yes" : "No" );
515+ print_file (a -> fd , " Core dump file: " , "/proc/sys/kernel/core_pattern" );
494516 ast_cli (a -> fd , " Maximum load average: %lf\n" , ast_option_maxload );
495517#if defined(HAVE_SYSINFO )
496518 ast_cli (a -> fd , " Minimum free memory: %ld MB\n" , option_minmemfree );
@@ -510,6 +532,20 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c
510532 ast_cli (a -> fd , " Default language: %s\n" , ast_defaultlanguage );
511533 ast_cli (a -> fd , " Language prefix: %s\n" , ast_language_is_prefix ? "Enabled" : "Disabled" );
512534 ast_cli (a -> fd , " User name and group: %s/%s\n" , ast_config_AST_RUN_USER , ast_config_AST_RUN_GROUP );
535+ #if defined(HAVE_EACCESS ) || defined(HAVE_EUIDACCESS )
536+ #if defined(HAVE_EUIDACCESS ) && !defined(HAVE_EACCESS )
537+ #define eaccess euidaccess
538+ #endif
539+ if (!getcwd (dir , sizeof (dir ))) {
540+ if (eaccess (dir , R_OK | X_OK | F_OK )) {
541+ ast_cli (a -> fd , " Running directory: %s\n" , "Unable to access" );
542+ } else {
543+ ast_cli (a -> fd , " Running directory: %s (%s)\n" , dir , "Unable to access" );
544+ }
545+ } else {
546+ ast_cli (a -> fd , " Running directory: %s\n" , dir );
547+ }
548+ #endif /* defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS) */
513549 ast_cli (a -> fd , " Executable includes: %s\n" , ast_test_flag (& ast_options , AST_OPT_FLAG_EXEC_INCLUDES ) ? "Enabled" : "Disabled" );
514550 ast_cli (a -> fd , " Transcode via SLIN: %s\n" , ast_test_flag (& ast_options , AST_OPT_FLAG_TRANSCODE_VIA_SLIN ) ? "Enabled" : "Disabled" );
515551 ast_cli (a -> fd , " Transmit silence during rec: %s\n" , ast_test_flag (& ast_options , AST_OPT_FLAG_TRANSMIT_SILENCE ) ? "Enabled" : "Disabled" );
@@ -3861,9 +3897,6 @@ int main(int argc, char *argv[])
38613897
38623898 {
38633899#if defined(HAVE_EACCESS ) || defined(HAVE_EUIDACCESS )
3864- #if defined(HAVE_EUIDACCESS ) && !defined(HAVE_EACCESS )
3865- #define eaccess euidaccess
3866- #endif
38673900 char dir [PATH_MAX ];
38683901 if (!getcwd (dir , sizeof (dir )) || eaccess (dir , R_OK | X_OK | F_OK )) {
38693902 fprintf (stderr , "Unable to access the running directory (%s). Changing to '/' for compatibility.\n" , strerror (errno ));
0 commit comments