/* * quick and dirty "rexec" command line client. * spd@daphne.cps.unizar.es * * NOTE: we should also read d_fderr; but I don't need it rigth now * NOTE: we should add error checking */ #include #include /* atoi */ #include /* getpid */ #include #include #include #include #include #include #include int main(int argc, char *argv[]) { struct servent *s; char *pass; char *ahost; int n=0; char buf[BUFSIZ]; int d_fdout,d_fderr; if (argc!=4) { fprintf( stderr,"uso: %s user host \"cmd\"\n", argv[0] ); exit(1); } pass=getpass("password: "); setservent(1); s=getservbyname("exec", "tcp"); ahost=strdup(argv[2]); fprintf(stderr,"%s:%s@%s:%d %s\n", pass,argv[1],ahost,s->s_port, argv[3]); d_fdout=rexec(&ahost,s->s_port, argv[1], pass, argv[3], &d_fderr); endservent(); while ( n=read(d_fdout,buf, sizeof(buf)) ) { write(1,buf,n); } return 0; }