diff options
author | Matt Johnston <matt@ucc.asn.au> | 2006-03-08 12:53:09 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2006-03-08 12:53:09 +0000 |
commit | e4697de1757849bccfeb201ed2f2f98996e11934 (patch) | |
tree | 4490ac0dce1170ba5d1f0db4c9dc68ab4a764aa2 /scp.c | |
parent | 1dc06524446b6ed8fa152ff99b0d5763214737f2 (diff) | |
parent | b5989964979e3ee885eeb6d0758d96605b131a7b (diff) |
merge of 4cbdd6e0a0d8c061075b9ed7609a06c4547f67d3
and 5d396842815593611f0d61762440145d1fc74d5a
--HG--
extra : convert_revision : 4c883eb469d2d251ee8abddbc11ae4005db6da17
Diffstat (limited to 'scp.c')
-rw-r--r-- | scp.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -166,8 +166,22 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc) close(reserved[0]); close(reserved[1]); + // uClinux needs to build the args here before vforking, + // otherwise we do it later on. +#ifdef __uClinux__ + args.list[0] = ssh_program; + if (remuser != NULL) + addargs(&args, "-l%s", remuser); + addargs(&args, "%s", host); + addargs(&args, "%s", cmd); +#endif /* __uClinux__ */ + /* Fork a child to execute the command on the remote host using ssh. */ +#ifdef __uClinux__ + do_cmd_pid = vfork(); +#else do_cmd_pid = fork(); +#endif /* __uClinux__ */ if (do_cmd_pid == 0) { /* Child. */ close(pin[1]); @@ -177,6 +191,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc) close(pin[0]); close(pout[1]); +#ifndef __uClinux__ args.list[0] = ssh_program; if (remuser != NULL) { addargs(&args, "-l"); @@ -184,6 +199,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc) } addargs(&args, "%s", host); addargs(&args, "%s", cmd); +#endif execvp(ssh_program, args.list); perror(ssh_program); @@ -192,6 +208,22 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc) fprintf(stderr, "Fatal error: fork: %s\n", strerror(errno)); exit(1); } + +#ifdef __uClinux__ + /* clean up command */ + /* pop cmd */ + free(args->list[--args->num]); + args->list[args->num]=NULL; + /* pop host */ + free(args->list[--args->num-1]); + args->list[args->num]=NULL; + /* pop user */ + if (remuser != NULL) { + free(args->list[--args->num-1]); + args->list[args->num]=NULL; + } +#endif /* __uClinux__ + /* Parent. Close the other side, and return the local side. */ close(pin[0]); *fdout = pin[1]; |