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

Diff for /src/usr.bin/ftp/fetch.c between version 1.156 and 1.157

version 1.156, 2017/01/07 12:10:11 version 1.157, 2017/01/10 17:43:12
Line 67 
Line 67 
 #include "ftp_var.h"  #include "ftp_var.h"
 #include "cmds.h"  #include "cmds.h"
   
 static int      url_get(const char *, const char *, const char *);  static int      url_get(const char *, const char *, const char *, int);
 void            aborthttp(int);  void            aborthttp(int);
 void            abortfile(int);  void            abortfile(int);
 char            hextochar(const char *);  char            hextochar(const char *);
Line 181 
Line 181 
  * Returns -1 on failure, 0 on success   * Returns -1 on failure, 0 on success
  */   */
 static int  static int
 url_get(const char *origline, const char *proxyenv, const char *outfile)  url_get(const char *origline, const char *proxyenv, const char *outfile, int lastfile)
 {  {
         char pbuf[NI_MAXSERV], hbuf[NI_MAXHOST], *cp, *portnum, *path, ststr[4];          char pbuf[NI_MAXSERV], hbuf[NI_MAXHOST], *cp, *portnum, *path, ststr[4];
         char *hosttail, *cause = "unknown", *newline, *host, *port, *buf = NULL;          char *hosttail, *cause = "unknown", *newline, *host, *port, *buf = NULL;
Line 640 
Line 640 
         fin = fdopen(s, "r+");          fin = fdopen(s, "r+");
 #endif /* !NOSSL */  #endif /* !NOSSL */
   
   #ifdef SMALL
           if (lastfile) {
                   if (pipeout) {
                           if (pledge("stdio rpath inet dns tty",  NULL) == -1)
                                   err(1, "pledge");
                   } else {
                           if (pledge("stdio rpath wpath cpath inet dns tty", NULL) == -1)
                                   err(1, "pledge");
                   }
           }
   #endif
   
         if (connect_timeout) {          if (connect_timeout) {
                 signal(SIGALRM, SIG_DFL);                  signal(SIGALRM, SIG_DFL);
                 alarmtimer(0);                  alarmtimer(0);
Line 903 
Line 915 
                                 fclose(fin);                                  fclose(fin);
                         else if (s != -1)                          else if (s != -1)
                                 close(s);                                  close(s);
                         rval = url_get(redirurl, proxyenv, savefile);                          rval = url_get(redirurl, proxyenv, savefile, lastfile);
                         free(redirurl);                          free(redirurl);
                         goto cleanup_url_get;                          goto cleanup_url_get;
                 }                  }
Line 924 
Line 936 
                         warn("Can't open %s", savefile);                          warn("Can't open %s", savefile);
                         goto cleanup_url_get;                          goto cleanup_url_get;
                 }                  }
         } else          } else {
                 out = fileno(stdout);                  out = fileno(stdout);
   #ifdef SMALL
                   if (lastfile) {
                           if (pledge("stdio tty", NULL) == -1)
                                   err(1, "pledge");
                   }
   #endif
           }
   
         /* Trap signals */          /* Trap signals */
         oldintr = NULL;          oldintr = NULL;
Line 1078 
Line 1097 
         char *cp, *url, *host, *dir, *file, *portnum;          char *cp, *url, *host, *dir, *file, *portnum;
         char *username, *pass, *pathstart;          char *username, *pass, *pathstart;
         char *ftpproxy, *httpproxy;          char *ftpproxy, *httpproxy;
         int rval, xargc;          int rval, xargc, lastfile;
         volatile int argpos;          volatile int argpos;
         int dirhasglob, filehasglob, oautologin;          int dirhasglob, filehasglob, oautologin;
         char rempath[PATH_MAX];          char rempath[PATH_MAX];
Line 1110 
Line 1129 
                 free(pass);                  free(pass);
                 host = dir = file = portnum = username = pass = NULL;                  host = dir = file = portnum = username = pass = NULL;
   
                   lastfile = (argv[argpos+1] == NULL);
   
                 /*                  /*
                  * We muck with the string, so we make a copy.                   * We muck with the string, so we make a copy.
                  */                   */
Line 1127 
Line 1148 
 #endif /* !NOSSL */  #endif /* !NOSSL */
                     strncasecmp(url, FILE_URL, sizeof(FILE_URL) - 1) == 0) {                      strncasecmp(url, FILE_URL, sizeof(FILE_URL) - 1) == 0) {
                         redirect_loop = 0;                          redirect_loop = 0;
                         if (url_get(url, httpproxy, outfile) == -1)                          if (url_get(url, httpproxy, outfile, lastfile) == -1)
                                 rval = argpos + 1;                                  rval = argpos + 1;
                         continue;                          continue;
                 }                  }
Line 1142 
Line 1163 
                         char *passend, *passagain, *userend;                          char *passend, *passagain, *userend;
   
                         if (ftpproxy) {                          if (ftpproxy) {
                                 if (url_get(url, ftpproxy, outfile) == -1)                                  if (url_get(url, ftpproxy, outfile, lastfile) == -1)
                                         rval = argpos + 1;                                          rval = argpos + 1;
                                 continue;                                  continue;
                         }                          }

Legend:
Removed from v.1.156  
changed lines
  Added in v.1.157