diff -N -c -r -X exclude_files squid-1.0.beta11/lib/Makefile.in squid-1.0.beta11.henrik/lib/Makefile.in *** squid-1.0.beta11/lib/Makefile.in Fri May 17 04:55:52 1996 --- squid-1.0.beta11.henrik/lib/Makefile.in Wed Jun 5 21:39:09 1996 *************** *** 27,33 **** getfullhostname.o \ debug.o \ log.o \ ! tempnam.o REGEXOBJS = GNUregex.o LIBS = libmiscutil.a libregex.a --- 27,34 ---- getfullhostname.o \ debug.o \ log.o \ ! tempnam.o \ ! base64.o REGEXOBJS = GNUregex.o LIBS = libmiscutil.a libregex.a diff -N -c -r -X exclude_files squid-1.0.beta11/lib/base64.c squid-1.0.beta11.henrik/lib/base64.c *** squid-1.0.beta11/lib/base64.c Thu Jan 1 01:00:00 1970 --- squid-1.0.beta11.henrik/lib/base64.c Wed Jun 5 21:42:03 1996 *************** *** 0 **** --- 1,61 ---- + #include "config.h" + + #if HAVE_STDIO_H + #include + #endif + #if HAVE_STDLIB_H + #include + #endif + + static int base64_initialized=0; + int base64_value[256]; + char base64_code[]="ABCDEFGHIJKLMNOPQRSTUVWZYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + static void base64_init() + { + int i; + + for(i=0;i<256;i++) + base64_value[i]=-1; + + for(i=0;i<64;i++) + base64_value[(int)base64_code[i]]=i; + base64_value['=']=0; + + base64_initialized=1; + } + + char *base64_decode(p) + unsigned char *p; + { + static char result[8192]; + int c; + long val; + int i; + char *d; + + if(!p) + return p; + + if(!base64_initialized) + base64_init(); + + val=c=0; + d=result; + while(*p) { + i=base64_value[(int)*p++]; + if(i>=0) { + val=val*64+i; + c++; + } + if(c==4) { /* One quantum of four encoding characters/24 bit */ + *d++=val>>16; /* High 8 bits */ + *d++=(val>>8)&0xff; /* Mid 8 bits */ + *d++=val&0xff; /* Low 8 bits */ + val=c=0; + } + } + + return *result ? result : NULL; + } + diff -N -c -r -X exclude_files squid-1.0.beta11/src/errorpage.c squid-1.0.beta11.henrik/src/errorpage.c *** squid-1.0.beta11/src/errorpage.c Sat May 18 20:49:04 1996 --- squid-1.0.beta11.henrik/src/errorpage.c Thu Jun 6 00:04:58 1996 *************** *** 97,102 **** --- 97,103 ---- /* LOCAL */ static char *tbuf; + static char *msg; int log_errors = 1; *************** *** 104,109 **** --- 105,111 ---- { tmp_error_buf = xmalloc(MAX_URL * 4); tbuf = xmalloc(MAX_URL * 3); + msg = xmalloc(MAX_URL * 3); } *************** *** 237,239 **** --- 239,278 ---- getMyHostname()); return tmp_error_buf; } + + char *authorization_needed_msg(request,realm) + request_t *request; + char *realm; + { + sprintf(msg,"Authorization needed\n\ + Sorry, you have to authorize yourself to request\n\ +
    ftp://%s@%s%s
\n\ + from this cache. Please check with the cache administrator if you\n\ + believe this is incorrect.\n\ +
\n\ +
\n\ + Generated by %s/%s@%s\n\ +
\n\ + \n", + request->login, + request->host, + request->urlpath, + appname, + version_string, + getMyHostname()); + + mk_mime_hdr(tbuf, + (time_t) getNegativeTTL(), + strlen(msg), + 0, + "text/html"); + sprintf(tmp_error_buf,"HTTP/1.0 401 Unauthorized\r\n\ + %s\ + WWW-Authenticate: Basic realm=\"%s\"\r\n\ + \r\n\ + %s", + tbuf,realm,msg); + return tmp_error_buf; + } + + diff -N -c -r -X exclude_files squid-1.0.beta11/src/errorpage.h squid-1.0.beta11.henrik/src/errorpage.h *** squid-1.0.beta11/src/errorpage.h Tue Apr 16 07:05:21 1996 --- squid-1.0.beta11.henrik/src/errorpage.h Wed Jun 5 21:32:44 1996 *************** *** 7,11 **** --- 7,12 ---- extern char *squid_error_request _PARAMS((char *, int, char *, int)); extern void errorInitialize _PARAMS((void)); extern char *access_denied_msg _PARAMS((int, int, char *, char *)); + extern char *authorization_needed_msg _PARAMS((request_t *, char *)); extern char *tmp_error_buf; diff -N -c -r -X exclude_files squid-1.0.beta11/src/ftp.c squid-1.0.beta11.henrik/src/ftp.c *** squid-1.0.beta11/src/ftp.c Fri May 31 08:14:43 1996 --- squid-1.0.beta11.henrik/src/ftp.c Thu Jun 6 00:27:34 1996 *************** *** 33,38 **** --- 33,39 ---- * expires */ int got_marker; /* denotes end of successful request */ int reply_hdr_state; + int authenticated; /* This ftp request is authenticated */ } FtpData; *************** *** 50,55 **** --- 51,59 ---- void ftpConnInProgress _PARAMS((int fd, FtpData * data)); void ftpServerClose _PARAMS((void)); + /* External functions */ + extern char *base64_decode _PARAMS((char *coded)); + static int ftpStateFree(fd, ftpState) int fd; FtpData *ftpState; *************** *** 479,484 **** --- 434,442 ---- sprintf(tbuf, "-P %d ", data->request->port); strcat(buf, tbuf); } + if (data->authenticated) { + strcat(buf, "-a "); + } strcat(buf, "-h "); /* httpify */ strcat(buf, "- "); /* stdout */ strcat(buf, data->request->host); *************** *** 542,548 **** --- 500,512 ---- request_t *request; StoreEntry *entry; { + static char realm[8192]; FtpData *data = NULL; + char *req_hdr = entry->mem_obj->mime_hdr; + char *auth_hdr; + char *response; + char *auth; + int status; debug(9, 3, "FtpStart: FD %d \n", unusedfd, url); *************** *** 552,559 **** data->request = request; request->link_count++; /* Parse login info. */ ! ftp_login_parser(request->login, data); debug(9, 5, "FtpStart: FD %d, host=%s, path=%s, user=%s, passwd=%s\n", unusedfd, data->request->host, data->request->urlpath, --- 516,551 ---- data->request = request; request->link_count++; + auth_hdr=mime_get_header(req_hdr,"Authorization"); + auth=NULL; + if(auth_hdr) { + if(strcasecmp(strtok(auth_hdr," \t"),"Basic")==0) { + auth=base64_decode(strtok(NULL," \t")); + } + } + /* Parse login info. */ ! if(auth) { ! ftp_login_parser(auth, data); ! data->authenticated=1; ! } else { ! ftp_login_parser(request->login, data); ! if(*data->user && !*data->password) { ! /* This request is not fully authenticated */ ! if(request->port==21) { ! sprintf(realm,"ftp %s", data->user); ! } else { ! sprintf(realm,"ftp %s port %d", ! data->user, request->port); ! } ! response=authorization_needed_msg(request,realm); ! storeAppend(entry, response, strlen(response)); ! httpParseHeaders(response,entry->mem_obj->reply); ! storeComplete(entry); ! ftpStateFree(-1, data); ! return COMM_OK; ! } ! } debug(9, 5, "FtpStart: FD %d, host=%s, path=%s, user=%s, passwd=%s\n", unusedfd, data->request->host, data->request->urlpath, *************** *** 566,572 **** #endif if (data->ftp_fd == COMM_ERROR) { squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror()); ! safe_free(data); return COMM_ERROR; } /* Pipe/socket created ok */ --- 558,564 ---- #endif if (data->ftp_fd == COMM_ERROR) { squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror()); ! ftpStateFree(-1, data); return COMM_ERROR; } /* Pipe/socket created ok */ diff -N -c -r -X exclude_files squid-1.0.beta11/src/ftpget.c squid-1.0.beta11.henrik/src/ftpget.c *** squid-1.0.beta11/src/ftpget.c Fri May 31 06:21:57 1996 --- squid-1.0.beta11.henrik/src/ftpget.c Wed Jun 5 15:59:48 1996 *************** *** 262,267 **** --- 262,269 ---- int o_timeout = XFER_TIMEOUT; /* data/command timeout, from config.h */ int o_neg_ttl = 300; /* negative TTL, default 5 min */ int o_httpify = 0; /* convert to HTTP */ + int o_showpass = 1; /* Show password in generated URLs */ + int o_showlogin = 1; /* Show login info in generated URLs */ char *o_iconprefix = "internal-"; /* URL prefix for icons */ char *o_iconsuffix = ""; /* URL suffix for icons */ int o_list_width = 32; /* size of filenames in directory list */ *************** *** 2381,2386 **** --- 2383,2390 ---- fprintf(stderr, "\t-p path Icon URL prefix\n"); fprintf(stderr, "\t-s .ext Icon URL suffix\n"); fprintf(stderr, "\t-h Convert to HTTP\n"); + fprintf(stderr, "\t-a Do not show password in generated URLs\n"); + fprintf(stderr, "\t-A Do not show login information in generated URLs\n"); fprintf(stderr, "\t-R DON'T get README file\n"); fprintf(stderr, "\t-w chars Filename width in directory listing\n"); fprintf(stderr, "\t-W Wrap long filenames\n"); *************** *** 2450,2455 **** --- 2454,2463 ---- !strcmp(*argv, "-h")) { o_httpify = 1; continue; + } else if (!strcmp(*argv, "-a")) { + o_showpass = 0; + } else if (!strcmp(*argv, "-A")) { + o_showlogin = 0; } else if (!strcmp(*argv, "-S")) { if (--argc < 1) usage(argc); *************** *** 2598,2606 **** *r->url = '\0'; strcat(r->url, "ftp://"); if (strcmp(r->user, "anonymous")) { ! strcat(r->url, r->user); ! strcat(r->url, ":"); ! strcat(r->url, r->pass); strcat(r->url, "@"); } strcat(r->url, r->host); --- 2606,2618 ---- *r->url = '\0'; strcat(r->url, "ftp://"); if (strcmp(r->user, "anonymous")) { ! if (o_showlogin ) { ! strcat(r->url, r->user); ! if (o_showpass) { ! strcat(r->url, ":"); ! strcat(r->url, r->pass); ! } ! } strcat(r->url, "@"); } strcat(r->url, r->host);