From 92d63efb7087b24910dee2e44f0fed51895e4fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 14 Jul 2021 23:33:59 +0200 Subject: Add SSHPASS compile-time flag --- INTRO | 12 ++++++++++++ rtty.c | 23 +++++++++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/INTRO b/INTRO index 3dec1e9..db55883 100644 --- a/INTRO +++ b/INTRO @@ -16,3 +16,15 @@ a brief overview: Editor: ed(1) Pager: cat(1), pr(1) History: fc (see sh(1)) + + + Supplying passwords to rtty + +If compiled with -DSSHPASS, rtty will run sshpass(1) with the -e +flag, expecting a password to be set in the SSHPASS environment +variable. + +If you often need to log into remote servers without public key +authentication, consider compiling a special version of rtty -- I +suggest the name rttyp -- and installing it alongside the normal +version of rtty. diff --git a/rtty.c b/rtty.c index b5fa5a8..cc5e38f 100644 --- a/rtty.c +++ b/rtty.c @@ -22,7 +22,7 @@ main(int argc, char *argv[]) { char bufin[MAXBUF], bufout[MAXBUF], *bi, *bo, in[30], **nargv, out[30]; fd_set rfds0, rfds1; - int fdin, fdout, i, n; + int fdin, fdout, i, n, offset; struct timeval tv; signal(SIGCHLD, sigchld); @@ -44,17 +44,24 @@ main(int argc, char *argv[]) dup2(fdout, 1); /* Create new argument vector. */ - if(!(nargv = malloc(sizeof(char *)*(argc+2)))) + if(!(nargv = malloc(sizeof(char *)*(argc+10)))) err(1, "malloc"); - nargv[0] = "ssh"; - nargv[1] = "-tt"; - nargv[2] = "-oBatchMode=yes"; + offset = -1; +#ifdef SSHPASS + nargv[++offset] = "sshpass"; + nargv[++offset] = "-e"; +#endif + nargv[++offset] = "ssh"; + nargv[++offset] = "-tt"; +#ifndef SSHPASS + nargv[++offset] = "-oBatchMode=yes"; +#endif for(i = 1; i < argc; i++) - nargv[i+2] = argv[i]; - nargv[argc+2] = NULL; + nargv[i+offset] = argv[i]; + nargv[argc+offset] = NULL; /* Exec into ssh. */ - execvp("ssh", nargv); + execvp(nargv[0], nargv); err(1, "execvp"); } -- cgit v1.2.3