X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vsyssh%2Fvsyssh.c;fp=vsyssh%2Fvsyssh.c;h=b0377caa9112f04065cbd20d83f21af227279d57;hb=d2f02b8408801a06b63b1b922f6af4c6b14fb5ef;hp=0000000000000000000000000000000000000000;hpb=8ed94d4c37a320acc03f1f3f6523201b42202f00;p=vsys.git diff --git a/vsyssh/vsyssh.c b/vsyssh/vsyssh.c new file mode 100644 index 0000000..b0377ca --- /dev/null +++ b/vsyssh/vsyssh.c @@ -0,0 +1,59 @@ +/* gcc -Wall -O2 -g chpid.c -o chpid */ +#define _XOPEN_SOURCE +#define _XOPEN_SOURCE_EXTENDED +#define _SVID_SOURCE +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv, char **envp) +{ + if (argc<3) { + printf("Usage: vsyssh \n"); + exit(1); + } + else { + int vfd0,vfd1; + char *inf,*outf; + inf=(char *)malloc(strlen(argv[1])+3); + outf=(char *)malloc(strlen(argv[2])+4); + strcpy(inf,argv[1]); + strcpy(inf,argv[2]); + strcat(inf,".in"); + strcat(outf,".out"); + + vfd1 = open(inf,O_WRONLY); + vfd0 = open(outf,O_RDONLY); + + if (vfd0==-1 || vfd1 == -1) { + printf("Error opening vsys entry %s\n", argv[1]); + exit(1); + } + + close(0); + close(1); + + dup2(vfd0,0); + dup2(vfd1,1); + + execve(argv[3],argv+3,envp); + } + + return; + +}