[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.80 and 1.81

version 1.80, 2008/07/08 21:07:57 version 1.81, 2008/09/26 11:11:59
Line 82 
Line 82 
 char            *ftp_readline(FILE *, SSL *, size_t *);  char            *ftp_readline(FILE *, SSL *, size_t *);
 size_t          ftp_read(FILE *, SSL *, char *, size_t);  size_t          ftp_read(FILE *, SSL *, char *, size_t);
 #ifndef SMALL  #ifndef SMALL
 int             proxy_connect(int, char *);  int             proxy_connect(int, char *, char *);
 int             SSL_vprintf(SSL *, const char *, va_list);  int             SSL_vprintf(SSL *, const char *, va_list);
 char            *SSL_readline(SSL *, size_t *);  char            *SSL_readline(SSL *, size_t *);
 #endif /* !SMALL */  #endif /* !SMALL */
Line 222 
Line 222 
   
                 path = strchr(host, '@');       /* look for credentials in proxy */                  path = strchr(host, '@');       /* look for credentials in proxy */
                 if (!EMPTYSTRING(path)) {                  if (!EMPTYSTRING(path)) {
                         *path++ = '\0';                          *path = '\0';
                         cookie = strchr(host, ':');                          cookie = strchr(host, ':');
                         if (EMPTYSTRING(cookie)) {                          if (EMPTYSTRING(cookie)) {
                                 warnx("Malformed proxy URL: %s", proxyenv);                                  warnx("Malformed proxy URL: %s", proxyenv);
                                 goto cleanup_url_get;                                  goto cleanup_url_get;
                         }                          }
                         cookie  = malloc(COOKIE_MAX_LEN);                          cookie  = malloc(COOKIE_MAX_LEN);
                         b64_ntop(host, strlen(host), cookie, COOKIE_MAX_LEN);                          if (cookie == NULL)
                                   errx(1, "out of memory");
                           if (b64_ntop(host, strlen(host), cookie, COOKIE_MAX_LEN) == -1)
                                   errx(1, "error in base64 encoding");
                           *path = '@'; /* restore @ in proxyurl */
                         /*                          /*
                          * This removes the password from proxyenv,                           * This removes the password from proxyurl,
                          * filling with stars                           * filling with stars
                          */                           */
                         for (host = strchr(proxyenv + 5, ':');  *host != '@';                          for (host = 1 + strchr(proxyurl + 5, ':');  *host != '@';
                              host++)                               host++)
                                 *host = '*';                                  *host = '*';
   
                         host = path;                          host = path + 1;
                 }                  }
                 path = newline;                  path = newline;
         }          }
Line 423 
Line 427 
   
 #ifndef SMALL  #ifndef SMALL
                 if (proxyenv && sslhost)                  if (proxyenv && sslhost)
                         proxy_connect(s, sslhost);                          proxy_connect(s, sslhost, cookie);
 #endif /* !SMALL */  #endif /* !SMALL */
                 break;                  break;
         }          }
Line 474 
Line 478 
 #endif /* !SMALL */  #endif /* !SMALL */
         if (proxyurl) {          if (proxyurl) {
                 if (verbose)                  if (verbose)
                         fprintf(ttyout, " (via %s)\n", proxyenv);                          fprintf(ttyout, " (via %s)\n", proxyurl);
                 /*                  /*
                  * Host: directive must use the destination host address for                   * Host: directive must use the destination host address for
                  * the original URI (path).  We do not attach it at this moment.                   * the original URI (path).  We do not attach it at this moment.
Line 649 
Line 653 
                                 close(s);                                  close(s);
                         free(proxyurl);                          free(proxyurl);
                         free(newline);                          free(newline);
                           free(cookie);
                         rval = url_get(cp, proxyenv, outfile);                          rval = url_get(cp, proxyenv, outfile);
                         free(buf);                          free(buf);
                         return (rval);                          return (rval);
Line 760 
Line 765 
         free(buf);          free(buf);
         free(proxyurl);          free(proxyurl);
         free(newline);          free(newline);
           free(cookie);
         return (rval);          return (rval);
 }  }
   
Line 1262 
Line 1268 
 }  }
   
 int  int
 proxy_connect(int socket, char *host)  proxy_connect(int socket, char *host, char *cookie)
 {  {
         int l;          int l;
         char buf[1024];          char buf[1024];
Line 1281 
Line 1287 
         if (!port)          if (!port)
                 port = "443";                  port = "443";
   
         l = asprintf(&connstr, "CONNECT %s:%s HTTP/1.1\n\n", host, port);          if (cookie) {
                   l = asprintf(&connstr, "CONNECT %s:%s HTTP/1.1\r\n"
                           "Proxy-Authorization: Basic %s\r\n%s\r\n\r\n",
                           host, port, cookie, HTTP_USER_AGENT);
           } else {
                   l = asprintf(&connstr, "CONNECT %s:%s HTTP/1.1\r\n%s\r\n\r\n",
                           host, port, HTTP_USER_AGENT);
           }
   
         if (l == -1)          if (l == -1)
                 errx(1, "Could not allocate memory to assemble connect string!");                  errx(1, "Could not allocate memory to assemble connect string!");
 #ifndef SMALL  #ifndef SMALL

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.81