Skip to content

Commit

Permalink
Fix #81 - support ssh user@host syntax
Browse files Browse the repository at this point in the history
Should be less confusing to new users
  • Loading branch information
davidrg committed Aug 27, 2022
1 parent 609c60b commit 4220c48
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions kermit/k95/ckuusr.c
Original file line number Diff line number Diff line change
Expand Up @@ -10712,11 +10712,40 @@ necessary DLLs did not load. Use SHOW NETWORK to check network status.\n");
}
switch (cmresult.nresult) { /* SSH keyword */
case XSSH_OPN: /* SSH OPEN */
char tmpline[LINBUFSIZ], tmpline2[LINBUFSIZ];
char* token;

if (!havehost) {
if ((x = cmfld("Host","",&s,xxstring)) < 0)
return(x);
ckstrncpy(line,s,LINBUFSIZ);
if ((x = cmfld("Host","",&s,xxstring)) < 0)
return(x);
ckstrncpy(line,s,LINBUFSIZ);
}

/* Try to handle username@hostname syntax */
ckstrncpy(tmpline,line,LINBUFSIZ);
token = strtok(tmpline, "@");
if (token != NULL) {
/* First part is the username */
makestr(&ssh_tmpuid,brstrip(token));

debug(F110, "Found username in the hostname!", ssh_tmpuid, 0);

token = strtok(NULL, "@");
if (token != NULL) {
/* Second part is the hostname */
debug(F110, "Found hostname", token, 0);
ckstrncpy(tmpline2,token,LINBUFSIZ);
token = strtok(NULL, "@");
if (token != NULL) {
/* Error - there should not be a third part. Give up */
debug(F110, "Error - found third token. Giving up.", token, 0);
makestr(&ssh_tmpuid,NULL);
} else {
ckstrncpy(line,tmpline2,LINBUFSIZ);
}
}
}

/* Parse [ port ] [ switches ] */
cmfdbi(&kw, /* Switches */
_CMKEY,
Expand Down

0 comments on commit 4220c48

Please sign in to comment.