Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/rexecd/unit-tests Add a few lines of code to print t...



details:   https://anonhg.NetBSD.org/src/rev/f445c05154f9
branches:  trunk
changeset: 574364:f445c05154f9
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Feb 27 01:34:07 2005 +0000

description:
Add a few lines of code to print the output from the remotely executed program.

diffstat:

 libexec/rexecd/unit-tests/rexec.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (48 lines):

diff -r 542ca4a765c8 -r f445c05154f9 libexec/rexecd/unit-tests/rexec.c
--- a/libexec/rexecd/unit-tests/rexec.c Sun Feb 27 01:16:27 2005 +0000
+++ b/libexec/rexecd/unit-tests/rexec.c Sun Feb 27 01:34:07 2005 +0000
@@ -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
 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 @@
        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;
 }
 



Home | Main Index | Thread Index | Old Index