update to links2.1pre14; tested by jolan@ and Pedro Bastos.

This commit is contained in:
fgsch 2003-11-17 22:59:32 +00:00
parent 11794ed32c
commit a96aea8dde
22 changed files with 75 additions and 1241 deletions

View File

@ -1,8 +1,8 @@
# $OpenBSD: Makefile,v 1.14 2003/09/23 06:35:33 fgsch Exp $
# $OpenBSD: Makefile,v 1.15 2003/11/17 22:59:32 fgsch Exp $
COMMENT= "graphics and text browser with javascript support"
VER= 2.1pre12
VER= 2.1pre14
DISTNAME= links-${VER}
PKGNAME= links+-${VER}
CATEGORIES= www
@ -35,7 +35,6 @@ CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include/libpng -I${LOCALBASE}/include" \
.endif
pre-configure:
cp ${FILESDIR}/auth.c ${WRKSRC}
cd ${WRKSRC}/intl && /bin/sh synclang
post-install:

View File

@ -1,3 +1,3 @@
MD5 (links-2.1pre12.tar.gz) = 62548242a1df8a26d23730cdb1ee096e
RMD160 (links-2.1pre12.tar.gz) = a02b3c7db4ddfa1c5ca8af3b2b5541401d549f60
SHA1 (links-2.1pre12.tar.gz) = b3a316118528555b7c9b30ca1b9f40c316b9b5c3
MD5 (links-2.1pre14.tar.gz) = 91247457966ed51b1ca5052d9a7890ed
RMD160 (links-2.1pre14.tar.gz) = 4ac5fb44380000691c9ab9b1715c03b9e6e10f8a
SHA1 (links-2.1pre14.tar.gz) = 6ebb73f2137c8f29ad1b8f94691ed151792f849a

View File

@ -1,540 +0,0 @@
/* HTTP Authentication support */
#include "links.h"
struct list_head http_auth_basic_list = { &http_auth_basic_list, &http_auth_basic_list };
unsigned char *straconcat(unsigned char *str, ...);
void init_auth()
{
need_auth=0;
}
/* Returns a valid host url for http authentication or NULL. */
/* FIXME: This really belongs to url.c, but it would look alien there. */
static unsigned char *
get_auth_url(unsigned char *url)
{
unsigned char *protocol = get_protocol_name(url);
unsigned char *host = get_host_name(url);
unsigned char *port = get_port_str(url);
unsigned char *newurl = NULL;
/* protocol == NULL is tested in straconcat() */;
newurl = straconcat(protocol, "://", host, NULL);
if (!newurl) goto end;
if (port && *port) {
add_to_strn(&newurl, ":");
add_to_strn(&newurl, port);
} else {
if (!strcasecmp(protocol, "http")) {
/* RFC2616 section 3.2.2
* If the port is empty or not given, port 80 is
* assumed. */
add_to_strn(&newurl, ":");
add_to_strn(&newurl, "80");
} else if (!strcasecmp(protocol, "https")) {
add_to_strn(&newurl, ":");
add_to_strn(&newurl, "443");
}
}
end:
if (protocol) mem_free(protocol);
if (host) mem_free(host);
if (port) mem_free(port);
return newurl;
}
/* Find if url/realm is in auth list. If a matching url is found, but realm is
* NULL, it returns the first record found. If realm isn't NULL, it returns
* the first record that matches exactly (url and realm) if any. */
struct http_auth_basic *
find_auth_entry(unsigned char *url, unsigned char *realm)
{
struct http_auth_basic *entry = NULL, *tmp_entry;
if (!url || !*url) return NULL;
foreach(tmp_entry, http_auth_basic_list) {
if (!strcasecmp(tmp_entry->url, url)) {
/* Found a matching url. */
entry = tmp_entry;
if (realm) {
/* From RFC 2617 section 1.2:
* The realm value (case-sensitive), in
* combination with the canonical root
* URL (the absolute URI for the server
* whose abs_path is empty; see section
* 5.1.2 of [2]) of the server being accessed,
* defines the protection space. */
if (tmp_entry->realm
&& !strcmp(tmp_entry->realm, realm)) {
/* Exact match. */
break; /* Stop here. */
}
} else {
/* Since realm is NULL, stops immediatly. */
break;
}
}
}
return entry;
}
/* Add a Basic Auth entry if needed. Returns -1 on error, 0 if entry do not
* exists and user/pass are in url, 1 if exact entry already exists or is
* in blocked state, 2 if entry was added. */
/* FIXME: use an enum for return codes. */
int
add_auth_entry(unsigned char *url, unsigned char *realm)
{
struct http_auth_basic *entry;
unsigned char *user = get_user_name(url);
unsigned char *pass = get_pass(url);
unsigned char *newurl = get_auth_url(url);
int ret = -1;
if (!newurl || !user || !pass) goto end;
/* Is host/realm already known ? */
entry = find_auth_entry(newurl, realm);
if (entry) {
/* Found an entry. */
if (entry->blocked == 1) {
/* Waiting for user/pass in dialog. */
ret = 1;
goto end;
}
/* If we have user/pass info then check if identical to
* those in entry. */
if ((*user || *pass) && entry->uid && entry->passwd) {
if (((!realm && !entry->realm)
|| (realm && entry->realm
&& !strcmp(realm, entry->realm)))
&& !strcmp(user, entry->uid)
&& !strcmp(pass, entry->passwd)) {
/* Same host/realm/pass/user. */
ret = 1;
goto end;
}
}
/* Delete entry and re-create it... */
/* FIXME: Could be better... */
del_auth_entry(entry);
}
/* Create a new entry. */
entry = mem_alloc(sizeof(struct http_auth_basic));
if (!entry) goto end;
memset(entry, 0, sizeof(struct http_auth_basic));
entry->url = newurl;
entry->url_len = strlen(entry->url); /* FIXME: Not really needed. */
if (realm) {
/* Copy realm value. */
entry->realm = stracpy(realm);
if (!entry->realm) {
mem_free(entry);
goto end;
}
}
if (*user || *pass) {
/* Copy user and pass info if any in passed url. */
entry->uid = mem_alloc(MAX_UID_LEN);
if (!entry->uid) {
mem_free(entry);
goto end;
}
safe_strncpy(entry->uid, user, MAX_UID_LEN);
entry->passwd = mem_alloc(MAX_PASSWD_LEN);
if (!entry->passwd) {
mem_free(entry);
goto end;
}
safe_strncpy(entry->passwd, pass, MAX_PASSWD_LEN);
ret = 0; /* Entry added with user/pass from url. */
}
add_to_list(http_auth_basic_list, entry);
if (ret) ret = 2; /* Entry added. */
end:
if (ret == -1 || ret == 1) {
if (newurl) mem_free(newurl);
}
if (user) mem_free(user);
if (pass) mem_free(pass);
return ret;
}
/* Find an entry in auth list by url. If url contains user/pass information
* and entry does not exist then entry is created.
* If entry exists but user/pass passed in url is different, then entry is
* updated (but not if user/pass is set in dialog).
* It returns NULL on failure, or a base 64 encoded user + pass suitable to
* use in Authorization header. */
unsigned char *
find_auth(unsigned char *url)
{
struct http_auth_basic *entry = NULL;
unsigned char *uid, *ret = NULL;
unsigned char *newurl = get_auth_url(url);
unsigned char *user = get_user_name(url);
unsigned char *pass = get_pass(url);
if (!newurl) goto end;
again:
entry = find_auth_entry(newurl, NULL);
/* Check is user/pass info is in url. */
if ((user && *user) || (pass && *pass)) {
/* If we've got an entry, but with different user/pass or no
* entry, then we try to create or modify it and retry. */
if ((entry && !entry->valid && entry->uid && entry->passwd
&& (strcmp(user, entry->uid) || strcmp(pass, entry->passwd)))
|| !entry) {
if (add_auth_entry(url, NULL) == 0) {
/* An entry was re-created, we free user/pass
* before retry to prevent infinite loop. */
if (user) {
mem_free(user);
user = NULL;
}
if (pass) {
mem_free(pass);
pass = NULL;
}
goto again;
}
}
}
/* No entry found. */
if (!entry) goto end;
/* Sanity check. */
if (!entry->passwd || !entry->uid) {
del_auth_entry(entry);
goto end;
}
/* RFC2617 section 2 [Basic Authentication Scheme]
* To receive authorization, the client sends the userid and password,
* separated by a single colon (":") character, within a base64 [7]
* encoded string in the credentials. */
/* Create base64 encoded string. */
uid = straconcat(entry->uid, ":", entry->passwd, NULL);
if (!uid) goto end;
ret = base64_encode(uid);
mem_free(uid);
end:
if (newurl) mem_free(newurl);
if (user) mem_free(user);
if (pass) mem_free(pass);
return ret;
}
/* Delete an entry from auth list. */
void
del_auth_entry(struct http_auth_basic *entry)
{
if (entry->url) mem_free(entry->url);
if (entry->realm) mem_free(entry->realm);
if (entry->uid) mem_free(entry->uid);
if (entry->passwd) mem_free(entry->passwd);
del_from_list(entry);
mem_free(entry);
}
/* Free all entries in auth list and questions in queue. */
void
free_auth()
{
while (!list_empty(http_auth_basic_list))
del_auth_entry(http_auth_basic_list.next);
}
unsigned char base64_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
unsigned char *base64_encode(unsigned char *in)
{
unsigned char *out, *outstr;
int inlen = strlen(in);
outstr = out = mem_alloc(((inlen / 3) + 1) * 4 + 1 );
if (!outstr) return NULL;
while (inlen >= 3) {
*out++ = base64_chars[(int) (*in >> 2) ];
*out++ = base64_chars[(int) ((*in << 4 | *(in + 1) >> 4) & 63) ];
*out++ = base64_chars[(int) ((*(in + 1) << 2 | *(in + 2) >> 6) & 63) ];
*out++ = base64_chars[(int) (*(in + 2) & 63) ];
inlen -= 3; in += 3;
}
if (inlen == 1) {
*out++ = base64_chars[(int) (*in >> 2) ];
*out++ = base64_chars[(int) (*in << 4 & 63) ];
*out++ = '=';
*out++ = '=';
}
if (inlen == 2) {
*out++ = base64_chars[(int) (*in >> 2) ];
*out++ = base64_chars[(int) ((*in << 4 | *(in + 1) >> 4) & 63) ];
*out++ = base64_chars[(int) ((*(in + 1) << 2) & 63) ];
*out++ = '=';
}
*out = 0;
return outstr;
}
/* Parse string param="value", return value as new string or NULL if any
* error. */
unsigned char *get_http_header_param(unsigned char *e, unsigned char *name)
{
unsigned char *n, *start;
int i = 0;
again:
while (*e && upcase(*e++) != upcase(*name));
if (!*e) return NULL;
n = name + 1;
while (*n && upcase(*e) == upcase(*n)) e++, n++;
if (*n) goto again;
while (WHITECHAR(*e)) e++;
if (*e++ != '=') return NULL;
while (WHITECHAR(*e)) e++;
start = e;
if (!U(*e)) while (*e && !WHITECHAR(*e)) e++;
else {
char uu = *e++;
start++;
while (*e != uu) {
if (!*e) return NULL;
e++;
}
}
while (start < e && *start == ' ') start++;
while (start < e && *(e - 1) == ' ') e--;
if (start == e) return NULL;
n = mem_alloc(e - start + 1);
if (!n) return NULL;
while (start < e) {
if (*start < ' ') n[i] = '.';
else n[i] = *start;
i++; start++;
}
n[i] = 0;
return n;
}
/* Auth dialog */
void
auth_layout(struct dialog_data *dlg)
{
struct terminal *term = dlg->win->term;
int max = 0, min = 0;
int w, rw;
int y = -1;
max_text_width(term, TEXT(T_USERID), &max, AL_LEFT);
min_text_width(term, TEXT(T_USERID), &min, AL_LEFT);
max_text_width(term, TEXT(T_PASSWORD), &max, AL_LEFT);
min_text_width(term, TEXT(T_PASSWORD), &min, AL_LEFT);
max_buttons_width(term, dlg->items + 2, 2, &max);
min_buttons_width(term, dlg->items + 2, 2, &min);
w = dlg->win->term->x * 9 / 10 - 2 * DIALOG_LB;
if (w < min) w = min;
if (w > dlg->win->term->x - 2 * DIALOG_LB) w = dlg->win->term->x - 2 * DIALOG_LB;
if (w < 1) w = 1;
rw = 0;
if (dlg->dlg->udata) {
dlg_format_text(dlg, NULL, dlg->dlg->udata, 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
y += gf_val(1, G_BFU_FONT_SIZE);
}
dlg_format_text(dlg, NULL, TEXT(T_USERID), 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
y += gf_val(2, G_BFU_FONT_SIZE*2);
dlg_format_text(dlg, NULL, TEXT(T_PASSWORD), 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
y += gf_val(2, G_BFU_FONT_SIZE*2);
dlg_format_buttons(dlg, NULL, dlg->items + 2, 2, 0, &y, w, &rw, AL_CENTER);
w = rw;
dlg->xw = w + 2 * DIALOG_LB;
dlg->yw = y + 2 * DIALOG_TB;
center_dlg(dlg);
draw_dlg(dlg);
y = dlg->y + DIALOG_TB;
if (dlg->dlg->udata) {
dlg_format_text(dlg, term, dlg->dlg->udata, dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
y += gf_val(1, G_BFU_FONT_SIZE);
}
dlg_format_text(dlg, term, TEXT(T_USERID), dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
dlg_format_field(dlg, term, &dlg->items[0], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
y += gf_val(1, G_BFU_FONT_SIZE);
dlg_format_text(dlg, term, TEXT(T_PASSWORD), dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
dlg_format_field(dlg, term, &dlg->items[1], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
y += gf_val(1, G_BFU_FONT_SIZE);
dlg_format_buttons(dlg, term, &dlg->items[2], 2, dlg->x + DIALOG_LB, &y, w, NULL, AL_CENTER);
}
int
auth_ok(struct dialog_data *dlg, struct dialog_item_data *di)
{
((struct http_auth_basic *)dlg->dlg->udata2)->blocked = 0;
reload(dlg->dlg->refresh_data, -1);
return ok_dialog(dlg, di);
}
int
auth_cancel(struct dialog_data *dlg, struct dialog_item_data *di)
{
((struct http_auth_basic *)dlg->dlg->udata2)->blocked = 0;
del_auth_entry(dlg->dlg->udata2);
return cancel_dialog(dlg, di);
}
/* FIXME: This should be exported properly. --pasky */
extern struct list_head http_auth_basic_list;
void
do_auth_dialog(struct session *ses)
{
/* TODO: complete rewrite */
struct dialog *d;
struct terminal *term = ses->term;
struct http_auth_basic *a = NULL;
if (!list_empty(http_auth_basic_list)
&& !((struct http_auth_basic *) http_auth_basic_list.next)->valid)
a = (struct http_auth_basic *) http_auth_basic_list.next;
if (!a || a->blocked) return;
a->valid = 1;
a->blocked = 1;
if (!a->uid) {
if (!(a->uid = mem_alloc(MAX_UID_LEN))) {
del_auth_entry(a);
return;
}
*a->uid = 0;
}
if (!a->passwd) {
if (!(a->passwd = mem_alloc(MAX_PASSWD_LEN))) {
del_auth_entry(a);
return;
}
*a->passwd = 0;
}
d = mem_alloc(sizeof(struct dialog) + 5 * sizeof(struct dialog_item)
+ strlen(_(TEXT(T_ENTER_USERNAME), term))
+ (a->realm ? strlen(a->realm) : 0)
+ strlen(_(TEXT(T_AT), term)) + strlen(a->url) + 1);
if (!d) return;
memset(d, 0, sizeof(struct dialog) + 5 * sizeof(struct dialog_item));
d->title = TEXT(T_USERID);
d->fn = auth_layout;
d->udata = (char *)d + sizeof(struct dialog) + 5 * sizeof(struct dialog_item);
strcpy(d->udata, _(TEXT(T_ENTER_USERNAME), term));
if (a->realm) strcat(d->udata, a->realm);
strcat(d->udata, _(TEXT(T_AT), term));
strcat(d->udata, a->url);
d->udata2 = a;
d->refresh_data = ses;
d->items[0].type = D_FIELD;
d->items[0].dlen = MAX_UID_LEN;
d->items[0].data = a->uid;
d->items[1].type = D_FIELD_PASS;
d->items[1].dlen = MAX_PASSWD_LEN;
d->items[1].data = a->passwd;
d->items[2].type = D_BUTTON;
d->items[2].gid = B_ENTER;
d->items[2].fn = auth_ok;
d->items[2].text = TEXT(T_OK);
d->items[3].type = D_BUTTON;
d->items[3].gid = B_ESC;
d->items[3].fn = auth_cancel;
d->items[3].text = TEXT(T_CANCEL);
d->items[4].type = D_END;
do_dialog(term, d, getml(d, NULL));
a->blocked = 0;
}
/* Concatenate all strings parameters. Parameters list must _always_ be
* terminated by a NULL pointer. If first parameter is NULL or allocation
* failure, return NULL. On success, returns a pointer to a dynamically
* allocated string.
*
* Example:
* ...
* unsigned char *s = straconcat("A", "B", "C", NULL);
* if (!s) return;
* printf("%s", s); -> print "ABC"
* mem_free(s); -> free memory used by s
*/
unsigned char *
straconcat(unsigned char *str, ...)
{
va_list ap;
unsigned char *a;
unsigned char *s;
unsigned int len;
if (!str) return NULL;
s = stracpy(str);
if (!s) return NULL;
len = strlen(s) + 1;
va_start(ap, str);
while ((a = va_arg(ap, unsigned char *))) {
unsigned char *p;
len += strlen(a);
p = mem_realloc(s, len);
if (!p) {
mem_free(s);
va_end(ap);
return NULL;
}
s = p;
strcat(s, a);
}
va_end(ap);
return s;
}

View File

@ -1,12 +0,0 @@
$OpenBSD: patch-Makefile_in,v 1.4 2003/09/23 06:35:33 fgsch Exp $
--- Makefile.in.orig 2003-09-21 04:57:56.000000000 -0300
+++ Makefile.in 2003-09-23 02:55:51.000000000 -0300
@@ -99,7 +99,7 @@ https.o img.o imgcache.o ipret.o javascr
kbd.o language.o links_icon.o listedit.o lru.o mailto.o main.o md5.o \
md5hl.o menu.o memory.o ns.o objreq.o os_dep.o pmshell.o png.o \
pomocny.o sched.o select.o session.o svgalib.o terminal.o tiff.o \
-types.o url.o view.o view_gr.o win32.o x.o xbm.o
+types.o url.o view.o view_gr.o win32.o x.o xbm.o auth.o
@ATHEOS_GR_TRUE@links_DEPENDENCIES = atheos.o
links_LDFLAGS =
CFLAGS = @CFLAGS@

View File

@ -1,108 +0,0 @@
$OpenBSD: patch-bfu_c,v 1.1 2002/12/11 08:07:17 fgsch Exp $
--- bfu.c.orig Sat Oct 12 15:46:23 2002
+++ bfu.c Sat Nov 30 21:51:38 2002
@@ -786,11 +786,18 @@ void display_dlg_item(struct dialog_data
}
break;
case D_FIELD:
+ case D_FIELD_PASS:
if (di->vpos + di->l <= di->cpos) di->vpos = di->cpos - di->l + 1;
if (di->vpos > di->cpos) di->vpos = di->cpos;
if (di->vpos < 0) di->vpos = 0;
fill_area(term, di->x, di->y, di->l, 1, COLOR_DIALOG_FIELD);
- print_text(term, di->x, di->y, strlen(di->cdata + di->vpos) <= di->l ? strlen(di->cdata + di->vpos) : di->l, di->cdata + di->vpos, COLOR_DIALOG_FIELD_TEXT);
+ if (di->item->type == D_FIELD) {
+ print_text(term, di->x, di->y, strlen(di->cdata + di->vpos) <= di->l ? strlen(di->cdata + di->vpos) : di->l, di->cdata + di->vpos, COLOR_DIALOG_FIELD_TEXT);
+ } else {
+ fill_area(term, di->x, di->y,
+ strlen(di->cdata + di->vpos) <= di->l ? strlen(di->cdata + di->vpos) : di->l, 1,
+ COLOR_DIALOG_FIELD_TEXT | '*');
+ }
if (sel) {
set_cursor(term, di->x + di->cpos - di->vpos, di->y, di->x + di->cpos - di->vpos, di->y);
set_window_ptr(dlg->win, di->x, di->y);
@@ -817,7 +824,7 @@ void display_dlg_item(struct dialog_data
switch (di->item->type) {
int p, pp;
struct style *st;
- unsigned char *text, *text2, *text3;
+ unsigned char *text, *text2, *text3, *text_pass;
struct rect r;
case D_CHECKBOX:
p = di->x;
@@ -845,8 +852,11 @@ void display_dlg_item(struct dialog_data
if (dlg->s) exclude_from_set(&dlg->s, di->x, di->y, p, di->y + G_BFU_FONT_SIZE);
break;
case D_FIELD:
+ case D_FIELD_PASS:
if (!(text = memacpy(di->cdata, di->cpos))) break;
- if (*(text2 = text3 = di->cdata + di->cpos)) {
+ text_pass=mem_alloc(di->cpos+1);
+ for(pp=0;pp<di->cpos;pp++) text_pass[pp]='*';text_pass[pp]='\0';
+ if (*(text2 = text3 = di->cdata + di->cpos)) {
GET_UTF_8(text3, p);
text2 = memacpy(text2, text3 - text2);
} else {
@@ -866,9 +876,16 @@ void display_dlg_item(struct dialog_data
if (dlg->s) exclude_from_set(&dlg->s, di->x, di->y, di->x + di->l, di->y + G_BFU_FONT_SIZE);
restrict_clip_area(dev, &r, di->x, di->y, di->x + di->l, di->y + G_BFU_FONT_SIZE);
p = di->x - di->vpos;
- g_print_text(drv, dev, p, di->y, bfu_style_wb_mono, text, &p);
- g_print_text(drv, dev, p, di->y, sel ? bfu_style_wb_mono_u : bfu_style_wb_mono, text2, &p);
+ if (di->item->type == D_FIELD) {
+ g_print_text(drv, dev, p, di->y, bfu_style_wb_mono, text, &p);
+ } else {
+ g_print_text(drv, dev, p, di->y, bfu_style_wb_mono, text_pass, &p);
+ }
+ mem_free(text_pass);
+ g_print_text(drv, dev, p, di->y, sel ? bfu_style_wb_mono_u : bfu_style_wb_mono, text2, &p);
g_print_text(drv, dev, p, di->y, bfu_style_wb_mono, text3, &p);
+
+
drv->fill_area(dev, p, di->y, di->x + di->l, di->y + G_BFU_FONT_SIZE, bfu_fg_color);
drv->set_clip_area(dev, &r);
mem_free(text);
@@ -963,6 +980,7 @@ int dlg_mouse(struct dialog_data *dlg, s
if ((ev->b & BM_ACT) == B_UP) dlg_select_item(dlg, di);
return 1;
case D_FIELD:
+ case D_FIELD_PASS:
if (gf_val(ev->y != di->y, ev->y < di->y || ev->y >= di->y + G_BFU_FONT_SIZE) || ev->x < di->x || ev->x >= di->x + di->l) return 0;
if (!F) {
if ((di->cpos = di->vpos + ev->x - di->x) > strlen(di->cdata)) di->cpos = strlen(di->cdata);
@@ -1103,7 +1121,7 @@ void dialog_func(struct window *win, str
}
init_list(di->history);
di->cur_hist = (struct history_item *)&di->history;
- if (di->item->type == D_FIELD) {
+ if (di->item->type == D_FIELD || di->item->type == D_FIELD_PASS) {
if (di->item->history) {
struct history_item *j;
/*int l = di->item->dlen;*/
@@ -1130,7 +1148,7 @@ void dialog_func(struct window *win, str
break;
case EV_KBD:
di = &dlg->items[dlg->selected];
- if (di->item->type == D_FIELD) {
+ if (di->item->type == D_FIELD || di->item->type == D_FIELD_PASS) {
if (ev->x == KBD_UP && (void *)di->cur_hist->prev != &di->history) {
di->cur_hist = di->cur_hist->prev;
dlg_set_history(di);
@@ -1353,7 +1371,7 @@ int check_dialog(struct dialog_data *dlg
{
int i;
for (i = 0; i < dlg->n; i++)
- if (dlg->dlg->items[i].type == D_CHECKBOX || dlg->dlg->items[i].type == D_FIELD)
+ if (dlg->dlg->items[i].type == D_CHECKBOX || dlg->dlg->items[i].type == D_FIELD || dlg->dlg->items[i].type == D_FIELD_PASS)
if (dlg->dlg->items[i].fn && dlg->dlg->items[i].fn(dlg, &dlg->items[i])) {
dlg->selected = i;
draw_to_window(dlg->win, (void (*)(struct terminal *, void *))redraw_dialog_items, dlg);
@@ -1738,7 +1756,7 @@ void dlg_format_group(struct dialog_data
#endif
item->x = x + nx + sl * (item->item->type != D_CHECKBOX);
item->y = *y;
- if (item->item->type == D_FIELD) item->l = gf_val(item->item->dlen, item->item->dlen * G_DIALOG_FIELD_WIDTH);
+ if (item->item->type == D_FIELD || item->item->type == D_FIELD_PASS) item->l = gf_val(item->item->dlen, item->item->dlen * G_DIALOG_FIELD_WIDTH);
}
if (rw && nx + wx > *rw) if ((*rw = nx + wx) > w) *rw = w;
nx += wx + gf_val(1, G_DIALOG_GROUP_SPACE);

View File

@ -1,19 +0,0 @@
$OpenBSD: patch-default_c,v 1.3 2003/09/23 06:35:33 fgsch Exp $
--- default.c.orig 2003-09-01 17:22:54.000000000 -0300
+++ default.c 2003-09-23 02:55:15.000000000 -0300
@@ -1067,6 +1067,7 @@ int aspect_on=1;
unsigned char download_dir[MAX_STR_LEN] = "";
unsigned char default_anon_pass[MAX_STR_LEN] = "somebody@host.domain";
+int ftp_passive=0; /* 1=use passive mode */
/* These are workarounds for some CGI script bugs */
struct http_bugs http_bugs = { 0, 1, 1, 0, 0, 1 };
@@ -1147,6 +1148,7 @@ struct option links_options[] = {
{1, gen_cmd, cp_rd, cp_wr, 0, 0, &bookmarks_codepage, "bookmarks_codepage", "bookmarks-codepage"},
{1, gen_cmd, str_rd, str_wr, 0, MAX_STR_LEN, bookmarks_file, "bookmarks_file", "bookmarks-file"},
{1, gen_cmd, str_rd, str_wr, 0, MAX_STR_LEN, default_anon_pass, "ftp.anonymous_password", "ftp.anonymous-password"},
+ {1, gen_cmd, num_rd, num_wr, 0, 1, &ftp_passive, "ftp.passive", "ftp.passive"},
{1, gen_cmd, cp_rd, NULL, 0, 0, &dds.assume_cp, "assume_codepage", "assume-codepage"},
{1, NULL, term_rd, term_wr, 0, 0, NULL, "terminal", NULL},
{1, NULL, term2_rd, NULL, 0, 0, NULL, "terminal2", NULL},

View File

@ -1,273 +0,0 @@
$OpenBSD: patch-ftp_c,v 1.2 2003/09/23 06:35:33 fgsch Exp $
--- ftp.c.orig 2003-09-01 16:40:44.000000000 -0300
+++ ftp.c 2003-09-23 02:58:09.000000000 -0300
@@ -19,6 +19,7 @@ struct ftp_connection_info {
int d;
int dpos;
int buf_pos;
+ int use_pasv; /* Use PASV (yes or no) */
unsigned char ftp_buffer[FTP_BUF];
unsigned char cmdbuf[1];
};
@@ -39,7 +40,58 @@ void ftp_got_final_response(struct conne
void got_something_from_data_connection(struct connection *);
void ftp_end_request(struct connection *);
-int get_ftp_response(struct connection *c, struct read_buffer *rb, int part)
+/* Parse EPSV or PASV response for address and/or port.
+ * int *n should point to a sizeof(int) * 6 space.
+ * It returns zero on error or count of parsed numbers.
+ * It returns an error if:
+ * - there's more than 6 or less than 1 numbers.
+ * - a number is strictly greater than max.
+ *
+ * On success, array of integers *n is filled with numbers starting
+ * from end of array (ie. if we found one number, you can access it using
+ * n[5]).
+ *
+ * Important:
+ * Negative numbers aren't handled so -123 is taken as 123.
+ * We don't take care about separators.
+*/
+static int parse_psv_resp(unsigned char *data, int *n, int max_value)
+{
+ unsigned char *p = data;
+ int i = 5;
+
+ memset(n, 0, 6 * sizeof(int));
+
+ if (*p < ' ') return 0;
+
+ /* Find the end. */
+ while (*p >= ' ') p++;
+
+ /* Ignore non-numeric ending chars. */
+ while (p != data && (*p < '0' || *p > '9')) p--;
+ if (p == data) return 0;
+
+ while (i >= 0) {
+ int x = 1;
+
+ /* Parse one number. */
+ while (p != data && *p >= '0' && *p <= '9') {
+ n[i] += (*p - '0') * x;
+ if (n[i] > max_value) return 0;
+ x *= 10;
+ p--;
+ }
+ /* Ignore non-numeric chars. */
+ while (p != data && (*p < '0' || *p > '9')) p--;
+ if (p == data) return (6 - i);
+ /* Get the next one. */
+ i--;
+ }
+
+ return 0;
+}
+
+int get_ftp_response(struct connection *c, struct read_buffer *rb, int part, struct sockaddr_in *sa)
{
int l;
set_timeout(c);
@@ -48,6 +100,17 @@ int get_ftp_response(struct connection *
unsigned char *e;
int k = strtoul(rb->data, (char **)&e, 10);
if (e != rb->data + 3 || k < 100) return -1;
+ if (sa && k == 227) { /* PASV response parsing. */
+ struct sockaddr_in *s = (struct sockaddr_in *) sa;
+ int n[6];
+
+ if (parse_psv_resp(e, (int *) n, 255) != 6)
+ return -1;
+ memset(s, 0, sizeof(struct sockaddr_in));
+ s->sin_family = AF_INET;
+ s->sin_addr.s_addr = htonl((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + n[3]);
+ s->sin_port = htons((n[4] << 8) + n[5]);
+ }
if (*e == '-') {
int i;
for (i = 0; i < rb->len - 5; i++) {
@@ -127,7 +190,7 @@ void ftp_logged(struct connection *c)
void ftp_got_info(struct connection *c, struct read_buffer *rb)
{
- int g = get_ftp_response(c, rb, 0);
+ int g = get_ftp_response(c, rb, 0, NULL);
if (g == -1) { setcstate(c, S_FTP_ERROR); abort_connection(c); return; }
if (!g) { read_from_socket(c, c->sock1, rb, ftp_got_info); return; }
if (g >= 400) { setcstate(c, S_FTP_UNAVAIL); retry_connection(c); return; }
@@ -136,7 +199,7 @@ void ftp_got_info(struct connection *c,
void ftp_got_user_info(struct connection *c, struct read_buffer *rb)
{
- int g = get_ftp_response(c, rb, 0);
+ int g = get_ftp_response(c, rb, 0, NULL);
if (g == -1) { setcstate(c, S_FTP_ERROR); abort_connection(c); return; }
if (!g) { read_from_socket(c, c->sock1, rb, ftp_got_user_info); return; }
if (g >= 530 && g < 540) { setcstate(c, S_FTP_LOGIN); retry_connection(c); return; }
@@ -169,7 +232,7 @@ void ftp_got_user_info(struct connection
void ftp_dummy_info(struct connection *c, struct read_buffer *rb)
{
- int g = get_ftp_response(c, rb, 0);
+ int g = get_ftp_response(c, rb, 0, NULL);
if (g == -1) { setcstate(c, S_FTP_ERROR); abort_connection(c); return; }
if (!g) { read_from_socket(c, c->sock1, rb, ftp_dummy_info); return; }
ftp_retr_file(c, rb);
@@ -184,7 +247,7 @@ void ftp_sent_passwd(struct connection *
void ftp_pass_info(struct connection *c, struct read_buffer *rb)
{
- int g = get_ftp_response(c, rb, 0);
+ int g = get_ftp_response(c, rb, 0, NULL);
if (g == -1) { setcstate(c, S_FTP_ERROR); abort_connection(c); return; }
if (!g) { read_from_socket(c, c->sock1, rb, ftp_pass_info); setcstate(c, S_LOGIN); return; }
if (g >= 530 && g < 540) { setcstate(c, S_FTP_LOGIN); abort_connection(c); return; }
@@ -215,7 +278,11 @@ struct ftp_connection_info *add_file_cmd
goto oom;
}
c->info = inf;
- if ((ps = get_pasv_socket(c, c->sock1, &c->sock2, pc))) return NULL;
+ inf->use_pasv = ftp_passive;
+ if (!inf->use_pasv) {
+ if ((ps = get_pasv_socket(c, c->sock1, &c->sock2, pc)))
+ return NULL;
+ }
if (!d) {
internal("get_url_data failed");
setcstate(c, S_INTERNAL);
@@ -226,18 +293,23 @@ struct ftp_connection_info *add_file_cmd
if (d == de || de[-1] == '/') {
inf->dir = 1;
inf->pending_commands = 4;
- add_to_str(&s, &l, "TYPE A\r\nPORT ");
- add_num_to_str(&s, &l, pc[0]);
- add_chr_to_str(&s, &l, ',');
- add_num_to_str(&s, &l, pc[1]);
- add_chr_to_str(&s, &l, ',');
- add_num_to_str(&s, &l, pc[2]);
- add_chr_to_str(&s, &l, ',');
- add_num_to_str(&s, &l, pc[3]);
- add_chr_to_str(&s, &l, ',');
- add_num_to_str(&s, &l, pc[4]);
- add_chr_to_str(&s, &l, ',');
- add_num_to_str(&s, &l, pc[5]);
+ add_to_str(&s, &l, "TYPE A\r\n");
+ if (inf->use_pasv)
+ add_to_str(&s, &l, "PASV");
+ else {
+ add_to_str(&s, &l, "PORT ");
+ add_num_to_str(&s, &l, pc[0]);
+ add_chr_to_str(&s, &l, ',');
+ add_num_to_str(&s, &l, pc[1]);
+ add_chr_to_str(&s, &l, ',');
+ add_num_to_str(&s, &l, pc[2]);
+ add_chr_to_str(&s, &l, ',');
+ add_num_to_str(&s, &l, pc[3]);
+ add_chr_to_str(&s, &l, ',');
+ add_num_to_str(&s, &l, pc[4]);
+ add_chr_to_str(&s, &l, ',');
+ add_num_to_str(&s, &l, pc[5]);
+ }
add_to_str(&s, &l, "\r\nCWD /");
add_bytes_to_str(&s, &l, d, de - d);
add_to_str(&s, &l, "\r\nLIST\r\n");
@@ -245,18 +317,23 @@ struct ftp_connection_info *add_file_cmd
} else {
inf->dir = 0;
inf->pending_commands = 3;
- add_to_str(&s, &l, "TYPE I\r\nPORT ");
- add_num_to_str(&s, &l, pc[0]);
- add_chr_to_str(&s, &l, ',');
- add_num_to_str(&s, &l, pc[1]);
- add_chr_to_str(&s, &l, ',');
- add_num_to_str(&s, &l, pc[2]);
- add_chr_to_str(&s, &l, ',');
- add_num_to_str(&s, &l, pc[3]);
- add_chr_to_str(&s, &l, ',');
- add_num_to_str(&s, &l, pc[4]);
- add_chr_to_str(&s, &l, ',');
- add_num_to_str(&s, &l, pc[5]);
+ add_to_str(&s, &l, "TYPE I\r\n");
+ if (inf->use_pasv)
+ add_to_str(&s, &l, "PASV");
+ else {
+ add_to_str(&s, &l, "PORT ");
+ add_num_to_str(&s, &l, pc[0]);
+ add_chr_to_str(&s, &l, ',');
+ add_num_to_str(&s, &l, pc[1]);
+ add_chr_to_str(&s, &l, ',');
+ add_num_to_str(&s, &l, pc[2]);
+ add_chr_to_str(&s, &l, ',');
+ add_num_to_str(&s, &l, pc[3]);
+ add_chr_to_str(&s, &l, ',');
+ add_num_to_str(&s, &l, pc[4]);
+ add_chr_to_str(&s, &l, ',');
+ add_num_to_str(&s, &l, pc[5]);
+ }
if (c->from && c->no_cache < NC_IF_MOD) {
add_to_str(&s, &l, "\r\nREST ");
add_num_to_str(&s, &l, c->from);
@@ -314,6 +391,8 @@ void ftp_retr_file(struct connection *c,
{
int g;
struct ftp_connection_info *inf = c->info;
+ int fd;
+ struct sockaddr_in sa;
if (0) {
rep:
if (!fast_ftp) {
@@ -322,9 +401,19 @@ void ftp_retr_file(struct connection *c,
}
}
if (inf->pending_commands > 1) {
- g = get_ftp_response(c, rb, 0);
+ g = get_ftp_response(c, rb, 0, &sa);
if (g == -1) { setcstate(c, S_FTP_ERROR); abort_connection(c); return; }
if (!g) { read_from_socket(c, c->sock1, rb, ftp_retr_file); setcstate(c, S_GETH); return; }
+ if (g == 227) {
+ fd = socket(PF_INET, SOCK_STREAM, 0);
+ if (fd < 0) {
+ setcstate(c, S_FTP_ERROR);
+ abort_connection(c);
+ return;
+ }
+ c->sock2 = fd;
+ connect(fd, (struct sockaddr *) &sa, sizeof(struct sockaddr_in));
+ }
inf->pending_commands--;
switch (inf->opc - inf->pending_commands) {
case 1: /* TYPE */
@@ -341,7 +430,7 @@ void ftp_retr_file(struct connection *c,
}
internal("WHAT???");
}
- g = get_ftp_response(c, rb, 2);
+ g = get_ftp_response(c, rb, 2, NULL);
if (!g) { read_from_socket(c, c->sock1, rb, ftp_retr_file); setcstate(c, S_GETH); return; }
if (g >= 100 && g < 200) {
int est;
@@ -369,7 +458,7 @@ void ftp_retr_file(struct connection *c,
void ftp_got_final_response(struct connection *c, struct read_buffer *rb)
{
struct ftp_connection_info *inf = c->info;
- int g = get_ftp_response(c, rb, 0);
+ int g = get_ftp_response(c, rb, 0, NULL);
if (g == -1) { setcstate(c, S_FTP_ERROR); abort_connection(c); return; }
if (!g) { read_from_socket(c, c->sock1, rb, ftp_got_final_response); if (c->state != S_TRANS) setcstate(c, S_GETH); return; }
if (g == 550) {
@@ -477,8 +566,12 @@ void got_something_from_data_connection(
int ns;
inf->d = 1;
set_handlers(c->sock2, NULL, NULL, NULL, NULL);
- if ((ns = accept(c->sock2, NULL, NULL)) == -1) goto e;
- close(c->sock2);
+ if (inf->use_pasv)
+ ns = c->sock2;
+ else {
+ if ((ns = accept(c->sock2, NULL, NULL)) == -1) goto e;
+ close(c->sock2);
+ }
c->sock2 = ns;
set_handlers(ns, (void (*)(void *))got_something_from_data_connection, NULL, NULL, c);
return;

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-html_c,v 1.5 2003/09/23 06:35:33 fgsch Exp $
--- html.c.orig 2003-08-29 14:05:17.000000000 -0300
+++ html.c 2003-09-23 02:55:15.000000000 -0300
$OpenBSD: patch-html_c,v 1.6 2003/11/17 22:59:32 fgsch Exp $
--- html.c.orig 2003-10-27 18:55:44.000000000 -0300
+++ html.c 2003-11-17 19:09:10.000000000 -0300
@@ -799,6 +799,7 @@ void html_a(unsigned char *a)
format.target = stracpy(format.target_base);
}
@ -9,7 +9,7 @@ $OpenBSD: patch-html_c,v 1.5 2003/09/23 06:35:33 fgsch Exp $
memcpy(&format.fg, &format.clink, sizeof(struct rgb));
} else if (!ev) kill_html_stack_item(&html_top);
if ((al = get_attr_val(a, "name"))) {
@@ -1670,7 +1671,7 @@ void new_menu_item(unsigned char *name,
@@ -1679,7 +1680,7 @@ void new_menu_item(unsigned char *name,
item->rtext = data == -1 ? ">" : "";
item->hotkey = fullname ? "\000\001" : "\000\000"; /* dirty */
item->func = data == -1 ? MENU_FUNC do_select_submenu : MENU_FUNC selected_item;
@ -18,7 +18,7 @@ $OpenBSD: patch-html_c,v 1.5 2003/09/23 06:35:33 fgsch Exp $
item->in_m = data == -1 ? 1 : 0;
item->free_i = 0;
item++;
@@ -1730,14 +1731,14 @@ void menu_labels(struct menu_item *m, un
@@ -1739,14 +1740,14 @@ void menu_labels(struct menu_item *m, un
}
} else {
if ((bs = stracpy(m->hotkey[1] ? (unsigned char *)"" : base))) add_to_strn(&bs, m->text);

View File

@ -1,48 +0,0 @@
$OpenBSD: patch-http_c,v 1.3 2003/09/23 06:35:33 fgsch Exp $
--- http.c.orig 2003-09-01 16:40:44.000000000 -0300
+++ http.c 2003-09-23 02:55:15.000000000 -0300
@@ -157,6 +157,7 @@ void http_send_header(struct connection
int l = 0;
unsigned char *post;
unsigned char *host;
+ unsigned char *host_data;
find_in_cache(c->url, &c->cache);
@@ -316,6 +317,13 @@ void http_send_header(struct connection
add_num_to_str(&hdr, &l, c->from);
add_to_str(&hdr, &l, "-\r\n");
}
+ host_data = find_auth(host);
+ if (host_data) {
+ add_to_str(&hdr, &l, "Authorization: Basic ");
+ add_to_str(&hdr, &l, host_data);
+ add_to_str(&hdr, &l, "\r\n");
+ mem_free(host_data);
+ }
if (post) {
unsigned char *pd = strchr(post, '\n');
if (pd) {
@@ -592,6 +600,22 @@ void http_got_header(struct connection *
e->redirect_get = h == 303;
}
}
+ if (h == 401) {
+ d = parse_http_header(e->head, "WWW-Authenticate", NULL);
+ if (d) {
+ if (!strncasecmp(d, "Basic", 5)) {
+ unsigned char *realm = get_http_header_param(d, "realm");
+
+ if (realm) {
+ if (add_auth_entry(host, realm) > 0) {
+ need_auth=1;
+ }
+ mem_free(realm);
+ }
+ }
+ mem_free(d);
+ }
+ }
kill_buffer_data(rb, a);
c->cache = e;
info->close = 0;

View File

@ -1,11 +0,0 @@
$OpenBSD: patch-intl_english_lng,v 1.5 2003/09/23 06:35:33 fgsch Exp $
--- intl/english.lng.orig 2003-09-01 17:23:00.000000000 -0300
+++ intl/english.lng 2003-09-23 02:55:15.000000000 -0300
@@ -404,6 +404,7 @@ T_ASPECT_CORRECTION_ON, "Aspect correcti
T_KEYBOARD_CODEPAGE, "Keyboard codepage",
T_COPY_LINK_LOCATION, "Copy link location",
T_COPY_URL_LOCATION, "Copy current URL location",
+T_USE_PASSIVE, "Use passive mode",
T_HK_ADD_BOOKMARK, "A",
T_HK_BOOKMARKS, "S",
T_HK_SAVE_BOOKMARKS, "A",

View File

@ -1,11 +0,0 @@
$OpenBSD: patch-intl_spanish_lng,v 1.5 2003/09/23 06:35:33 fgsch Exp $
--- intl/spanish.lng.orig 2003-09-01 17:23:05.000000000 -0300
+++ intl/spanish.lng 2003-09-23 02:55:15.000000000 -0300
@@ -404,6 +404,7 @@ T_ASPECT_CORRECTION_ON, NULL,
T_KEYBOARD_CODEPAGE, NULL,
T_COPY_LINK_LOCATION, NULL,
T_COPY_URL_LOCATION, NULL,
+T_USE_PASSIVE, "Usar modo pasivo",
T_HK_ADD_BOOKMARK, "A",
T_HK_BOOKMARKS, "C",
T_HK_SAVE_BOOKMARKS, NULL,

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-jsint_c,v 1.4 2003/09/23 06:35:33 fgsch Exp $
--- jsint.c.orig 2003-09-01 16:40:44.000000000 -0300
+++ jsint.c 2003-09-23 02:55:15.000000000 -0300
$OpenBSD: patch-jsint_c,v 1.5 2003/11/17 22:59:32 fgsch Exp $
--- jsint.c.orig 2003-11-10 15:03:29.000000000 -0300
+++ jsint.c 2003-11-17 19:13:56.000000000 -0300
@@ -2810,7 +2810,7 @@ static void __js_upcall_goto_history_ok_
if (a<jsid->n&&(fd->js)&&jsid->js_id==fd->js->ctx->js_id){js_downcall_vezmi_null(fd->js->ctx);return;} /* call downcall */
@ -10,3 +10,12 @@ $OpenBSD: patch-jsint_c,v 1.4 2003/09/23 06:35:33 fgsch Exp $
}
@@ -2918,7 +2918,7 @@ void js_upcall_goto_history(void * data)
{
js_mem_free(s);
mem_free(url);
- go_backwards(term,(void*)(history_num),fd->ses);
+ go_backwards(term,(void*)(intptr_t)(history_num),fd->ses);
}
return;
goto_history_failed:

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-kbd_c,v 1.1 2002/09/16 04:11:23 fgsch Exp $
--- kbd.c.orig Sun Sep 15 09:46:19 2002
+++ kbd.c Sun Sep 15 09:46:37 2002
@@ -384,10 +384,10 @@ void in_sock(struct itrm *itrm)
$OpenBSD: patch-kbd_c,v 1.2 2003/11/17 22:59:32 fgsch Exp $
--- kbd.c.orig 2003-10-10 02:52:57.000000000 -0300
+++ kbd.c 2003-11-17 19:09:11.000000000 -0300
@@ -386,10 +386,10 @@ void in_sock(struct itrm *itrm)
}
mem_free(param);
if (fg == 1) {

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-links_h,v 1.8 2003/09/23 06:35:33 fgsch Exp $
$OpenBSD: patch-links_h,v 1.9 2003/11/17 22:59:32 fgsch Exp $
--- links.h.orig 2003-09-18 08:46:34.000000000 -0300
+++ links.h 2003-09-23 02:55:15.000000000 -0300
@@ -137,6 +137,8 @@ x #endif*/
@ -10,59 +10,3 @@ $OpenBSD: patch-links_h,v 1.8 2003/09/23 06:35:33 fgsch Exp $
#include <termios.h>
#include "os_depx.h"
@@ -1028,6 +1030,7 @@ static inline int end_of_dir(unsigned ch
int parse_url(unsigned char *, int *, unsigned char **, int *, unsigned char **, int *, unsigned char **, int *, unsigned char **, int *, unsigned char **, int *, unsigned char **);
unsigned char *get_host_name(unsigned char *);
+unsigned char *get_protocol_name(unsigned char *);
unsigned char *get_host_and_pass(unsigned char *);
unsigned char *get_user_name(unsigned char *);
unsigned char *get_pass(unsigned char *);
@@ -3008,7 +3011,8 @@ struct history {
#define D_END 0
#define D_CHECKBOX 1
#define D_FIELD 2
-#define D_BUTTON 3
+#define D_FIELD_PASS 3
+#define D_BUTTON 4
#define B_ENTER 1
#define B_ESC 2
@@ -3872,6 +3876,7 @@ struct http_bugs {
extern struct http_bugs http_bugs;
extern unsigned char default_anon_pass[];
+extern int ftp_passive;
/* listedit.c */
@@ -3943,4 +3948,29 @@ void save_bookmarks(void);
/* Launches bookmark manager */
void menu_bookmark_manager(struct terminal *, void *, struct session *);
+/* auth.h */
+
+struct http_auth_basic {
+ struct http_auth_basic *next;
+ struct http_auth_basic *prev;
+ int blocked;
+ int valid;
+ unsigned char *url;
+ int url_len;
+ unsigned char *realm;
+ unsigned char *uid;
+ unsigned char *passwd;
+};
+
+void init_auth();
+unsigned char *find_auth(unsigned char *);
+int add_auth_entry(unsigned char *, unsigned char *);
+void del_auth_entry(struct http_auth_basic *);
+void free_auth();
+unsigned char *base64_encode(unsigned char *);
+unsigned char *get_http_header_param(unsigned char *e, unsigned char * name);
+void do_auth_dialog(struct session *ses);
+
+int need_auth;
+
#endif /* #ifndef _LINKS_H */

View File

@ -1,19 +0,0 @@
$OpenBSD: patch-main_c,v 1.1 2002/12/11 08:07:17 fgsch Exp $
--- main.c.orig Sat Oct 12 15:48:21 2002
+++ main.c Sat Nov 30 21:51:38 2002
@@ -351,6 +351,7 @@ void initialize_all_subsystems(void)
init_dns();
init_cache();
iinit_bfu();
+ init_auth();
}
/* Is called sometimes after and sometimes before graphics driver init */
@@ -385,6 +386,7 @@ void terminate_all_subsystems(void)
free_history_lists();
free_term_specs();
free_types();
+ free_auth();
if (init_b) finalize_bookmarks();
free_conv_table();
free_blacklist();

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-menu_c,v 1.5 2003/09/23 06:35:33 fgsch Exp $
--- menu.c.orig 2003-09-01 17:22:57.000000000 -0300
+++ menu.c 2003-09-23 02:55:15.000000000 -0300
$OpenBSD: patch-menu_c,v 1.6 2003/11/17 22:59:32 fgsch Exp $
--- menu.c.orig 2003-11-10 15:03:30.000000000 -0300
+++ menu.c 2003-11-17 19:09:12.000000000 -0300
@@ -329,7 +329,7 @@ void flush_caches(struct terminal *term,
/* jde v historii o psteps polozek dozadu */
void go_backwards(struct terminal *term, void *psteps, struct session *ses)
@ -64,91 +64,7 @@ $OpenBSD: patch-menu_c,v 1.5 2003/09/23 06:35:33 fgsch Exp $
}
sel = *ptr;
if (sel < 0) sel = 0;
@@ -751,26 +751,68 @@ int dlg_http_options(struct dialog_data
return 0;
}
+unsigned char *ftp_labels[] = { TEXT(T_USE_PASSIVE), TEXT(T_PASSWORD_FOR_ANONYMOUS_LOGIN) };
+
+void ftpopt_fn(struct dialog_data *dlg)
+{
+ struct terminal *term = dlg->win->term;
+ int max = 0, min = 0;
+ int w, rw;
+ int y = 0;
+ checkboxes_width(term, dlg->dlg->udata, &max, max_text_width);
+ checkboxes_width(term, dlg->dlg->udata, &min, min_text_width);
+ max_text_width(term, ftp_labels[1], &max, AL_LEFT);
+ min_text_width(term, ftp_labels[1], &min, AL_LEFT);
+ max_buttons_width(term, dlg->items + dlg->n - 2, 2, &max);
+ min_buttons_width(term, dlg->items + dlg->n - 2, 2, &min);
+ w = term->x * 9 / 10 - 2 * DIALOG_LB;
+ if (w > max) w = max;
+ if (w < min) w = min;
+ if (w > term->x - 2 * DIALOG_LB) w = term->x - 2 * DIALOG_LB;
+ if (w < 5) w = 5;
+ rw = 0;
+ dlg_format_checkboxes(dlg, NULL, dlg->items, dlg->n - 3, 0, &y, w, &rw, dlg->dlg->udata);
+ y += gf_val(1, G_BFU_FONT_SIZE);
+ dlg_format_text(dlg, NULL, ftp_labels[1], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
+ y += gf_val(1, 2 * G_BFU_FONT_SIZE);
+ dlg_format_buttons(dlg, NULL, dlg->items + dlg->n - 2, 2, 0, &y, w, &rw, AL_CENTER);
+ w = rw;
+ dlg->xw = rw + 2 * DIALOG_LB;
+ dlg->yw = y + 2 * DIALOG_TB;
+ center_dlg(dlg);
+ draw_dlg(dlg);
+ y = dlg->y + DIALOG_TB + gf_val(1, G_BFU_FONT_SIZE);
+ dlg_format_checkboxes(dlg, term, dlg->items, dlg->n - 3, dlg->x + DIALOG_LB, &y, w, NULL, dlg->dlg->udata);
+ y += gf_val(1, G_BFU_FONT_SIZE);
+ dlg_format_text(dlg, term, ftp_labels[1], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
+ dlg_format_field(dlg, term, dlg->items + 1, dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
+ y += gf_val(1, G_BFU_FONT_SIZE);
+ dlg_format_buttons(dlg, term, dlg->items + dlg->n - 2, 2, dlg->x + DIALOG_LB, &y, w, &rw, AL_CENTER);
+}
+
int dlg_ftp_options(struct dialog_data *dlg, struct dialog_item_data *di)
{
struct dialog *d;
- if (!(d = mem_alloc(sizeof(struct dialog) + 4 * sizeof(struct dialog_item)))) return 0;
- memset(d, 0, sizeof(struct dialog) + 4 * sizeof(struct dialog_item));
+ if (!(d = mem_alloc(sizeof(struct dialog) + 5 * sizeof(struct dialog_item)))) return 0;
+ memset(d, 0, sizeof(struct dialog) + 5 * sizeof(struct dialog_item));
d->title = TEXT(T_FTP_OPTIONS);
- d->fn = input_field_fn;
- d->udata = TEXT(T_PASSWORD_FOR_ANONYMOUS_LOGIN);
- d->items[0].type = D_FIELD;
- d->items[0].dlen = MAX_STR_LEN;
- d->items[0].data = di->cdata;
- d->items[1].type = D_BUTTON;
- d->items[1].gid = B_ENTER;
- d->items[1].fn = ok_dialog;
- d->items[1].text = TEXT(T_OK);
+ d->fn = ftpopt_fn;
+ d->udata = ftp_labels;
+ d->items[0].type = D_CHECKBOX;
+ d->items[0].dlen = sizeof(int);
+ d->items[0].data = (void *)&ftp_passive;
+ d->items[1].type = D_FIELD;
+ d->items[1].dlen = MAX_STR_LEN;
+ d->items[1].data = di->cdata;
d->items[2].type = D_BUTTON;
- d->items[2].gid = B_ESC;
- d->items[2].fn = cancel_dialog;
- d->items[2].text = TEXT(T_CANCEL);
- d->items[3].type = D_END;
+ d->items[2].gid = B_ENTER;
+ d->items[2].fn = ok_dialog;
+ d->items[2].text = TEXT(T_OK);
+ d->items[3].type = D_BUTTON;
+ d->items[3].gid = B_ESC;
+ d->items[3].fn = cancel_dialog;
+ d->items[3].text = TEXT(T_CANCEL);
+ d->items[4].type = D_END;
do_dialog(dlg->win->term, d, getml(d, NULL));
return 0;
}
@@ -1845,7 +1887,7 @@ void miscelaneous_options(struct termina
@@ -1885,7 +1885,7 @@ void miscelaneous_options(struct termina
void menu_set_language(struct terminal *term, void *pcp, struct session *ses)
{
@ -157,7 +73,7 @@ $OpenBSD: patch-menu_c,v 1.5 2003/09/23 06:35:33 fgsch Exp $
cls_redraw_all_terminals();
}
@@ -1857,7 +1899,7 @@ void menu_language_list(struct terminal
@@ -1897,7 +1897,7 @@ void menu_language_list(struct terminal
if (!(mi = new_menu(1))) return;
for (i = 0; i < n_languages(); i++) {
n = language_name(i);

View File

@ -0,0 +1,30 @@
$OpenBSD: patch-objreq_c,v 1.1 2003/11/17 22:59:32 fgsch Exp $
--- objreq.c.orig 2003-10-09 05:23:48.000000000 -0300
+++ objreq.c 2003-11-17 19:15:44.000000000 -0300
@@ -79,7 +79,7 @@ void auth_fn(struct dialog_data *dlg)
int auth_cancel(struct dialog_data *dlg, struct dialog_item_data *item)
{
- struct object_request *rq = find_rq((int)dlg->dlg->udata2);
+ struct object_request *rq = find_rq((intptr_t)dlg->dlg->udata2);
if (rq) {
rq->state = O_OK;
if (rq->timer != -1) kill_timer(rq->timer);
@@ -92,7 +92,7 @@ int auth_cancel(struct dialog_data *dlg,
int auth_ok(struct dialog_data *dlg, struct dialog_item_data *item)
{
- struct object_request *rq = find_rq((int)dlg->dlg->udata2);
+ struct object_request *rq = find_rq((intptr_t)dlg->dlg->udata2);
if (rq) {
struct auth_dialog *a = dlg->dlg->udata;
struct session *ses;
@@ -157,7 +157,7 @@ int auth_window(struct object_request *r
a->proxy = rq->stat.ce->http_code == 407;
a->realm = stracpy(realm);
d->udata = a;
- d->udata2 = (void *)rq->count;
+ d->udata2 = (void *)(intptr_t)rq->count;
if (rq->stat.ce->http_code == 401) d->title = TEXT(T_AUTHORIZATION_REQUIRED);
else d->title = TEXT(T_PROXY_AUTHORIZATION_REQUIRED);
d->fn = auth_fn;

View File

@ -1,14 +0,0 @@
$OpenBSD: patch-session_c,v 1.1 2002/12/11 08:07:17 fgsch Exp $
--- session.c.orig Sat Nov 2 12:22:42 2002
+++ session.c Sat Nov 30 21:51:38 2002
@@ -156,6 +156,10 @@ void print_screen_status(struct session
set_terminal_title(ses->term, m);
/*mem_free(m); -- set_terminal_title frees it */
}
+ if (need_auth==1) {
+ need_auth=0;
+ do_auth_dialog(ses);
+ }
}
void print_error_dialog(struct session *ses, struct status *stat, unsigned char *title)

View File

@ -1,9 +0,0 @@
$OpenBSD: patch-setup_h,v 1.1 2002/12/11 08:07:17 fgsch Exp $
--- setup.h.orig Sat Jun 29 15:27:04 2002
+++ setup.h Sat Nov 30 21:51:38 2002
@@ -187,3 +187,5 @@
#define MOUSE_SCROLL_DIVIDER 1
#define MAGICKA_KONSTANTA_NA_MAXIMALNI_DYLKU_JS_KODU_PRI_ERRORU 256
+#define MAX_UID_LEN 20
+#define MAX_PASSWD_LEN 20

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-terminal_c,v 1.1 2002/09/16 04:11:23 fgsch Exp $
--- terminal.c.orig Sun Sep 15 09:39:28 2002
+++ terminal.c Sun Sep 15 09:42:14 2002
@@ -1053,14 +1053,14 @@ void exec_thread(unsigned char *path, in
$OpenBSD: patch-terminal_c,v 1.2 2003/11/17 22:59:32 fgsch Exp $
--- terminal.c.orig 2003-10-10 02:52:57.000000000 -0300
+++ terminal.c 2003-11-17 19:09:12.000000000 -0300
@@ -1056,14 +1056,14 @@ void exec_thread(unsigned char *path, in
void close_handle(void *p)
{
@ -18,7 +18,7 @@ $OpenBSD: patch-terminal_c,v 1.1 2002/09/16 04:11:23 fgsch Exp $
term->blocked = -1;
if (!F) {
set_handlers(term->fdin, (void (*)(void *))in_term, NULL, (void (*)(void *))destroy_terminal, term);
@@ -1121,7 +1121,7 @@ void exec_on_terminal(struct terminal *t
@@ -1124,7 +1124,7 @@ void exec_on_terminal(struct terminal *t
if (!F) set_handlers(term->fdin, NULL, NULL, (void (*)(void *))destroy_terminal, term);
/*block_itrm(term->fdin);*/
} else {

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-url_c,v 1.1 2002/12/17 08:11:31 fgsch Exp $
--- url.c.orig Tue Dec 17 03:46:42 2002
+++ url.c Tue Dec 17 03:46:55 2002
@@ -26,6 +26,7 @@ struct {
$OpenBSD: patch-url_c,v 1.2 2003/11/17 22:59:32 fgsch Exp $
--- url.c.orig 2003-10-27 18:55:47.000000000 -0300
+++ url.c 2003-11-17 19:09:12.000000000 -0300
@@ -27,6 +27,7 @@ struct {
#ifdef JS
{"javascript", 0, NULL, javascript_func, 1, 0, 0},
#endif

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-view_c,v 1.6 2003/09/23 06:35:33 fgsch Exp $
--- view.c.orig 2003-09-01 16:40:51.000000000 -0300
+++ view.c 2003-09-23 02:55:15.000000000 -0300
$OpenBSD: patch-view_c,v 1.7 2003/11/17 22:59:32 fgsch Exp $
--- view.c.orig 2003-11-10 15:03:30.000000000 -0300
+++ view.c 2003-11-17 19:09:12.000000000 -0300
@@ -1692,7 +1692,7 @@ void back(struct session *ses, struct f_
void selected_item(struct terminal *term, void *pitem, struct session *ses)
@ -10,7 +10,7 @@ $OpenBSD: patch-view_c,v 1.6 2003/09/23 06:35:33 fgsch Exp $
int old_item=item;
struct f_data_c *f = current_frame(ses);
struct link *l;
@@ -2537,7 +2537,7 @@ void send_event(struct session *ses, str
@@ -2544,7 +2544,7 @@ void send_event(struct session *ses, str
goto x;
}
if ((upcase(ev->x) == 'Q' && !ev->y) || ev->x == KBD_CTRL_C) {