[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.66 and 1.66.2.3

version 1.66, 2005/08/08 13:22:48 version 1.66.2.3, 2006/11/08 00:44:05
Line 1 
Line 1 
   /* $OpenBSD$ */
 /*  /*
  * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>   * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
  *   *
Line 14 
Line 15 
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
   
 #include "includes.h"  #include <sys/types.h>
   #include <sys/ioctl.h>
   #include <sys/wait.h>
   #include <sys/stat.h>
   #include <sys/socket.h>
   #include <sys/param.h>
   
 RCSID("$OpenBSD$");  #include <errno.h>
   
 #include <glob.h>  #include <glob.h>
 #include <histedit.h>  #include <histedit.h>
   #include <paths.h>
   #include <signal.h>
   #include <stdlib.h>
   #include <stdio.h>
   #include <string.h>
   #include <unistd.h>
   #include <stdarg.h>
   
 #include "buffer.h"  
 #include "xmalloc.h"  #include "xmalloc.h"
 #include "log.h"  #include "log.h"
 #include "pathnames.h"  #include "pathnames.h"
 #include "misc.h"  #include "misc.h"
   
 #include "sftp.h"  #include "sftp.h"
   #include "buffer.h"
 #include "sftp-common.h"  #include "sftp-common.h"
 #include "sftp-client.h"  #include "sftp-client.h"
   
Line 230 
Line 242 
                 if (errno != EINTR)                  if (errno != EINTR)
                         fatal("Couldn't wait for child: %s", strerror(errno));                          fatal("Couldn't wait for child: %s", strerror(errno));
         if (!WIFEXITED(status))          if (!WIFEXITED(status))
                 error("Shell exited abormally");                  error("Shell exited abnormally");
         else if (WEXITSTATUS(status))          else if (WEXITSTATUS(status))
                 error("Shell exited with status %d", WEXITSTATUS(status));                  error("Shell exited with status %d", WEXITSTATUS(status));
 }  }
Line 469 
Line 481 
         if (stat(path, &sb) == -1)          if (stat(path, &sb) == -1)
                 return(0);                  return(0);
   
         return(sb.st_mode & S_IFDIR);          return(S_ISDIR(sb.st_mode));
 }  }
   
 static int  static int
Line 493 
Line 505 
                 return(0);                  return(0);
         if (!(a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS))          if (!(a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS))
                 return(0);                  return(0);
         return(a->perm & S_IFDIR);          return(S_ISDIR(a->perm));
 }  }
   
 static int  static int
Line 533 
Line 545 
   
                 if (g.gl_matchc == 1 && dst) {                  if (g.gl_matchc == 1 && dst) {
                         /* If directory specified, append filename */                          /* If directory specified, append filename */
                           xfree(tmp);
                         if (is_dir(dst)) {                          if (is_dir(dst)) {
                                 if (infer_path(g.gl_pathv[0], &tmp)) {                                  if (infer_path(g.gl_pathv[0], &tmp)) {
                                         err = 1;                                          err = 1;
Line 557 
Line 570 
   
 out:  out:
         xfree(abs_src);          xfree(abs_src);
         if (abs_dst)  
                 xfree(abs_dst);  
         globfree(&g);          globfree(&g);
         return(err);          return(err);
 }  }
Line 692 
Line 703 
         }          }
   
         if (lflag & SORT_FLAGS) {          if (lflag & SORT_FLAGS) {
                   for (n = 0; d[n] != NULL; n++)
                           ;       /* count entries */
                 sort_flag = lflag & (SORT_FLAGS|LS_REVERSE_SORT);                  sort_flag = lflag & (SORT_FLAGS|LS_REVERSE_SORT);
                 qsort(d, n, sizeof(*d), sdirent_comp);                  qsort(d, n, sizeof(*d), sdirent_comp);
         }          }
Line 952 
Line 965 
         case I_CHOWN:          case I_CHOWN:
         case I_CHGRP:          case I_CHGRP:
                 /* Get numeric arg (mandatory) */                  /* Get numeric arg (mandatory) */
                   errno = 0;
                 l = strtol(cp, &cp2, base);                  l = strtol(cp, &cp2, base);
                 if (cp2 == cp || ((l == LONG_MIN || l == LONG_MAX) &&                  if (cp2 == cp || ((l == LONG_MIN || l == LONG_MAX) &&
                     errno == ERANGE) || l < 0) {                      errno == ERANGE) || l < 0) {
Line 1269 
Line 1283 
                         if (parse_dispatch_command(conn, cmd, &pwd, 1) != 0) {                          if (parse_dispatch_command(conn, cmd, &pwd, 1) != 0) {
                                 xfree(dir);                                  xfree(dir);
                                 xfree(pwd);                                  xfree(pwd);
                                   xfree(conn);
                                 return (-1);                                  return (-1);
                         }                          }
                 } else {                  } else {
Line 1281 
Line 1296 
                         err = parse_dispatch_command(conn, cmd, &pwd, 1);                          err = parse_dispatch_command(conn, cmd, &pwd, 1);
                         xfree(dir);                          xfree(dir);
                         xfree(pwd);                          xfree(pwd);
                           xfree(conn);
                         return (err);                          return (err);
                 }                  }
                 xfree(dir);                  xfree(dir);
Line 1337 
Line 1353 
                         break;                          break;
         }          }
         xfree(pwd);          xfree(pwd);
           xfree(conn);
   
         if (el != NULL)          if (el != NULL)
                 el_end(el);                  el_end(el);
Line 1350 
Line 1367 
 {  {
         int c_in, c_out;          int c_in, c_out;
   
 #ifdef USE_PIPES  
         int pin[2], pout[2];  
   
         if ((pipe(pin) == -1) || (pipe(pout) == -1))  
                 fatal("pipe: %s", strerror(errno));  
         *in = pin[0];  
         *out = pout[1];  
         c_in = pout[0];  
         c_out = pin[1];  
 #else /* USE_PIPES */  
         int inout[2];          int inout[2];
   
         if (socketpair(AF_UNIX, SOCK_STREAM, 0, inout) == -1)          if (socketpair(AF_UNIX, SOCK_STREAM, 0, inout) == -1)
                 fatal("socketpair: %s", strerror(errno));                  fatal("socketpair: %s", strerror(errno));
         *in = *out = inout[0];          *in = *out = inout[0];
         c_in = c_out = inout[1];          c_in = c_out = inout[1];
 #endif /* USE_PIPES */  
   
         if ((sshpid = fork()) == -1)          if ((sshpid = fork()) == -1)
                 fatal("fork: %s", strerror(errno));                  fatal("fork: %s", strerror(errno));
Line 1428 
Line 1434 
         extern int optind;          extern int optind;
         extern char *optarg;          extern char *optarg;
   
           /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
           sanitise_stdfd();
   
           memset(&args, '\0', sizeof(args));
         args.list = NULL;          args.list = NULL;
         addargs(&args, "ssh");          /* overwritten with ssh_program */          addargs(&args, "%s", ssh_program);
         addargs(&args, "-oForwardX11 no");          addargs(&args, "-oForwardX11 no");
         addargs(&args, "-oForwardAgent no");          addargs(&args, "-oForwardAgent no");
           addargs(&args, "-oPermitLocalCommand no");
         addargs(&args, "-oClearAllForwardings yes");          addargs(&args, "-oClearAllForwardings yes");
   
         ll = SYSLOG_LEVEL_INFO;          ll = SYSLOG_LEVEL_INFO;
Line 1463 
Line 1474 
                         break;                          break;
                 case 'S':                  case 'S':
                         ssh_program = optarg;                          ssh_program = optarg;
                           replacearg(&args, 0, "%s", ssh_program);
                         break;                          break;
                 case 'b':                  case 'b':
                         if (batchmode)                          if (batchmode)
Line 1539 
Line 1551 
                 addargs(&args, "%s", host);                  addargs(&args, "%s", host);
                 addargs(&args, "%s", (sftp_server != NULL ?                  addargs(&args, "%s", (sftp_server != NULL ?
                     sftp_server : "sftp"));                      sftp_server : "sftp"));
                 args.list[0] = ssh_program;  
   
                 if (!batchmode)                  if (!batchmode)
                         fprintf(stderr, "Connecting to %s...\n", host);                          fprintf(stderr, "Connecting to %s...\n", host);
Line 1552 
Line 1563 
                         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);
         }          }
           freeargs(&args);
   
         err = interactive_loop(in, out, file1, file2);          err = interactive_loop(in, out, file1, file2);
   

Legend:
Removed from v.1.66  
changed lines
  Added in v.1.66.2.3