[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.185 and 1.186

version 1.185, 2016/03/02 22:43:52 version 1.186, 2016/05/25 23:48:45
Line 83 
Line 83 
 #include <dirent.h>  #include <dirent.h>
 #include <errno.h>  #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
   #include <locale.h>
 #include <pwd.h>  #include <pwd.h>
 #include <signal.h>  #include <signal.h>
 #include <stdarg.h>  #include <stdarg.h>
Line 100 
Line 101 
 #include "log.h"  #include "log.h"
 #include "misc.h"  #include "misc.h"
 #include "progressmeter.h"  #include "progressmeter.h"
   #include "utf8.h"
   
 #define COPY_BUFLEN     16384  #define COPY_BUFLEN     16384
   
Line 175 
Line 177 
         if (verbose_mode) {          if (verbose_mode) {
                 fprintf(stderr, "Executing:");                  fprintf(stderr, "Executing:");
                 for (i = 0; i < a->num; i++)                  for (i = 0; i < a->num; i++)
                         fprintf(stderr, " %s", a->list[i]);                          fmprintf(stderr, " %s", a->list[i]);
                 fprintf(stderr, "\n");                  fprintf(stderr, "\n");
         }          }
         if ((pid = fork()) == -1)          if ((pid = fork()) == -1)
Line 216 
Line 218 
         int pin[2], pout[2], reserved[2];          int pin[2], pout[2], reserved[2];
   
         if (verbose_mode)          if (verbose_mode)
                 fprintf(stderr,                  fmprintf(stderr,
                     "Executing: program %s host %s, user %s, command %s\n",                      "Executing: program %s host %s, user %s, command %s\n",
                     ssh_program, host,                      ssh_program, host,
                     remuser ? remuser : "(unspecified)", cmd);                      remuser ? remuser : "(unspecified)", cmd);
Line 291 
Line 293 
         int status;          int status;
   
         if (verbose_mode)          if (verbose_mode)
                 fprintf(stderr,                  fmprintf(stderr,
                     "Executing: 2nd program %s host %s, user %s, command %s\n",                      "Executing: 2nd program %s host %s, user %s, command %s\n",
                     ssh_program, host,                      ssh_program, host,
                     remuser ? remuser : "(unspecified)", cmd);                      remuser ? remuser : "(unspecified)", cmd);
Line 362 
Line 364 
         /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */          /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
         sanitise_stdfd();          sanitise_stdfd();
   
           setlocale(LC_CTYPE, "");
   
         /* Copy argv, because we modify it */          /* Copy argv, because we modify it */
         newargv = xcalloc(MAX(argc + 1, 1), sizeof(*newargv));          newargv = xcalloc(MAX(argc + 1, 1), sizeof(*newargv));
         for (n = 0; n < argc; n++)          for (n = 0; n < argc; n++)
Line 789 
Line 793 
                 snprintf(buf, sizeof buf, "C%04o %lld %s\n",                  snprintf(buf, sizeof buf, "C%04o %lld %s\n",
                     (u_int) (stb.st_mode & FILEMODEMASK),                      (u_int) (stb.st_mode & FILEMODEMASK),
                     (long long)stb.st_size, last);                      (long long)stb.st_size, last);
                 if (verbose_mode) {                  if (verbose_mode)
                         fprintf(stderr, "Sending file modes: %s", buf);                          fmprintf(stderr, "Sending file modes: %s", buf);
                 }  
                 (void) atomicio(vwrite, remout, buf, strlen(buf));                  (void) atomicio(vwrite, remout, buf, strlen(buf));
                 if (response() < 0)                  if (response() < 0)
                         goto next;                          goto next;
Line 868 
Line 871 
         (void) snprintf(path, sizeof path, "D%04o %d %.1024s\n",          (void) snprintf(path, sizeof path, "D%04o %d %.1024s\n",
             (u_int) (statp->st_mode & FILEMODEMASK), 0, last);              (u_int) (statp->st_mode & FILEMODEMASK), 0, last);
         if (verbose_mode)          if (verbose_mode)
                 fprintf(stderr, "Entering directory: %s", path);                  fmprintf(stderr, "Entering directory: %s", path);
         (void) atomicio(vwrite, remout, path, strlen(path));          (void) atomicio(vwrite, remout, path, strlen(path));
         if (response() < 0) {          if (response() < 0) {
                 closedir(dirp);                  closedir(dirp);
Line 908 
Line 911 
         off_t size, statbytes;          off_t size, statbytes;
         unsigned long long ull;          unsigned long long ull;
         int setimes, targisdir, wrerrno = 0;          int setimes, targisdir, wrerrno = 0;
         char ch, *cp, *np, *targ, *why, *vect[1], buf[2048];          char ch, *cp, *np, *targ, *why, *vect[1], buf[2048], visbuf[2048];
         struct timeval tv[2];          struct timeval tv[2];
   
 #define atime   tv[0]  #define atime   tv[0]
Line 943 
Line 946 
                 } while (cp < &buf[sizeof(buf) - 1] && ch != '\n');                  } while (cp < &buf[sizeof(buf) - 1] && ch != '\n');
                 *cp = 0;                  *cp = 0;
                 if (verbose_mode)                  if (verbose_mode)
                         fprintf(stderr, "Sink: %s", buf);                          fmprintf(stderr, "Sink: %s", buf);
   
                 if (buf[0] == '\01' || buf[0] == '\02') {                  if (buf[0] == '\01' || buf[0] == '\02') {
                         if (iamremote == 0)                          if (iamremote == 0) {
                                   (void) snmprintf(visbuf, sizeof(visbuf),
                                       NULL, "%s", buf + 1);
                                 (void) atomicio(vwrite, STDERR_FILENO,                                  (void) atomicio(vwrite, STDERR_FILENO,
                                     buf + 1, strlen(buf + 1));                                      visbuf, strlen(visbuf));
                           }
                         if (buf[0] == '\02')                          if (buf[0] == '\02')
                                 exit(1);                                  exit(1);
                         ++errs;                          ++errs;
Line 1183 
Line 1189 
 int  int
 response(void)  response(void)
 {  {
         char ch, *cp, resp, rbuf[2048];          char ch, *cp, resp, rbuf[2048], visbuf[2048];
   
         if (atomicio(read, remin, &resp, sizeof(resp)) != sizeof(resp))          if (atomicio(read, remin, &resp, sizeof(resp)) != sizeof(resp))
                 lostconn(0);                  lostconn(0);
Line 1203 
Line 1209 
                         *cp++ = ch;                          *cp++ = ch;
                 } while (cp < &rbuf[sizeof(rbuf) - 1] && ch != '\n');                  } while (cp < &rbuf[sizeof(rbuf) - 1] && ch != '\n');
   
                 if (!iamremote)                  if (!iamremote) {
                         (void) atomicio(vwrite, STDERR_FILENO, rbuf, cp - rbuf);                          cp[-1] = '\0';
                           (void) snmprintf(visbuf, sizeof(visbuf),
                               NULL, "%s\n", rbuf);
                           (void) atomicio(vwrite, STDERR_FILENO,
                               visbuf, strlen(visbuf));
                   }
                 ++errs;                  ++errs;
                 if (resp == 1)                  if (resp == 1)
                         return (-1);                          return (-1);
Line 1242 
Line 1253 
   
         if (!iamremote) {          if (!iamremote) {
                 va_start(ap, fmt);                  va_start(ap, fmt);
                 vfprintf(stderr, fmt, ap);                  vfmprintf(stderr, fmt, ap);
                 va_end(ap);                  va_end(ap);
                 fprintf(stderr, "\n");                  fprintf(stderr, "\n");
         }          }
Line 1288 
Line 1299 
         } while (*++cp);          } while (*++cp);
         return (1);          return (1);
   
 bad:    fprintf(stderr, "%s: invalid user name\n", cp0);  bad:    fmprintf(stderr, "%s: invalid user name\n", cp0);
         return (0);          return (0);
 }  }
   

Legend:
Removed from v.1.185  
changed lines
  Added in v.1.186