- int pin[2], pout[2], reserved[2];
-
- if (verbose)
- fprintf(stderr, "Executing: host %s, user %s, command %s\n",
- host, remuser ? remuser : "(unspecified)", cmd);
-
- /* Reserve two descriptors so that the real pipes won't get descriptors
- 0 and 1 because that will screw up dup2 below. */
- pipe(reserved);
-
- /* Create a socket pair for communicating with ssh. */
- if (pipe(pin) < 0)
- fatal("pipe: %s", strerror(errno));
- if (pipe(pout) < 0)
- fatal("pipe: %s", strerror(errno));
-
- /* Free the reserved descriptors. */
- close(reserved[0]);
- close(reserved[1]);
-
- /* For a child to execute the command on the remote host using ssh. */
- if (fork() == 0)
- {
- char *args[100];
- unsigned int i;
-
- /* Child. */
- close(pin[1]);
- close(pout[0]);
- dup2(pin[0], 0);
- dup2(pout[1], 1);
- close(pin[0]);
- close(pout[1]);
-
- i = 0;
- args[i++] = SSH_PROGRAM;
- args[i++] = "-x";
- args[i++] = "-oFallBackToRsh no";
- if (verbose)
- args[i++] = "-v";
- if (compress)
- args[i++] = "-C";
- if (batchmode)
- args[i++] = "-oBatchMode yes";
- if (cipher != NULL)
- {
- args[i++] = "-c";
- args[i++] = cipher;
- }
- if (identity != NULL)
- {
- args[i++] = "-i";
- args[i++] = identity;
- }
- if (port != NULL)
- {
- args[i++] = "-p";
- args[i++] = port;
- }
- if (remuser != NULL)
- {
- args[i++] = "-l";
- args[i++] = remuser;
+ int pin[2], pout[2], reserved[2];
+
+ if (verbose_mode)
+ fprintf(stderr, "Executing: host %s, user %s, command %s\n",
+ host, remuser ? remuser : "(unspecified)", cmd);
+
+ /*
+ * Reserve two descriptors so that the real pipes won't get
+ * descriptors 0 and 1 because that will screw up dup2 below.
+ */
+ pipe(reserved);
+
+ /* Create a socket pair for communicating with ssh. */
+ if (pipe(pin) < 0)
+ fatal("pipe: %s", strerror(errno));
+ if (pipe(pout) < 0)
+ fatal("pipe: %s", strerror(errno));
+
+ /* Free the reserved descriptors. */
+ close(reserved[0]);
+ close(reserved[1]);
+
+ /* For a child to execute the command on the remote host using ssh. */
+ if (fork() == 0) {
+ char *args[100];
+ unsigned int i;
+
+ /* Child. */
+ close(pin[1]);
+ close(pout[0]);
+ dup2(pin[0], 0);
+ dup2(pout[1], 1);
+ close(pin[0]);
+ close(pout[1]);
+
+ i = 0;
+ args[i++] = SSH_PROGRAM;
+ args[i++] = "-x";
+ args[i++] = "-oFallBackToRsh no";
+ if (IPv4)
+ args[i++] = "-4";
+ if (IPv6)
+ args[i++] = "-6";
+ args[i++] = "-oFallBackToRsh no";
+ if (verbose_mode)
+ args[i++] = "-v";
+ if (compress_flag)
+ args[i++] = "-C";
+ if (batchmode)
+ args[i++] = "-oBatchMode yes";
+ if (cipher != NULL) {
+ args[i++] = "-c";
+ args[i++] = cipher;
+ }
+ if (identity != NULL) {
+ args[i++] = "-i";
+ args[i++] = identity;
+ }
+ if (port != NULL) {
+ args[i++] = "-p";
+ args[i++] = port;
+ }
+ if (remuser != NULL) {
+ args[i++] = "-l";
+ args[i++] = remuser;
+ }
+ args[i++] = host;
+ args[i++] = cmd;
+ args[i++] = NULL;
+
+ execvp(SSH_PROGRAM, args);
+ perror(SSH_PROGRAM);
+ exit(1);