[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.7.2.2 and 1.7.2.3

version 1.7.2.2, 2001/02/19 17:19:25 version 1.7.2.3, 2001/03/21 19:46:29
Line 43 
Line 43 
 int use_ssh1 = 0;  int use_ssh1 = 0;
 char *ssh_program = _PATH_SSH_PROGRAM;  char *ssh_program = _PATH_SSH_PROGRAM;
 char *sftp_server = NULL;  char *sftp_server = NULL;
   FILE* infile;
   
 void  void
 connect_to_server(char **args, int *in, int *out, pid_t *sshpid)  connect_to_server(char **args, int *in, int *out, pid_t *sshpid)
Line 91 
Line 92 
         static char **args = NULL;          static char **args = NULL;
         static int nargs = 0;          static int nargs = 0;
         char debug_buf[4096];          char debug_buf[4096];
         int i, use_subsystem = 1;          int i;
   
         /* no subsystem if protocol 1 or the server-spec contains a '/' */  
         if (use_ssh1 ||  
             (sftp_server != NULL && strchr(sftp_server, '/') != NULL))  
                 use_subsystem = 0;  
   
         /* Init args array */          /* Init args array */
         if (args == NULL) {          if (args == NULL) {
                 nargs = use_subsystem ? 6 : 5;                  nargs = 2;
                 i = 0;                  i = 0;
                 args = xmalloc(sizeof(*args) * nargs);                  args = xmalloc(sizeof(*args) * nargs);
                 args[i++] = "ssh";                  args[i++] = "ssh";
                 args[i++] = use_ssh1 ? "-oProtocol=1" : "-oProtocol=2";  
                 if (use_subsystem)  
                         args[i++] = "-s";  
                 args[i++] = "-oForwardAgent=no";  
                 args[i++] = "-oForwardX11=no";  
                 args[i++] = NULL;                  args[i++] = NULL;
         }          }
   
Line 121 
Line 112 
                 return(NULL);                  return(NULL);
         }          }
   
           /* no subsystem if the server-spec contains a '/' */
           if (sftp_server == NULL || strchr(sftp_server, '/') == NULL)
                   make_ssh_args("-s");
           make_ssh_args("-oForwardX11=no");
           make_ssh_args("-oForwardAgent=no");
           make_ssh_args(use_ssh1 ? "-oProtocol=1" : "-oProtocol=2");
   
         /* Otherwise finish up and return the arg array */          /* Otherwise finish up and return the arg array */
         if (sftp_server != NULL)          if (sftp_server != NULL)
                 make_ssh_args(sftp_server);                  make_ssh_args(sftp_server);
Line 143 
Line 141 
 void  void
 usage(void)  usage(void)
 {  {
         fprintf(stderr, "usage: sftp [-1vC] [-osshopt=value] [user@]host\n");          fprintf(stderr, "usage: sftp [-1vC] [-b batchfile] [-osshopt=value] [user@]host\n");
         exit(1);          exit(1);
 }  }
   
Line 157 
Line 155 
         extern int optind;          extern int optind;
         extern char *optarg;          extern char *optarg;
   
           infile = stdin;         /* Read from STDIN unless changed by -b */
         debug_level = compress_flag = 0;          debug_level = compress_flag = 0;
   
         while ((ch = getopt(argc, argv, "1hvCo:s:S:")) != -1) {          while ((ch = getopt(argc, argv, "1hvCo:s:S:b:")) != -1) {
                 switch (ch) {                  switch (ch) {
                 case 'C':                  case 'C':
                         compress_flag = 1;                          compress_flag = 1;
Line 182 
Line 181 
                 case 'S':                  case 'S':
                         ssh_program = optarg;                          ssh_program = optarg;
                         break;                          break;
                   case 'b':
                           if (infile == stdin) {
                                   infile = fopen(optarg, "r");
                                   if (infile == NULL)
                                           fatal("%s (%s).", strerror(errno), optarg);
                           } else
                                   fatal("Filename already specified.");
                           break;
                 case 'h':                  case 'h':
                 default:                  default:
                         usage();                          usage();
Line 242 
Line 249 
   
         connect_to_server(make_ssh_args(NULL), &in, &out, &sshpid);          connect_to_server(make_ssh_args(NULL), &in, &out, &sshpid);
   
         do_init(in, out);  
   
         interactive_loop(in, out);          interactive_loop(in, out);
   
         close(in);          close(in);
         close(out);          close(out);
           if (infile != stdin)
         if (kill(sshpid, SIGHUP) == -1)                  fclose(infile);
                 fatal("Couldn't terminate ssh process: %s", strerror(errno));  
   
         if (waitpid(sshpid, NULL, 0) == -1)          if (waitpid(sshpid, NULL, 0) == -1)
                 fatal("Couldn't wait for ssh process: %s", strerror(errno));                  fatal("Couldn't wait for ssh process: %s", strerror(errno));

Legend:
Removed from v.1.7.2.2  
changed lines
  Added in v.1.7.2.3