[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.69 and 1.70

version 1.69, 2001/05/03 23:09:53 version 1.70, 2001/05/08 19:45:24
Line 93 
Line 93 
 int getttywidth(void);  int getttywidth(void);
 int do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc);  int do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc);
   
 /* setup arguments for the call to ssh */  /* Struct for addargs */
 void addargs(char *fmt, ...) __attribute__((format(printf, 1, 2)));  arglist args;
   
 /* Time a transfer started. */  /* Time a transfer started. */
 static struct timeval start;  static struct timeval start;
Line 117 
Line 117 
 /* 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 the list of arguments that scp passes to ssh */  
 struct {  
         char    **list;  
         int     num;  
         int     nalloc;  
 } args;  
   
 /*  /*
  * 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 167 
Line 160 
   
                 args.list[0] = ssh_program;                  args.list[0] = ssh_program;
                 if (remuser != NULL)                  if (remuser != NULL)
                         addargs("-l%s", remuser);                          addargs(&args, "-l%s", remuser);
                 addargs("%s", host);                  addargs(&args, "%s", host);
                 addargs("%s", cmd);                  addargs(&args, "%s", cmd);
   
                 execvp(ssh_program, args.list);                  execvp(ssh_program, args.list);
                 perror(ssh_program);                  perror(ssh_program);
Line 222 
Line 215 
         extern int optind;          extern int optind;
   
         args.list = NULL;          args.list = NULL;
         addargs("ssh");         /* overwritten with ssh_program */          addargs(&args, "ssh");          /* overwritten with ssh_program */
         addargs("-x");          addargs(&args, "-x");
         addargs("-oFallBackToRsh no");          addargs(&args, "-oFallBackToRsh no");
   
         fflag = tflag = 0;          fflag = tflag = 0;
         while ((ch = getopt(argc, argv, "dfprtvBCc:i:P:q46S:o:")) != -1)          while ((ch = getopt(argc, argv, "dfprtvBCc:i:P:q46S:o:")) != -1)
Line 233 
Line 226 
                 case '4':                  case '4':
                 case '6':                  case '6':
                 case 'C':                  case 'C':
                         addargs("-%c", ch);                          addargs(&args, "-%c", ch);
                         break;                          break;
                 case 'o':                  case 'o':
                 case 'c':                  case 'c':
                 case 'i':                  case 'i':
                         addargs("-%c%s", ch, optarg);                          addargs(&args, "-%c%s", ch, optarg);
                         break;                          break;
                 case 'P':                  case 'P':
                         addargs("-p%s", optarg);                          addargs(&args, "-p%s", optarg);
                         break;                          break;
                 case 'B':                  case 'B':
                         addargs("-oBatchmode yes");                          addargs(&args, "-oBatchmode yes");
                         break;                          break;
                 case 'p':                  case 'p':
                         pflag = 1;                          pflag = 1;
Line 1167 
Line 1160 
                 return (winsize.ws_col ? winsize.ws_col : 80);                  return (winsize.ws_col ? winsize.ws_col : 80);
         else          else
                 return (80);                  return (80);
 }  
   
 void  
 addargs(char *fmt, ...)  
 {  
         va_list ap;  
         char buf[1024];  
   
         va_start(ap, fmt);  
         vsnprintf(buf, sizeof(buf), fmt, ap);  
         va_end(ap);  
   
         if (args.list == NULL) {  
                 args.nalloc = 32;  
                 args.num = 0;  
                 args.list = xmalloc(args.nalloc * sizeof(char *));  
         } else if (args.num+2 >= args.nalloc) {  
                 args.nalloc *= 2;  
                 args.list = xrealloc(args.list, args.nalloc * sizeof(char *));  
         }  
         args.list[args.num++] = xstrdup(buf);  
         args.list[args.num] = NULL;  
 }  }

Legend:
Removed from v.1.69  
changed lines
  Added in v.1.70