You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2010/01/17 11:44:13 UTC

svn commit: r900092 - in /commons/sandbox/runtime/trunk/src/main/native: Makefile.in configure include/acr_exec.h os/solaris/openpty.c os/unix/exec.c os/unix/pty.c os/unix/signals.c test/testsuite.c

Author: mturk
Date: Sun Jan 17 10:44:12 2010
New Revision: 900092

URL: http://svn.apache.org/viewvc?rev=900092&view=rev
Log:
Axe pseudo terminals

Removed:
    commons/sandbox/runtime/trunk/src/main/native/os/solaris/openpty.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/pty.c
Modified:
    commons/sandbox/runtime/trunk/src/main/native/Makefile.in
    commons/sandbox/runtime/trunk/src/main/native/configure
    commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
    commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=900092&r1=900091&r2=900092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Sun Jan 17 10:44:12 2010
@@ -143,7 +143,6 @@
 	$(SRCDIR)/os/unix/path.$(OBJ) \
 	$(SRCDIR)/os/unix/pipe.$(OBJ) \
 	$(SRCDIR)/os/unix/proc.$(OBJ) \
-	$(SRCDIR)/os/unix/pty.$(OBJ) \
 	$(SRCDIR)/os/unix/secmem.$(OBJ) \
 	$(SRCDIR)/os/unix/sema.$(OBJ) \
 	$(SRCDIR)/os/unix/shm.$(OBJ) \
@@ -186,7 +185,6 @@
 	$(SRCDIR)/os/unix/path.$(OBJ) \
 	$(SRCDIR)/os/unix/pipe.$(OBJ) \
 	$(SRCDIR)/os/unix/proc.$(OBJ) \
-	$(SRCDIR)/os/unix/pty.$(OBJ) \
 	$(SRCDIR)/os/unix/secmem.$(OBJ) \
 	$(SRCDIR)/os/unix/sema.$(OBJ) \
 	$(SRCDIR)/os/unix/shm.$(OBJ) \
@@ -201,7 +199,6 @@
 	$(SRCDIR)/os/solaris/env.$(OBJ) \
 	$(SRCDIR)/os/solaris/fasync.$(OBJ) \
 	$(SRCDIR)/os/solaris/module.$(OBJ) \
-	$(SRCDIR)/os/solaris/openpty.$(OBJ) \
 	$(SRCDIR)/os/solaris/platform.$(OBJ) \
 	$(SRCDIR)/os/solaris/group.$(OBJ) \
 	$(SRCDIR)/os/solaris/user.$(OBJ) \
@@ -226,7 +223,6 @@
 	$(SRCDIR)/os/unix/path.$(OBJ) \
 	$(SRCDIR)/os/unix/pipe.$(OBJ) \
 	$(SRCDIR)/os/unix/proc.$(OBJ) \
-	$(SRCDIR)/os/unix/pty.$(OBJ) \
 	$(SRCDIR)/os/unix/secmem.$(OBJ) \
 	$(SRCDIR)/os/unix/sema.$(OBJ) \
 	$(SRCDIR)/os/unix/shm.$(OBJ) \
@@ -268,7 +264,6 @@
 	$(SRCDIR)/os/unix/path.$(OBJ) \
 	$(SRCDIR)/os/unix/pipe.$(OBJ) \
 	$(SRCDIR)/os/unix/proc.$(OBJ) \
-	$(SRCDIR)/os/unix/pty.$(OBJ) \
 	$(SRCDIR)/os/unix/secmem.$(OBJ) \
 	$(SRCDIR)/os/unix/sema.$(OBJ) \
 	$(SRCDIR)/os/unix/signals.$(OBJ) \

Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=900092&r1=900091&r2=900092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Sun Jan 17 10:44:12 2010
@@ -1000,7 +1000,6 @@
     have_windows=1
     have_uuid_uuid=0
     have_off64t=0
-    have_openpty=0
 else
     have_ktmw32=0
     have_off64t=1
@@ -1019,8 +1018,6 @@
     fi
     ok=`have_library resolv res_init`
     test ".$ok" = .1 && varadds ldflags -lresolv
-    have_openpty=`have_library util openpty`
-    test ".$have_openpty" = .1 && varadds ldflags -lutil
 fi
 
 if [ ".$host" = ".linux" ]; then
@@ -1161,7 +1158,6 @@
 #define HAVE_SELINUX_H        $have_selinux
 #define HAVE_PORT_H           $have_port
 #define HAVE_SQLITE3          $have_sqlite3
-#define HAVE_OPENPTY          $have_openpty
 
 #define HAVE_UNISTD_H         `have_include x unistd`
 #define HAVE_STRING_H         `have_include w string`
@@ -1196,8 +1192,6 @@
 #define HAVE_RESOLV_H         `have_include x resolv`
 #define HAVE_SYS_UN_H         `have_include x sys/un`
 #define HAVE_UCONTEXT_H       `have_include x ucontext`
-#define HAVE_PTY_H            `have_include x pty`
-#define HAVE_UTIL_H           `have_include x util`
 #define HAVE_WCSCASECMP       `have_function w wcscasecmp`
 #define HAVE_STRERROR_R       `have_function x strerror_r`
 #define HAVE_MMAP64           `have_function x mmap64`
@@ -1214,8 +1208,6 @@
 #define HAVE_SIGACTION        `have_function x sigaction`
 #define HAVE_FDWALK           `have_function x fdwalk`
 #define HAVE_SETRLIMIT        `have_function x setrlimit`
-#define HAVE_GRANTPT          `have_function x grantpt`
-#define HAVE_POSIX_OPENPT     `have_function x posix_openpt`
 #define HAVE_DUP3             `have_function c dup3`
 #define HAVE_EPOLL_CREATE1    `have_function c epoll_create1`
 #define HAVE_ACCEPT4          `have_function c accept4`

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h?rev=900092&r1=900091&r2=900092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h Sun Jan 17 10:44:12 2010
@@ -73,8 +73,6 @@
     acr_uid_t           uid;
     /** Group Id for child process */
     acr_gid_t           gid;
-    /** Password for su */
-    const char          *password;
 #endif
     /** Process working directory */
     acr_pchar_t        *currdir;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c?rev=900092&r1=900091&r2=900092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c Sun Jan 17 10:44:12 2010
@@ -37,7 +37,6 @@
  */
 
 extern int pipepair(int pd[2], int flags);
-extern int ptypipes(int pd[2], int flags);
 extern int nullpipe(int flags, int fd);
 
 #define PROC_TIMEOUT_STEP   100
@@ -164,8 +163,8 @@
 {
     pid_t  pid;
     ssize_t rd;
+    ssize_t wr;
     int i;
-    int np = 0;
     int rc = 0;
     int exitval;
     int pipes[PIPE_COUNT] = { -1, -1, -1, -1,  -1, -1, -1, -1, -1, -1 };
@@ -189,13 +188,8 @@
     /* Create standard stream pipes
      */
     if (ep->flags & ACR_PROC_HAS_STDIN) {
-#if 0
         if ((rc = pipepair(&pipes[PIPE_STDINP], ACR_PIPE_READ_BLOCK)))
             goto cleanup;
-#else
-        if ((rc = ptypipes(&pipes[PIPE_STDINP], ACR_PIPE_READ_BLOCK)))
-            goto cleanup;
-#endif
     }
     if (ep->flags & ACR_PROC_HAS_STDOUT) {
         if ((rc = pipepair(&pipes[PIPE_STDOUT], ACR_PIPE_WRITE_BLOCK)))
@@ -390,14 +384,15 @@
     }
     else {
         /* Parent process */
-        struct pollfd ps[4];
+        struct pollfd ps[3];
+        char   buf[PROC_BUFFER_SIZE];
         int    npipes     = 0;
         int    pipelining = ep->flags & (ACR_PROC_HAS_STDOUT | ACR_PROC_HAS_STDERR);
         pid_t  child      = pid;
         const char *inpp  = (const char *)ep->data.iov_base;
         int    polltime   = ep->limit.timeout > 0 ? PROC_TIMEOUT_STEP : -1;
         acr_time_t endat  = 0;
-        int    count      = 0;
+
         /* Close parent side of pipes
          */
         i_close(&pipes[PIPE_STDINP_RDS]);
@@ -441,7 +436,7 @@
         }
         while (pipelining) {
             npipes = 0;
-            if (pipes[PIPE_STDINP_WRS] != -1 && ep->data.iov_len) {
+            if (pipes[PIPE_STDINP_WRS] != -1) {
                 ps[npipes].fd = pipes[PIPE_STDINP_WRS];
                 ps[npipes].events  = POLLOUT;
                 ps[npipes].revents = 0;
@@ -449,13 +444,13 @@
             }
             if (pipes[PIPE_STDOUT_RDS] != -1) {
                 ps[npipes].fd = pipes[PIPE_STDOUT_RDS];
-                ps[npipes].events  = POLLIN | POLLPRI;
+                ps[npipes].events  = POLLIN;
                 ps[npipes].revents = 0;
                 npipes++;
             }
             if (pipes[PIPE_STDERR_RDS] != -1) {
                 ps[npipes].fd = pipes[PIPE_STDERR_RDS];
-                ps[npipes].events  = POLLIN | POLLPRI;
+                ps[npipes].events  = POLLIN;
                 ps[npipes].revents = 0;
                 npipes++;
             }
@@ -483,19 +478,22 @@
                          * but only if we are using pty for stdin.
                          */
                         ps[i].fd = pipes[PIPE_STDERR_RDS];
+                        ps[i].revents = POLLIN;
                         ACR_DEBUG((THROW_FMARK, "Poll with zero revents. "
                                                 "Redirecting stdin event to stderr!"));
                     }
                     if (pipes[PIPE_STDINP_WRS] == ps[i].fd) {
-                        ssize_t wr;
-                        wr = r_write(pipes[PIPE_STDINP_WRS], inpp,
-                                     ep->data.iov_len);
+                        wr = 0;
+                        if (ps[i].revents & POLLOUT) {
+                            wr = r_write(pipes[PIPE_STDINP_WRS], inpp,
+                                         ep->data.iov_len);
+                        }
                         if (wr > 0) {
                             ep->data.iov_len -= wr;
                             inpp += wr;
                             if (ep->data.iov_len == 0) {
-                                /* XXX: Closing the pseudo-terminal
-                                 *      can cause IO error inside child.
+                                /* Closing the stdin should cause
+                                 * EOF in child.
                                  */
                                 i_close(&pipes[PIPE_STDINP_WRS]);
                             }
@@ -506,9 +504,11 @@
                         }
                     }
                     if (pipes[PIPE_STDOUT_RDS] == ps[i].fd) {
-                        char   buf[512];
-
-                        rd = r_read(pipes[PIPE_STDOUT_RDS], buf, sizeof(buf));
+                        rd = 0;
+                        if (ps[i].revents & POLLIN) {
+                            rd = r_read(pipes[PIPE_STDOUT_RDS],
+                                        buf, PROC_BUFFER_SIZE);
+                        }
                         if (rd > 0) {
                             if (acr_sbuf_bcat(&ep->sout, buf, rd)) {
                                 /* Error appending to the buffer.
@@ -517,16 +517,6 @@
                                 pipelining = 0;
                                 break;
                             }
-                            if (ep->password) {
-                                acr_sbuf_flush(&ep->sout);
-                                if (strstr(acr_sbuf_data(&ep->sout),
-                                           "Password:")) {
-                                    inpp = ep->password;
-                                    ep->data.iov_len = strlen(ep->password);
-                                    /* One time shot */
-                                    ep->password = NULL;
-                                }
-                            }
                         }
                         else {
                             if (rd != -1 || !ACR_STATUS_IS_EAGAIN(errno))
@@ -534,9 +524,11 @@
                         }
                     }
                     if (pipes[PIPE_STDERR_RDS] == ps[i].fd) {
-                        char   buf[512];
-
-                        rd = r_read(pipes[PIPE_STDERR_RDS], buf, sizeof(buf));
+                        rd = 0;
+                        if (ps[i].revents & POLLIN) {
+                            rd = r_read(pipes[PIPE_STDERR_RDS],
+                                        buf, PROC_BUFFER_SIZE);
+                        }
                         if (rd > 0) {
                             if (acr_sbuf_bcat(&ep->serr, buf, rd)) {
                                 /* Error appending to the buffer.
@@ -545,16 +537,6 @@
                                 pipelining = 0;
                                 break;
                             }
-                            if (ep->password) {
-                                acr_sbuf_flush(&ep->serr);
-                                if (strstr(acr_sbuf_data(&ep->serr),
-                                           "Password:")) {
-                                    inpp = ep->password;
-                                    ep->data.iov_len = strlen(ep->password);
-                                    /* One time shot */
-                                    ep->password = NULL;
-                                }
-                            }
                         }
                         else {
                             if (rd != -1 || !ACR_STATUS_IS_EAGAIN(errno))
@@ -562,7 +544,6 @@
                         }
                     }
                 }
-
             }
             else {
                 /* All pipes are closed

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c?rev=900092&r1=900091&r2=900092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c Sun Jan 17 10:44:12 2010
@@ -290,8 +290,7 @@
 
 ACR_DECLARE(int) ACR_SIG_DFL(int signo)
 {
-    int rc;
-    struct sigaction act, oact;
+    struct sigaction act;
 
     if (signo < 1 || signo > ACR_NUMSIG) {
         errno = EINVAL;
@@ -320,7 +319,6 @@
 
 ACR_DECLARE(int) ACR_SIG_IGN(int signo)
 {
-    int rc;
     struct sigaction act;
 
     if (signo < 1 || signo > ACR_NUMSIG) {

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=900092&r1=900091&r2=900092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Sun Jan 17 10:44:12 2010
@@ -685,12 +685,12 @@
     if (argc < 1) {
         return ACR_EINVAL;
     }
+
     exe = ACR_ExecNew(ACR_PROC_HAS_STDOUT | ACR_PROC_HAS_STDERR | ACR_PROC_HAS_STDIN);
+    ACR_ExecStdinSet(exe, hello, strlen(hello));
 #if defined(WIN32)
-
     rc = ACR_ExecSubproc(exe, NULL, wargv[0], &wargv[1], NULL);
 #else
-    exe->password = "su password";
     rc = ACR_ExecProgram(exe, argv[0], &argv[1], NULL);
 #endif
     fprintf(stdout, "[STDOUT]:\n%s", ACR_ExecStream(exe, 1));