[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.72 and 1.73

version 1.72, 2007/02/08 03:19:12 version 1.73, 2007/04/17 14:58:51
Line 69 
Line 69 
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
 #include <util.h>  #include <util.h>
   #include <resolv.h>
   
 #ifndef SMALL  #ifndef SMALL
 #include <openssl/ssl.h>  #include <openssl/ssl.h>
Line 100 
Line 101 
 #define FTP_PROXY       "ftp_proxy"     /* env var with ftp proxy location */  #define FTP_PROXY       "ftp_proxy"     /* env var with ftp proxy location */
 #define HTTP_PROXY      "http_proxy"    /* env var with http proxy location */  #define HTTP_PROXY      "http_proxy"    /* env var with http proxy location */
   
   #define COOKIE_MAX_LEN  42
   
 #define EMPTYSTRING(x)  ((x) == NULL || (*(x) == '\0'))  #define EMPTYSTRING(x)  ((x) == NULL || (*(x) == '\0'))
   
Line 124 
Line 126 
         struct addrinfo hints, *res0, *res;          struct addrinfo hints, *res0, *res;
         const char * volatile savefile;          const char * volatile savefile;
         char * volatile proxyurl = NULL;          char * volatile proxyurl = NULL;
           char *cookie = NULL;
         volatile int s = -1, out;          volatile int s = -1, out;
         volatile sig_t oldintr;          volatile sig_t oldintr;
         FILE *fin = NULL;          FILE *fin = NULL;
Line 215 
Line 218 
                 *--path = '/';                  /* add / back to real path */                  *--path = '/';                  /* add / back to real path */
                 path = strchr(host, '/');       /* remove trailing / on host */                  path = strchr(host, '/');       /* remove trailing / on host */
                 if (!EMPTYSTRING(path))                  if (!EMPTYSTRING(path))
                           *path++ = '\0';         /* i guess this ++ is useless */
   
                   path = strchr(host, '@');       /* look for credentials in proxy */
                   if (!EMPTYSTRING(path)) {
                         *path++ = '\0';                          *path++ = '\0';
                           cookie = strchr(host, ':');
                           if (EMPTYSTRING(cookie)) {
                                   warnx("Malformed proxy URL: %s", proxyenv);
                                   goto cleanup_url_get;
                           }
                           cookie  = malloc(COOKIE_MAX_LEN);
                           b64_ntop(host, strlen(host), cookie, COOKIE_MAX_LEN);
                           /*
                            * This removes the password from proxyenv,
                            * filling with stars
                            */
                           for (host = strchr(proxyenv + 5, ':');  *host != '@';
                                host++)
                                   *host = '*';
   
                           host = path;
                   }
                 path = newline;                  path = newline;
         }          }
   
Line 431 
Line 455 
                  * 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.
                  */                   */
                 ftp_printf(fin, ssl, "GET %s HTTP/1.0\r\n%s\r\n\r\n", path,                  if (cookie)
                     HTTP_USER_AGENT);                          ftp_printf(fin, ssl, "GET %s HTTP/1.0\r\n"
                               "Proxy-Authorization: Basic %s\r\n%s\r\n\r\n",
                               path, cookie, HTTP_USER_AGENT);
                   else
                           ftp_printf(fin, ssl, "GET %s HTTP/1.0\r\n%s\r\n\r\n",
                               path, HTTP_USER_AGENT);
   
         } else {          } else {
                 ftp_printf(fin, ssl, "GET /%s HTTP/1.0\r\nHost: ", path);                  ftp_printf(fin, ssl, "GET /%s HTTP/1.0\r\nHost: ", path);
                 if (strchr(host, ':')) {                  if (strchr(host, ':')) {

Legend:
Removed from v.1.72  
changed lines
  Added in v.1.73