diff options
author | John Ankarström <john@ankarstrom.se> | 2021-07-14 23:33:59 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-07-14 23:33:59 +0200 |
commit | 92d63efb7087b24910dee2e44f0fed51895e4fd9 (patch) | |
tree | 54cb3ad88a7956d1095c48b2e00289eef87a33c2 | |
parent | 1171342a0c326f464b46a0e2ae9d0f215fa014fa (diff) | |
download | rtty-92d63efb7087b24910dee2e44f0fed51895e4fd9.tar.gz |
Add SSHPASS compile-time flag
-rw-r--r-- | INTRO | 12 | ||||
-rw-r--r-- | rtty.c | 23 |
2 files changed, 27 insertions, 8 deletions
@@ -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. @@ -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"); } |