Index: unk/Ohana/src/imregister/imreg/rconnect.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/rconnect.c	(revision 39279)
+++ 	(revision )
@@ -1,106 +1,0 @@
-# include "imregister.h"
-# include "imreg.h"
-
-/* rconnect opens a remote shell on hostname and returns two file descriptors:
-   one for read, one for write */
-
-int rconnect (char *hostname, char *command, int *rsock, int *wsock) {
-
-  int i, rfd[2], wfd[2], status;
-  pid_t pid;
-  char buffer[0x4000];
-  char *file;
-  Fifo fifo;
-
-  InitFifo (&fifo, 0x4000, 0x1000);
-
-  status = pipe (rfd);
-  if (status < 0) {
-    perror ("pipe");
-    return (FALSE);
-  }
-  status = pipe (wfd);
-  if (status < 0) {
-    perror ("pipe");
-    return (FALSE);
-  }
-
-  file = filebasename (command);
-  pid = fork ();
-  if (!pid) { /* must be child process */
-    fprintf (stderr, "starting remote connection to %s...", hostname);
-    /* close the excess sockets */
-    close (wfd[1]);
-    close (rfd[0]);
-    dup2 (wfd[0], STDIN_FILENO);
-    dup2 (rfd[1], STDOUT_FILENO);
-    dup2 (rfd[1], STDERR_FILENO);
-    setvbuf (stdin,  (char *) NULL, _IONBF, BUFSIZ);
-    setvbuf (stdout, (char *) NULL, _IONBF, BUFSIZ);
-    setvbuf (stderr, (char *) NULL, _IONBF, BUFSIZ);
-
-    status = execl (command, file, hostname, "/bin/csh", NULL); 
-    fprintf (stderr, "error starting remote shell process\n");
-    Shutdown (1);
-  }
-  *wsock = wfd[1];
-  *rsock = rfd[0];
-  close (wfd[0]);
-  close (rfd[1]);
-  
-  fcntl (*rsock, F_SETFL, O_NONBLOCK);
-  fcntl (*wsock, F_SETFL, O_NONBLOCK);
-
-  sprintf (buffer, "echo PTOLEMY STARTED\n");
-  status = write (*wsock, buffer, strlen(buffer));
-  if ((status == -1) && (errno == EPIPE)) {
-    fprintf (stderr, "socket closed unexpectedly\n");
-    close (*wsock);
-    close (*rsock);
-    return (FALSE);
-  }
-
-  /* try to get evidence connection is alive - wait upto a few seconds */
-  status = -1;
-  for (i = 0; (i < 300) && (status == -1); i++) {
-    fcntl (*rsock, F_SETFL, O_NONBLOCK);
-    status = SockScan ("PTOLEMY STARTED", &fifo, *rsock);
-    if (!(i % 30)) fprintf (stderr, ".");
-    if (status == 0) {
-      fprintf (stderr, "socket closed unexpectedly\n");
-      close (*wsock);
-      close (*rsock);
-      return (FALSE);
-    }
-  }
-  if (i == -1) {
-    fprintf (stderr, "timeout while connecting\n");
-    close (*wsock);
-    close (*rsock);
-    return (FALSE);
-  }
-  fprintf (stderr, "Connected\n");
-
-  /* the onintr command works with csh/tcsh type shells to
-     prevent trapping of SIGTERM, used to kill hung jobs.
-     for bash/sh type shells, you can use SIGQUIT instead
-     without setting onintr */
-  sprintf (buffer, "onintr\n");
-  if (write (*wsock, buffer, strlen (buffer)) != strlen(buffer)) {
-    fprintf (stderr, "error sending signal\n");
-    close (*wsock);
-    close (*rsock);
-    return (FALSE);
-  }
-
-  if ((status == -1) && (errno == EPIPE)) {
-    fprintf (stderr, "socket closed unexpectedly\n");
-    close (*wsock);
-    close (*rsock);
-    return (FALSE);
-  }
-
-  FreeFifo (&fifo);
-  return (pid);
-
-}
Index: /trunk/Ohana/src/libohana/src/rconnect.c
===================================================================
--- /trunk/Ohana/src/libohana/src/rconnect.c	(revision 39279)
+++ /trunk/Ohana/src/libohana/src/rconnect.c	(revision 39280)
@@ -22,7 +22,12 @@
 /* connection can take a while, allow up to 5 sec by default */
 static int CONNECT_TIMEOUT = 5000;
+static char *CONNECT_FLAGS = NULL;
 
 void rconnect_set_timeout (int timeout) {
   CONNECT_TIMEOUT = timeout;
+}
+
+void rconnect_set_flags (char *flags) {
+  CONNECT_FLAGS = flags;
 }
 
@@ -52,12 +57,15 @@
   if (pipe (stderr_fd) < 0) goto pipe_error;
 
-  char *flag = "-x";
+  // make this a user option?
+  // char *flag = "-x -o PasswordAuthentication=No";
 
-  ALLOCATE (argv, char *, 5);
+  ALLOCATE (argv, char *, 7);
   argv[0] = command;
-  argv[1] = flag;
-  argv[2] = hostname;
-  argv[3] = shell;
-  argv[4] = 0;
+  argv[1] = "-x";
+  argv[2] = "-o";
+  argv[3] = "PasswordAuthentication=No";
+  argv[4] = hostname;
+  argv[5] = shell;
+  argv[6] = 0;
 
   pid = fork ();
Index: unk/Ohana/src/opihi/pcontrol/rconnect.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/rconnect.c	(revision 39279)
+++ 	(revision )
@@ -1,148 +1,0 @@
-# include "pcontrol.h"
-
-/* connection can take a while, allow up to 2 sec */
-# define CONNECT_TIMEOUT 5000
-
-/* connect to host, start the shell: ssh hostname pclient -> command hostname shell
-   stdio is an array of file descriptors (stdio[3])
-*/
-
-int rconnect (char *command, char *hostname, char *shell, int *stdio) {
-
-  int i = 0, stdin_fd[2], stdout_fd[2], stderr_fd[2], status;
-  int result, waitstatus;
-  pid_t pid;
-  char *p;
-  char **argv;
-  IOBuffer buffer;
-  struct timespec request, remain;
-
-  ASSERT (command != NULL, "command is NULL");
-  ASSERT (hostname != NULL, "hostname is NULL");
-  ASSERT (shell != NULL, "shell is NULL");
-  ASSERT (stdio != NULL, "stdio is NULL");
-
-  bzero (stdin_fd,  2*sizeof(int));
-  bzero (stdout_fd, 2*sizeof(int));
-  bzero (stderr_fd, 2*sizeof(int));
-
-  if (pipe (stdin_fd)  < 0) goto pipe_error;
-  if (pipe (stdout_fd) < 0) goto pipe_error;
-  if (pipe (stderr_fd) < 0) goto pipe_error;
-
-  ALLOCATE (argv, char *, 4);
-  argv[0] = command;
-  argv[1] = hostname;
-  argv[2] = shell;
-  argv[3] = 0;
-
-  pid = fork ();
-  if (!pid) { /* must be child process */
-    if (VerboseMode()) gprint (GP_ERR, "starting remote connection to %s...", hostname);
-
-    /* close the other ends of the pipes */
-    close (stdin_fd[1]);
-    close (stdout_fd[0]);
-    close (stderr_fd[0]);
-
-    /* tie our ends of the pipes to stdin, stdout, stderr */
-    dup2 (stdin_fd[0],  STDIN_FILENO);
-    dup2 (stdout_fd[1], STDOUT_FILENO);
-    dup2 (stderr_fd[1], STDERR_FILENO);
-
-    /* set all three unblocking */
-    setvbuf (stdin,  (char *) NULL, _IONBF, BUFSIZ);
-    setvbuf (stdout, (char *) NULL, _IONBF, BUFSIZ);
-    setvbuf (stderr, (char *) NULL, _IONBF, BUFSIZ);
-
-    status = execvp (argv[0], argv);
-    gprint (GP_ERR, "error starting remote shell process\n");
-    pcontrol_exit (60);
-  }
-  free (argv);
-
-  /* close the other ends of the pipes */
-  close (stdin_fd[0]);  stdin_fd[0]  = 0;
-  close (stdout_fd[1]); stdout_fd[1] = 0;
-  close (stderr_fd[1]); stderr_fd[1] = 0;
-
-  /* make the pipes non-blocking */
-  fcntl (stdin_fd[1],  F_SETFL, O_NONBLOCK);
-  fcntl (stdout_fd[0], F_SETFL, O_NONBLOCK);
-  fcntl (stderr_fd[0], F_SETFL, O_NONBLOCK);
-
-  /* perform handshake with pclient to verify alive & running */
-  /** this handshake is similar to PclientCommand, but has important differences **/
-  InitIOBuffer (&buffer, 0x100);
-
-  /* send handshake command */
-  status = write_fmt (stdin_fd[1], "echo CONNECTED\n");
-  if ((status == -1) && (errno == EPIPE)) goto connect_error;
-
-  /* try to get evidence connection is alive - wait upto a few seconds */
-  p = NULL;
-  status = -1;
-  for (i = 0; (i < CONNECT_TIMEOUT) && (status != 0) && (p == NULL); i++) {
-    status = ReadtoIOBuffer (&buffer, stdout_fd[0]);
-    p = memstr (buffer.buffer, "CONNECTED", buffer.Nbuffer);
-    usleep (10000); // wait for client to be connected
-  }
-  if (status == 0) goto connect_error;
-  if (status == -1) goto connect_error;
-  if (VerboseMode()) gprint (GP_ERR, "%d cycles to connect\n", i);
-  FreeIOBuffer (&buffer);
-
-  if (VerboseMode()) gprint (GP_ERR, "Connected\n");
-
-  stdio[0] = stdin_fd[1];
-  stdio[1] = stdout_fd[0];
-  stdio[2] = stderr_fd[0];
-
-  return (pid);
-
-pipe_error:
-  perror ("pipe error:");
-  goto close_pipes;
-
-connect_error:
-  if (VerboseMode()) gprint (GP_ERR, "error while connecting, status: %d, ncycles: %d\n", status, i);
-
-  /* avoid blocking on waitpid, test every 100 usec, up to 50 msec */
-  request.tv_sec = 0;
-  request.tv_nsec = 100000;
-
-  /* harvest the child process: kill & wait (< 100 ms) for exit */
-  kill (pid, SIGKILL);
-  result = waitpid (pid, &waitstatus, WNOHANG);
-  for (i = 0; (i < 50) && (result == 0); i++) {
-    nanosleep (&request, &remain);
-    result = waitpid (pid, &waitstatus, WNOHANG);
-  }
-
-  if ((result == -1) && (errno != ECHILD)) {
-    gprint (GP_ERR, "unexpected error from waitpid (%d): programming error\n", errno);
-    pcontrol_exit (61);
-  }
-  if (result == 0) {
-    if (VerboseMode()) gprint (GP_ERR, "child did not exit (rconnect)??");
-  }
-  if (result > 0) {
-    if (result != pid) {
-      gprint (GP_ERR, "waitpid error: mis-matched PID (%d vs %d).  programming error\n", result, pid);
-      pcontrol_exit (62);
-    }
-    if (WIFSTOPPED(waitstatus)) {
-      gprint (GP_ERR, "waitpid returns 'stopped': programming error\n");
-      pcontrol_exit (63);
-    }
-  }
-
-close_pipes:
-  if (stdin_fd[0]  != 0) close (stdin_fd[0]);
-  if (stdin_fd[1]  != 0) close (stdin_fd[1]);
-  if (stdout_fd[0] != 0) close (stdout_fd[0]);
-  if (stdout_fd[1] != 0) close (stdout_fd[1]);
-  if (stderr_fd[0] != 0) close (stderr_fd[0]);
-  if (stderr_fd[1] != 0) close (stderr_fd[1]);
-  return (FALSE);
-}
Index: unk/Ohana/src/photdbc/src/rconnect.c
===================================================================
--- /trunk/Ohana/src/photdbc/src/rconnect.c	(revision 39279)
+++ 	(revision )
@@ -1,150 +1,0 @@
-# include "dvodist.h"
-# include <sys/types.h>
-# include <sys/wait.h>
-
-/* connection can take a while, allow up to 2 sec */
-# define CONNECT_TIMEOUT 5000
-
-/* connect to host, start the shell: ssh hostname pclient -> command hostname shell
-   stdio is an array of file descriptors (stdio[3])
-*/
-
-int rconnect (char *command, char *hostname, char *shell, int *stdio) {
-
-  int i = 0, stdin_fd[2], stdout_fd[2], stderr_fd[2], status;
-  int result, waitstatus;
-  pid_t pid;
-  char *p;
-  char **argv;
-  IOBuffer buffer;
-  struct timespec request, remain;
-
-  myAssert (command != NULL, "command is NULL");
-  myAssert (hostname != NULL, "hostname is NULL");
-  myAssert (shell != NULL, "shell is NULL");
-  myAssert (stdio != NULL, "stdio is NULL");
-
-  bzero (stdin_fd,  2*sizeof(int));
-  bzero (stdout_fd, 2*sizeof(int));
-  bzero (stderr_fd, 2*sizeof(int));
-
-  if (pipe (stdin_fd)  < 0) goto pipe_error;
-  if (pipe (stdout_fd) < 0) goto pipe_error;
-  if (pipe (stderr_fd) < 0) goto pipe_error;
-
-  ALLOCATE (argv, char *, 4);
-  argv[0] = command;
-  argv[1] = hostname;
-  argv[2] = shell;
-  argv[3] = 0;
-
-  pid = fork ();
-  if (!pid) { /* must be child process */
-    if (VERBOSE) fprintf (stderr, "starting remote connection to %s...", hostname);
-
-    /* close the other ends of the pipes */
-    close (stdin_fd[1]);
-    close (stdout_fd[0]);
-    close (stderr_fd[0]);
-
-    /* tie our ends of the pipes to stdin, stdout, stderr */
-    dup2 (stdin_fd[0],  STDIN_FILENO);
-    dup2 (stdout_fd[1], STDOUT_FILENO);
-    dup2 (stderr_fd[1], STDERR_FILENO);
-
-    /* set all three unblocking */
-    setvbuf (stdin,  (char *) NULL, _IONBF, BUFSIZ);
-    setvbuf (stdout, (char *) NULL, _IONBF, BUFSIZ);
-    setvbuf (stderr, (char *) NULL, _IONBF, BUFSIZ);
-
-    status = execvp (argv[0], argv);
-    fprintf (stderr, "error starting remote shell process\n");
-    exit (60);
-  }
-  free (argv);
-
-  /* close the other ends of the pipes */
-  close (stdin_fd[0]);  stdin_fd[0]  = 0;
-  close (stdout_fd[1]); stdout_fd[1] = 0;
-  close (stderr_fd[1]); stderr_fd[1] = 0;
-
-  /* make the pipes non-blocking */
-  fcntl (stdin_fd[1],  F_SETFL, O_NONBLOCK);
-  fcntl (stdout_fd[0], F_SETFL, O_NONBLOCK);
-  fcntl (stderr_fd[0], F_SETFL, O_NONBLOCK);
-
-  /* perform handshake with pclient to verify alive & running */
-  /** this handshake is similar to PclientCommand, but has important differences **/
-  InitIOBuffer (&buffer, 0x100);
-
-  /* send handshake command */
-  status = write_fmt (stdin_fd[1], "echo CONNECTED\n");
-  if ((status == -1) && (errno == EPIPE)) goto connect_error;
-
-  /* try to get evidence connection is alive - wait upto a few seconds */
-  p = NULL;
-  status = -1;
-  for (i = 0; (i < CONNECT_TIMEOUT) && (status != 0) && (p == NULL); i++) {
-    status = ReadtoIOBuffer (&buffer, stdout_fd[0]);
-    p = memstr (buffer.buffer, "CONNECTED", buffer.Nbuffer);
-    usleep (10000); // wait for client to be connected
-  }
-  if (status == 0) goto connect_error;
-  if (status == -1) goto connect_error;
-  if (VERBOSE) fprintf (stderr, "%d cycles to connect\n", i);
-  FreeIOBuffer (&buffer);
-
-  if (VERBOSE) fprintf (stderr, "Connected\n");
-
-  stdio[0] = stdin_fd[1];
-  stdio[1] = stdout_fd[0];
-  stdio[2] = stderr_fd[0];
-
-  return (pid);
-
-pipe_error:
-  perror ("pipe error:");
-  goto close_pipes;
-
-connect_error:
-  if (VERBOSE) fprintf (stderr, "error while connecting, status: %d, ncycles: %d\n", status, i);
-
-  /* avoid blocking on waitpid, test every 100 usec, up to 50 msec */
-  request.tv_sec = 0;
-  request.tv_nsec = 100000;
-
-  /* harvest the child process: kill & wait (< 100 ms) for exit */
-  kill (pid, SIGKILL);
-  result = waitpid (pid, &waitstatus, WNOHANG);
-  for (i = 0; (i < 50) && (result == 0); i++) {
-    nanosleep (&request, &remain);
-    result = waitpid (pid, &waitstatus, WNOHANG);
-  }
-
-  if ((result == -1) && (errno != ECHILD)) {
-    fprintf (stderr, "unexpected error from waitpid (%d): programming error\n", errno);
-    exit (61);
-  }
-  if (result == 0) {
-    if (VERBOSE) fprintf (stderr, "child did not exit (rconnect)??");
-  }
-  if (result > 0) {
-    if (result != pid) {
-      fprintf (stderr, "waitpid error: mis-matched PID (%d vs %d).  programming error\n", result, pid);
-      exit (62);
-    }
-    if (WIFSTOPPED(waitstatus)) {
-      fprintf (stderr, "waitpid returns 'stopped': programming error\n");
-      exit (63);
-    }
-  }
-
-close_pipes:
-  if (stdin_fd[0]  != 0) close (stdin_fd[0]);
-  if (stdin_fd[1]  != 0) close (stdin_fd[1]);
-  if (stdout_fd[0] != 0) close (stdout_fd[0]);
-  if (stdout_fd[1] != 0) close (stdout_fd[1]);
-  if (stderr_fd[0] != 0) close (stderr_fd[0]);
-  if (stderr_fd[1] != 0) close (stderr_fd[1]);
-  return (FALSE);
-}
