[Asterisk-code-review] asterisk.c: Warn of incompatibilities with remote console. (asterisk[master])

N A asteriskteam at digium.com
Sat Mar 5 05:47:12 CST 2022


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18184 )


Change subject: asterisk.c: Warn of incompatibilities with remote console.
......................................................................

asterisk.c: Warn of incompatibilities with remote console.

Some command line options to Asterisk only apply when Asterisk
is started and cannot be used with remote console mode. If a
user tries to use any of these, they are currently simply
silently ignored.

This prints out a warning if incompatible options are used,
informing users that an option used cannot be used with remote
console mode. Additionally, some clarifications are added to
the help text and man page.

ASTERISK-22246

Change-Id: I980a5380ef2c19e8ea348596396d5382893c4337
---
M doc/asterisk.8
M main/asterisk.c
2 files changed, 52 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/84/18184/1

diff --git a/doc/asterisk.8 b/doc/asterisk.8
index e5991d9..b45ac88 100644
--- a/doc/asterisk.8
+++ b/doc/asterisk.8
@@ -195,7 +195,8 @@
 .TP
 \-T
 Add timestamp to all non-command related output going to the console
-when running with verbose and/or logging to the console.
+when running with verbose and/or logging to the console. Can only be
+used at startup (e.g. not with remote console mode).
 .TP
 \-U \fIuser\fR
 Run as user \fIuser\fR instead of the
diff --git a/main/asterisk.c b/main/asterisk.c
index de520a0..04e6fb3 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -3360,7 +3360,7 @@
 	printf("   -t              Record soundfiles in /var/tmp and move them where they\n");
 	printf("                   belong after they are done\n");
 	printf("   -T              Display the time in [Mmm dd hh:mm:ss] format for each line\n");
-	printf("                   of output to the CLI\n");
+	printf("                   of output to the CLI. Cannot be used with remote console mode.\n\n");
 	printf("   -v              Increase verbosity (multiple v's = more verbose)\n");
 	printf("   -x <cmd>        Execute command <cmd> (implies -r)\n");
 	printf("   -X              Enable use of #exec in asterisk.conf\n");
@@ -3716,6 +3716,55 @@
 		}
 	}
 
+	if (ast_opt_remote) {
+		int didwarn = 0;
+		optind = 1;
+
+		/* Not all options can be used with remote console. Warn if they're used. */
+		while ((c = getopt(argc, argv, getopt_settings)) != -1) {
+			switch (c) {
+			/* okay to run with remote console */
+			case 'B': /* force black background */
+			case 'd': /* debug */
+			case 'h': /* help */
+			case 'I': /* obsolete timing option: warning already thrown if used */
+			case 'L': /* max load */
+			case 'M': /* max calls */
+			case 'n': /* no color */
+			case 'R': /* reconnect */
+			case 'r': /* remote */
+			case 's': /* set socket path */
+			case 'V': /* version */
+			case 'v': /* verbose */
+			case 'W': /* white background */
+			case 'x': /* remote execute */
+			case '?': /* ? */
+				break;
+			/* can only be run when Asterisk is starting */
+			case 'X': /* enables #exec for asterisk.conf only. */
+			case 'C': /* set config path */
+			case 'c': /* foreground console */
+			case 'e': /* minimum memory free */
+			case 'F': /* always fork */
+			case 'f': /* no fork */
+			case 'G': /* run group */
+			case 'g': /* dump core */
+			case 'i': /* init keys */
+			case 'm': /* mute */
+			case 'p': /* high priority */
+			case 'q': /* quiet */
+			case 'T': /* timestamp */
+			case 't': /* cache record files */
+			case 'U': /* run user */
+				fprintf(stderr, "'%c' option is not compatible with remote console mode and has no effect.\n", c);
+				didwarn = 1;
+			}
+		}
+		if (didwarn) {
+			fprintf(stderr, "\n"); /* if any warnings print out, make them stand out */
+		}
+	}
+
 	/* For remote connections, change the name of the remote connection.
 	 * We do this for the benefit of init scripts (which need to know if/when
 	 * the main asterisk process has died yet). */

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18184
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I980a5380ef2c19e8ea348596396d5382893c4337
Gerrit-Change-Number: 18184
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220305/f1a97a91/attachment.html>


More information about the asterisk-code-review mailing list