Skip to content

Commit 4585a9c

Browse files
InterLinked1jcolp
authored andcommitted
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 ASTERISK-26582 Change-Id: I980a5380ef2c19e8ea348596396d5382893c4337
1 parent 306ce09 commit 4585a9c

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

doc/asterisk.8

+3-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ too many simultaneous calls.
158158
.TP
159159
\-n
160160
Disable ANSI colors even on terminals capable of displaying them.
161+
This option can be used only at startup (e.g. not with remote console).
161162
.TP
162163
\-p
163164
If supported by the operating system (and executing as root),
@@ -195,7 +196,8 @@ then move them into the final location when done.
195196
.TP
196197
\-T
197198
Add timestamp to all non-command related output going to the console
198-
when running with verbose and/or logging to the console.
199+
when running with verbose and/or logging to the console. Can only be
200+
used at startup (e.g. not with remote console mode).
199201
.TP
200202
\-U \fIuser\fR
201203
Run as user \fIuser\fR instead of the

main/asterisk.c

+51-2
Original file line numberDiff line numberDiff line change
@@ -3351,7 +3351,7 @@ static int show_cli_help(void)
33513351
printf(" -L <load> Limit the maximum load average before rejecting new calls\n");
33523352
printf(" -M <value> Limit the maximum number of calls to the specified value\n");
33533353
printf(" -m Mute debugging and console output on the console\n");
3354-
printf(" -n Disable console colorization\n");
3354+
printf(" -n Disable console colorization. Can be used only at startup.\n");
33553355
printf(" -p Run as pseudo-realtime thread\n");
33563356
printf(" -q Quiet mode (suppress output)\n");
33573357
printf(" -r Connect to Asterisk on this machine\n");
@@ -3360,7 +3360,7 @@ static int show_cli_help(void)
33603360
printf(" -t Record soundfiles in /var/tmp and move them where they\n");
33613361
printf(" belong after they are done\n");
33623362
printf(" -T Display the time in [Mmm dd hh:mm:ss] format for each line\n");
3363-
printf(" of output to the CLI\n");
3363+
printf(" of output to the CLI. Cannot be used with remote console mode.\n\n");
33643364
printf(" -v Increase verbosity (multiple v's = more verbose)\n");
33653365
printf(" -x <cmd> Execute command <cmd> (implies -r)\n");
33663366
printf(" -X Enable use of #exec in asterisk.conf\n");
@@ -3716,6 +3716,55 @@ int main(int argc, char *argv[])
37163716
}
37173717
}
37183718

3719+
if (ast_opt_remote) {
3720+
int didwarn = 0;
3721+
optind = 1;
3722+
3723+
/* Not all options can be used with remote console. Warn if they're used. */
3724+
while ((c = getopt(argc, argv, getopt_settings)) != -1) {
3725+
switch (c) {
3726+
/* okay to run with remote console */
3727+
case 'B': /* force black background */
3728+
case 'd': /* debug */
3729+
case 'h': /* help */
3730+
case 'I': /* obsolete timing option: warning already thrown if used */
3731+
case 'L': /* max load */
3732+
case 'M': /* max calls */
3733+
case 'R': /* reconnect */
3734+
case 'r': /* remote */
3735+
case 's': /* set socket path */
3736+
case 'V': /* version */
3737+
case 'v': /* verbose */
3738+
case 'W': /* white background */
3739+
case 'x': /* remote execute */
3740+
case '?': /* ? */
3741+
break;
3742+
/* can only be run when Asterisk is starting */
3743+
case 'X': /* enables #exec for asterisk.conf only. */
3744+
case 'C': /* set config path */
3745+
case 'c': /* foreground console */
3746+
case 'e': /* minimum memory free */
3747+
case 'F': /* always fork */
3748+
case 'f': /* no fork */
3749+
case 'G': /* run group */
3750+
case 'g': /* dump core */
3751+
case 'i': /* init keys */
3752+
case 'm': /* mute */
3753+
case 'n': /* no color */
3754+
case 'p': /* high priority */
3755+
case 'q': /* quiet */
3756+
case 'T': /* timestamp */
3757+
case 't': /* cache record files */
3758+
case 'U': /* run user */
3759+
fprintf(stderr, "'%c' option is not compatible with remote console mode and has no effect.\n", c);
3760+
didwarn = 1;
3761+
}
3762+
}
3763+
if (didwarn) {
3764+
fprintf(stderr, "\n"); /* if any warnings print out, make them stand out */
3765+
}
3766+
}
3767+
37193768
/* For remote connections, change the name of the remote connection.
37203769
* We do this for the benefit of init scripts (which need to know if/when
37213770
* the main asterisk process has died yet). */

0 commit comments

Comments
 (0)