Merge branch 'client_opt_k'

This commit is contained in:
Bryan Stansell 2020-10-18 10:17:59 -07:00
commit 15359cd1f3
No known key found for this signature in database
GPG Key ID: 28E4B7253029E7F6
3 changed files with 27 additions and 5 deletions

View File

@ -285,6 +285,7 @@ Usage(int wantfull)
"f(F) force read/write connection (and replay)",
"h output this message",
"i(I) display status info in machine-parseable form (on master)",
"k abort connection if the console is not 'up'",
"l user use username instead of current username",
"M master master server to poll first",
"n do not read system-wide config file",
@ -312,7 +313,7 @@ Usage(int wantfull)
%s [generic-args] [-iIuwWx] [console]\n\
%s [generic-args] [-hPqQrRV] [-[bB] message] [-d [user][@console]]\n\
[-t [user][@console] message] [-[zZ] cmd]\n\n\
generic-args: [-7DEnUv] [-c cred] [-C config] [-M master]\n\
generic-args: [-7DEknUv] [-c cred] [-C config] [-M master]\n\
[-p port] [-l username]\n", progname, progname, progname);
if (wantfull) {
@ -1471,8 +1472,13 @@ CallUp(CONSFILE *pcf, char *pcMaster, char *pcMach, char *pcHow,
/* try to grok the state of the console */
FilePrint(pcf, FLAGFALSE, "%c%c=", chAttn, chEsc);
r = ReadReply(pcf, FLAGFALSE);
if (strncmp(r, "[unknown", 8) != 0 && strncmp(r, "[up]", 4) != 0)
FileWrite(cfstdout, FLAGFALSE, r, -1);
if (strncmp(r, "[unknown", 8) != 0 && strncmp(r, "[up]", 4) != 0) {
FileWrite(cfstdout, FLAGFALSE, r, -1);
if (config->exitdown == FLAGTRUE) {
Error("Console is not 'up'. Exiting. (-k)");
Bye(EX_UNAVAILABLE);
}
}
/* try to grok the version of the server */
FilePrint(pcf, FLAGFALSE, "%c%c%c", chAttn, chEsc, 0xD6);
@ -1905,7 +1911,7 @@ main(int argc, char **argv)
int fLocal;
static STRING *acPorts = (STRING *)0;
static char acOpts[] =
"7aAb:B:c:C:d:De:EfFhiIl:M:np:PqQrRsSt:uUvVwWxz:Z:";
"7aAb:B:c:C:d:De:EfFhikIl:M:np:PqQrRsSt:uUvVwWxz:Z:";
extern int optind;
extern int optopt;
extern char *optarg;
@ -2035,6 +2041,10 @@ main(int argc, char **argv)
pcCmd = "info";
break;
case 'k':
optConf->exitdown = FLAGTRUE;
break;
case 'l':
if ((optConf->username = StrDup(optarg)) == (char *)0)
OutOfMem();
@ -2232,6 +2242,13 @@ main(int argc, char **argv)
else
config->striphigh = FLAGFALSE;
if (optConf->exitdown != FLAGUNKNOWN)
config->exitdown = optConf->exitdown;
else if (pConfig->exitdown != FLAGUNKNOWN)
config->exitdown = pConfig->exitdown;
else
config->exitdown = FLAGFALSE;
if (optConf->escape != (char *)0)
ParseEsc(optConf->escape);
else if (pConfig->escape != (char *)0)

View File

@ -28,7 +28,7 @@ console \- console server client program
.IR cmd ]
.PP
.IR generic-args :
.RB [ \-7DEnUv ]
.RB [ \-7DEknUv ]
.RB [ \-c
.IR cred ]
.RB [ \-C
@ -178,6 +178,10 @@ Same as
.B \-i
but just acts on the primary server.
.TP
.B \-k
Abort the connection if the console is not in the `up' state immediately
upon connecting.
.TP
.BI \-l user
Set the login name used for authentication to
.IR user .

View File

@ -12,6 +12,7 @@ typedef struct config {
char *port;
char *escape;
FLAG striphigh;
FLAG exitdown;
unsigned short replay;
unsigned short playback;
#if HAVE_OPENSSL