From 7c6d9c72353d27355a1012cdd4d151e8a8f15d73 Mon Sep 17 00:00:00 2001
From: Terry Wilson <twilson@digium.com>
Date: Tue, 13 Jan 2009 23:00:27 +0000
Subject: [PATCH] Add option to hide console connect messages

(closes issue #14222)
Reported by: jamesgolovich
Patches:
      asterisk-hideconnect.diff.txt uploaded by jamesgolovich (license 176)
Tested by: otherwiseguy


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@168585 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 Makefile                   | 1 +
 include/asterisk/options.h | 3 +++
 main/asterisk.c            | 9 +++++++--
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 519776f942..dc2a208cd6 100644
--- a/Makefile
+++ b/Makefile
@@ -726,6 +726,7 @@ samples: adsi
 		echo ";rungroup = asterisk ; The group to run as" ; \
 		echo ";lightbackground = yes ; If your terminal is set for a light-colored background" ; \
 		echo "documentation_language = en_US ; Set the Language you want Documentation displayed in. Value is in the same format as locale names" ; \
+		echo ";hideconnect = yes ; Hide messages displayed when a remote console connects and disconnects" ; \
 		echo "" ; \
 		echo "; Changing the following lines may compromise your security." ; \
 		echo ";[files]" ; \
diff --git a/include/asterisk/options.h b/include/asterisk/options.h
index 54295e8ad5..065d0c9a1b 100644
--- a/include/asterisk/options.h
+++ b/include/asterisk/options.h
@@ -88,6 +88,8 @@ enum ast_option_flags {
 	AST_OPT_FLAG_INITIATED_SECONDS = (1 << 26),
 	/*! Force black background */
 	AST_OPT_FLAG_FORCE_BLACK_BACKGROUND = (1 << 27),
+	/*! Hide remote console connect messages on console */
+	AST_OPT_FLAG_HIDE_CONSOLE_CONNECT = (1 << 28),
 };
 
 /*! These are the options that set by default when Asterisk starts */
@@ -119,6 +121,7 @@ enum ast_option_flags {
 #define ast_opt_verb_file		ast_test_flag(&ast_options, AST_OPT_FLAG_VERBOSE_FILE)
 #define ast_opt_light_background		ast_test_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND)
 #define ast_opt_force_black_background		ast_test_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND)
+#define ast_opt_hide_connect		ast_test_flag(&ast_options, AST_OPT_FLAG_HIDE_CONSOLE_CONNECT)
 
 extern struct ast_flags ast_options;
 
diff --git a/main/asterisk.c b/main/asterisk.c
index 9b8b3f78a1..d48c156151 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -1212,7 +1212,9 @@ static void *netconsole(void *vconsole)
 				break;
 		}
 	}
-	ast_verb(3, "Remote UNIX connection disconnected\n");
+	if (!ast_opt_hide_connect) {
+		ast_verb(3, "Remote UNIX connection disconnected\n");
+	}
 	close(con->fd);
 	close(con->p[0]);
 	close(con->p[1]);
@@ -1289,8 +1291,9 @@ static void *listener(void *unused)
 					fdprint(s, "No more connections allowed\n");
 					ast_log(LOG_WARNING, "No more connections allowed\n");
 					close(s);
-				} else if (consoles[x].fd > -1) 
+				} else if ((consoles[x].fd > -1) && (!ast_opt_hide_connect)) {
 					ast_verb(3, "Remote UNIX connection\n");
+				}
 			}
 		}
 	}
@@ -2953,6 +2956,8 @@ static void ast_readconfig(void)
 			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_LIGHT_BACKGROUND);
 		} else if (!strcasecmp(v->name, "forceblackbackground")) {
 			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
+		} else if (!strcasecmp(v->name, "hideconnect")) {
+			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIDE_CONSOLE_CONNECT);
 		}
 	}
 	for (v = ast_variable_browse(cfg, "compat"); v; v = v->next) {
-- 
GitLab