diff options
| author | christos <christos@NetBSD.org> | 2005-02-27 01:34:07 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2005-02-27 01:34:07 +0000 |
| commit | aa73cae19608873cc4d1f712c4a0f8f8435f1ffa (patch) | |
| tree | 750e8a7f945741b9300ca670166c77c6618586e8 /libexec/rexecd | |
| parent | 901ebd51aac43ba90cdbf4ce17efe8c02707b42c (diff) | |
Add a few lines of code to print the output from the remotely executed program.
Diffstat (limited to 'libexec/rexecd')
| -rw-r--r-- | libexec/rexecd/unit-tests/rexec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libexec/rexecd/unit-tests/rexec.c b/libexec/rexecd/unit-tests/rexec.c index fa7c907f95a..d354cf32345 100644 --- a/libexec/rexecd/unit-tests/rexec.c +++ b/libexec/rexecd/unit-tests/rexec.c @@ -1,4 +1,4 @@ -/* $NetBSD: rexec.c,v 1.1 2005/02/23 01:27:32 christos Exp $ */ +/* $NetBSD: rexec.c,v 1.2 2005/02/27 01:34:07 christos Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: rexec.c,v 1.1 2005/02/23 01:27:32 christos Exp $"); +__RCSID("$NetBSD: rexec.c,v 1.2 2005/02/27 01:34:07 christos Exp $"); #include <stdio.h> #include <netdb.h> @@ -51,12 +51,14 @@ int rexec(char **, int, char *, char *, char *, int *); int main(int argc, char **argv) { - int c; + int c, s; + ssize_t nr; struct servent *sv; char *host = __UNCONST("localhost"); char *user = __UNCONST("root"); char *pass = __UNCONST("h@x0R"); char *cmd = __UNCONST("ls"); + char line[BUFSIZ]; while ((c = getopt(argc, argv, "h:u:p:c:")) != -1) switch (c) { @@ -79,8 +81,12 @@ main(int argc, char **argv) if ((sv = getservbyname("exec", "tcp")) == NULL) errx(1, "Cannot find service exec/tcp"); - if (rexec(&host, sv->s_port, user, pass, cmd, NULL) == -1) + if ((s = rexec(&host, sv->s_port, user, pass, cmd, NULL)) == -1) return 1; + while ((nr = read(s, line, sizeof(line))) > 0) + (void)write(STDOUT_FILENO, line, nr); + if (nr == -1) + err(1, "read failed"); return 0; } |
