rx(1) choses 9p, ssh, and bsd protocols in that order, this patch adds support for -l remoteuser and -r (strip CR's) options to the latter two. Notes: Wed Nov 3 12:03:46 EST 2004 rsc i rewrote most of the patch to conform to the style of the rest of the program. Reference: /n/sources/patch/applied/rx Date: Wed Nov 3 18:03:59 CET 2004 Reviewed-by: rsc --- /sys/src/cmd/rx.c Wed Nov 3 18:03:59 2004 +++ /sys/src/cmd/rx.c Wed Nov 3 18:03:59 2004 @@ -15,7 +15,7 @@ char *buildargs(char*[]); int send(int); void error(char*, char*); -void sshexec(char *host, char *cmd); +void sshexec(char*, char*); void usage(void) @@ -120,17 +120,18 @@ void tcpexec(int fd, char *addr, char *cmd) { - char *cp, *ep, *u, buf[4096]; + char *cp, *ep, *u, *ru, buf[4096]; int kid, n; - char *r; /* * do the ucb authentication and send command */ u = getuser(); - r = ruser ? ruser : u; + ru = ruser; + if(ru == nil) + ru = u; if(write(fd, "", 1)<0 || write(fd, u, strlen(u)+1)<0 - || write(fd, r, strlen(r)+1)<0 || write(fd, cmd, strlen(cmd)+1)<0){ + || write(fd, ru, strlen(ru)+1)<0 || write(fd, cmd, strlen(cmd)+1)<0){ close(fd); error("can't authenticate to", addr); } @@ -181,7 +182,22 @@ void sshexec(char *host, char *cmd) { - execl("/bin/ssh", "ssh", "-iCm", host, cmd, 0); + char *argv[10]; + int n; + + n = 0; + argv[n++] = "ssh"; + argv[n++] = "-iCm"; + if(!returns) + argv[n++] = "-r"; + if(ruser){ + argv[n++] = "-l"; + argv[n++] = ruser; + } + argv[n++] = host; + argv[n++] = cmd; + argv[n] = 0; + exec("/bin/ssh", argv); } int