diff options
Diffstat (limited to 'rtty.c')
-rw-r--r-- | rtty.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -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"); } |