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

Diff for /src/usr.bin/ssh/sftp.c between version 1.31.2.1 and 1.31.2.2

version 1.31.2.1, 2003/04/01 00:12:14 version 1.31.2.2, 2003/09/16 21:20:27
Line 26 
Line 26 
   
 RCSID("$OpenBSD$");  RCSID("$OpenBSD$");
   
 /* XXX: short-form remote directory listings (like 'ls -C') */  
   
 #include "buffer.h"  #include "buffer.h"
 #include "xmalloc.h"  #include "xmalloc.h"
 #include "log.h"  #include "log.h"
Line 42 
Line 40 
 FILE* infile;  FILE* infile;
 size_t copy_buffer_len = 32768;  size_t copy_buffer_len = 32768;
 size_t num_requests = 16;  size_t num_requests = 16;
   static pid_t sshpid = -1;
   
 extern int showprogress;  extern int showprogress;
   
 static void  static void
 connect_to_server(char *path, char **args, int *in, int *out, pid_t *sshpid)  killchild(int signo)
 {  {
           if (sshpid > 1)
                   kill(sshpid, signo);
   
           _exit(1);
   }
   
   static void
   connect_to_server(char *path, char **args, int *in, int *out)
   {
         int c_in, c_out;          int c_in, c_out;
   
 #ifdef USE_PIPES  #ifdef USE_PIPES
Line 68 
Line 76 
         c_in = c_out = inout[1];          c_in = c_out = inout[1];
 #endif /* USE_PIPES */  #endif /* USE_PIPES */
   
         if ((*sshpid = fork()) == -1)          if ((sshpid = fork()) == -1)
                 fatal("fork: %s", strerror(errno));                  fatal("fork: %s", strerror(errno));
         else if (*sshpid == 0) {          else if (sshpid == 0) {
                 if ((dup2(c_in, STDIN_FILENO) == -1) ||                  if ((dup2(c_in, STDIN_FILENO) == -1) ||
                     (dup2(c_out, STDOUT_FILENO) == -1)) {                      (dup2(c_out, STDOUT_FILENO) == -1)) {
                         fprintf(stderr, "dup2: %s\n", strerror(errno));                          fprintf(stderr, "dup2: %s\n", strerror(errno));
Line 85 
Line 93 
                 exit(1);                  exit(1);
         }          }
   
           signal(SIGTERM, killchild);
           signal(SIGINT, killchild);
           signal(SIGHUP, killchild);
         close(c_in);          close(c_in);
         close(c_out);          close(c_out);
 }  }
Line 95 
Line 106 
         extern char *__progname;          extern char *__progname;
   
         fprintf(stderr,          fprintf(stderr,
             "usage: %s [-vC1] [-b batchfile] [-o option] [-s subsystem|path] [-B buffer_size]\n"              "usage: %s [-vC1] [-b batchfile] [-o ssh_option] [-s subsystem | sftp_server]\n"
             "            [-F config] [-P direct server path] [-S program]\n"              "            [-B buffer_size] [-F ssh_config] [-P sftp_server path]\n"
               "            [-R num_requests] [-S program]\n"
             "            [user@]host[:file [file]]\n", __progname);              "            [user@]host[:file [file]]\n", __progname);
         exit(1);          exit(1);
 }  }
Line 105 
Line 117 
 main(int argc, char **argv)  main(int argc, char **argv)
 {  {
         int in, out, ch, err;          int in, out, ch, err;
         pid_t sshpid;  
         char *host, *userhost, *cp, *file2;          char *host, *userhost, *cp, *file2;
         int debug_level = 0, sshver = 2;          int debug_level = 0, sshver = 2;
         char *file1 = NULL, *sftp_server = NULL;          char *file1 = NULL, *sftp_server = NULL;
Line 222 
Line 233 
                 args.list[0] = ssh_program;                  args.list[0] = ssh_program;
   
                 fprintf(stderr, "Connecting to %s...\n", host);                  fprintf(stderr, "Connecting to %s...\n", host);
                 connect_to_server(ssh_program, args.list, &in, &out,                  connect_to_server(ssh_program, args.list, &in, &out);
                     &sshpid);  
         } else {          } else {
                 args.list = NULL;                  args.list = NULL;
                 addargs(&args, "sftp-server");                  addargs(&args, "sftp-server");
   
                 fprintf(stderr, "Attaching to %s...\n", sftp_direct);                  fprintf(stderr, "Attaching to %s...\n", sftp_direct);
                 connect_to_server(sftp_direct, args.list, &in, &out,                  connect_to_server(sftp_direct, args.list, &in, &out);
                     &sshpid);  
         }          }
   
         err = interactive_loop(in, out, file1, file2);          err = interactive_loop(in, out, file1, file2);

Legend:
Removed from v.1.31.2.1  
changed lines
  Added in v.1.31.2.2