[BACK]Return to scp.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/scp.c between version 1.91 and 1.92

version 1.91, 2002/06/19 00:27:55 version 1.92, 2002/11/07 22:35:38
Line 119 
Line 119 
 /* This is the program to execute for the secured connection. ("ssh" or -S) */  /* This is the program to execute for the secured connection. ("ssh" or -S) */
 char *ssh_program = _PATH_SSH_PROGRAM;  char *ssh_program = _PATH_SSH_PROGRAM;
   
   /* This is used to store the pid of ssh_program */
   pid_t do_cmd_pid;
   
 /*  /*
  * This function executes the given command as the specified user on the   * This function executes the given command as the specified user on the
  * given host.  This returns < 0 if execution fails, and >= 0 otherwise. This   * given host.  This returns < 0 if execution fails, and >= 0 otherwise. This
Line 153 
Line 156 
         close(reserved[1]);          close(reserved[1]);
   
         /* For a child to execute the command on the remote host using ssh. */          /* For a child to execute the command on the remote host using ssh. */
         if (fork() == 0)  {          do_cmd_pid = fork();
           if (do_cmd_pid == 0) {
                 /* Child. */                  /* Child. */
                 close(pin[1]);                  close(pin[1]);
                 close(pout[0]);                  close(pout[0]);
Line 171 
Line 175 
                 execvp(ssh_program, args.list);                  execvp(ssh_program, args.list);
                 perror(ssh_program);                  perror(ssh_program);
                 exit(1);                  exit(1);
           } else if (do_cmd_pid == -1) {
                   fatal("fork: %s", strerror(errno));
         }          }
         /* Parent.  Close the other side, and return the local side. */          /* Parent.  Close the other side, and return the local side. */
         close(pin[0]);          close(pin[0]);
Line 213 
Line 219 
         int argc;          int argc;
         char *argv[];          char *argv[];
 {  {
         int ch, fflag, tflag;          int ch, fflag, tflag, status;
         char *targ;          char *targ;
         extern char *optarg;          extern char *optarg;
         extern int optind;          extern int optind;
Line 306 
Line 312 
                 targetshouldbedirectory = 1;                  targetshouldbedirectory = 1;
   
         remin = remout = -1;          remin = remout = -1;
           do_cmd_pid = -1;
         /* Command to be executed on remote system using "ssh". */          /* Command to be executed on remote system using "ssh". */
         (void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",          (void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",
             verbose_mode ? " -v" : "",              verbose_mode ? " -v" : "",
Line 320 
Line 327 
                 tolocal(argc, argv);    /* Dest is local host. */                  tolocal(argc, argv);    /* Dest is local host. */
                 if (targetshouldbedirectory)                  if (targetshouldbedirectory)
                         verifydir(argv[argc - 1]);                          verifydir(argv[argc - 1]);
           }
           /*
            * Finally check the exit status of the ssh process, if one was forked
            * and no error has occured yet
            */
           if (do_cmd_pid != -1 && errs == 0) {
                   if (remin != -1)
                       (void) close(remin);
                   if (remout != -1)
                       (void) close(remout);
                   if (waitpid(do_cmd_pid, &status, 0) == -1)
                           errs = 1;
                   else {
                           if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
                                   errs = 1;
                   }
         }          }
         exit(errs != 0);          exit(errs != 0);
 }  }

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.92