aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ChangeLog23
-rw-r--r--etc.c19
-rw-r--r--file.c40
-rw-r--r--fm.h3
-rw-r--r--ftp.c6
-rw-r--r--proto.h10
-rw-r--r--url.c3
7 files changed, 77 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 32c6b16..dd52b1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2002-02-20 Fumitoshi UKAI <ukai@debian.or.jp>
+ * [w3m-dev 03057] Re: Bug#134350: w3m: Forgets (http auth) login information upon reload (or almost anything else)
+ * etc.c (find_auth): add `file'
+ check file as well
+ * etc.c (find_auth_cookie): add `file'
+ * etc.c (add_auth_cookie): add `file'
+ * file.c (AuthBasicCred): add "Basic "
+ * file.c (AuthDigestCred): add "Digest "
+ * file.c (getAuthCookie): if h_auth == NULL, get recorded cookie
+ * file.c (get_auth_cookie): get recorded cookie
+ * file.c (loadGeneralFile): don't clear add_auth_cookie_flag
+ by redirection
+ add_auth_cookie if authorization is required and passed
+ * fm.h (auth_cookie): add file
+ * ftp.c (openFTP): follow change auth_cookie
+ * proto.h (get_auth_cookie): added
+ * proto.h (find_auth_cookie): add `file'
+ * proto.h (add_auth_cookie): add `file'
+ * url.c (openURL): get_auth_cookie
+
+2002-02-20 Fumitoshi UKAI <ukai@debian.or.jp>
+
* [w3m-dev 03058] mailer
* NEWS: rc: mailer
* fm.h (Mailer): change default
@@ -2955,4 +2976,4 @@
* release-0-2-1
* import w3m-0.2.1
-$Id: ChangeLog,v 1.320 2002/02/19 15:25:19 ukai Exp $
+$Id: ChangeLog,v 1.321 2002/02/19 15:50:17 ukai Exp $
diff --git a/etc.c b/etc.c
index fd06c59..cd1db2d 100644
--- a/etc.c
+++ b/etc.c
@@ -1,4 +1,4 @@
-/* $Id: etc.c,v 1.18 2002/01/31 17:54:50 ukai Exp $ */
+/* $Id: etc.c,v 1.19 2002/02/19 15:50:18 ukai Exp $ */
#include "fm.h"
#include <pwd.h>
#include "myctype.h"
@@ -888,40 +888,45 @@ correct_irrtag(int status)
/* authentication */
struct auth_cookie *
-find_auth(char *host, int port, char *realm)
+find_auth(char *host, int port, char *file, char *realm)
{
struct auth_cookie *p;
for (p = Auth_cookie; p != NULL; p = p->next) {
if (!Strcasecmp_charp(p->host, host) &&
- p->port == port && !Strcasecmp_charp(p->realm, realm))
+ p->port == port &&
+ ((realm && !Strcasecmp_charp(p->realm, realm)) ||
+ (p->file && file && !Strcasecmp_charp(p->file, file))))
return p;
}
return NULL;
}
Str
-find_auth_cookie(char *host, int port, char *realm)
+find_auth_cookie(char *host, int port, char *file, char *realm)
{
- struct auth_cookie *p = find_auth(host, port, realm);
+ struct auth_cookie *p = find_auth(host, port, file, realm);
if (p)
return p->cookie;
return NULL;
}
void
-add_auth_cookie(char *host, int port, char *realm, Str cookie)
+add_auth_cookie(char *host, int port, char *file, char *realm, Str cookie)
{
struct auth_cookie *p;
- p = find_auth(host, port, realm);
+ p = find_auth(host, port, file, realm);
if (p) {
+ if (realm && p->realm == NULL)
+ p->realm = Strnew_charp(realm);
p->cookie = cookie;
return;
}
p = New(struct auth_cookie);
p->host = Strnew_charp(host);
p->port = port;
+ p->file = file ? Strnew_charp(file) : NULL;
p->realm = Strnew_charp(realm);
p->cookie = cookie;
p->next = Auth_cookie;
diff --git a/file.c b/file.c
index eddbc12..79ab3bf 100644
--- a/file.c
+++ b/file.c
@@ -1,4 +1,4 @@
-/* $Id: file.c,v 1.69 2002/02/08 11:18:10 ukai Exp $ */
+/* $Id: file.c,v 1.70 2002/02/19 15:50:18 ukai Exp $ */
#include "fm.h"
#include <sys/types.h>
#include "myctype.h"
@@ -1006,7 +1006,7 @@ AuthBasicCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu,
Str s = Strdup(uname);
Strcat_char(s, ':');
Strcat(s, pw);
- return encodeB(s->ptr);
+ return Strnew_m_charp("Basic ", encodeB(s->ptr)->ptr, NULL);
}
#ifdef USE_DIGEST_AUTH
@@ -1154,7 +1154,7 @@ AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu,
* [nonce-count] | [auth-param] )
*/
- tmp = Strnew_m_charp("username=\"", uname->ptr, "\"", NULL);
+ tmp = Strnew_m_charp("Digest username=\"", uname->ptr, "\"", NULL);
Strcat_m_charp(tmp, ", realm=",
get_auth_param(ha->param, "realm")->ptr, NULL);
Strcat_m_charp(tmp, ", nonce=",
@@ -1292,7 +1292,10 @@ getAuthCookie(struct http_auth *hauth, char *auth_header,
TextListItem *i, **i0;
int a_found;
int auth_header_len = strlen(auth_header);
- char *realm = qstr_unquote(get_auth_param(hauth->param, "realm"))->ptr;
+ char *realm = NULL;
+
+ if (hauth)
+ realm = qstr_unquote(get_auth_param(hauth->param, "realm"))->ptr;
a_found = FALSE;
for (i0 = &(extra_header->first), i = *i0; i != NULL;
@@ -1303,6 +1306,8 @@ getAuthCookie(struct http_auth *hauth, char *auth_header,
}
}
if (a_found) {
+ if (!realm)
+ return NULL;
/* This means that *-Authenticate: header is received after
* Authorization: header is sent to the server.
*/
@@ -1318,8 +1323,8 @@ getAuthCookie(struct http_auth *hauth, char *auth_header,
* extra_header */
}
else
- ss = find_auth_cookie(pu->host, pu->port, realm);
- if (ss == NULL) {
+ ss = find_auth_cookie(pu->host, pu->port, pu->file, realm);
+ if (realm && ss == NULL) {
if (QuietMessage)
return ss;
/* input username and password */
@@ -1372,14 +1377,21 @@ getAuthCookie(struct http_auth *hauth, char *auth_header,
}
if (ss) {
tmp = Strnew_charp(auth_header);
- Strcat_m_charp(tmp, " ", hauth->scheme, NULL);
- Strcat(tmp, ss);
- Strcat_charp(tmp, "\r\n");
+ Strcat_m_charp(tmp, " ", ss->ptr, "\r\n", NULL);
pushText(extra_header, tmp->ptr);
}
return ss;
}
+void
+get_auth_cookie(char *auth_header,
+ TextList *extra_header, ParsedURL *pu, HRequest *hr,
+ FormList *request)
+{
+ getAuthCookie(NULL, auth_header, extra_header, pu, hr, request);
+}
+
+
static int
same_url_p(ParsedURL *pu1, ParsedURL *pu2)
@@ -1599,7 +1611,6 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
tpath = tmp->ptr;
request = NULL;
UFclose(&f);
- add_auth_cookie_flag = 0;
current = New(ParsedURL);
copyParsedURL(current, &pu);
t_buf->bufferprop |= BP_REDIRECTED;
@@ -1607,6 +1618,12 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
goto load_doc;
}
}
+ if (add_auth_cookie_flag && realm && ss) {
+ /* If authorization is required and passed */
+ add_auth_cookie(pu.host, pu.port, pu.file,
+ qstr_unquote(realm)->ptr, ss);
+ add_auth_cookie_flag = 0;
+ }
if ((p = checkHeader(t_buf, "WWW-Authenticate:")) != NULL &&
http_response_code == 401) {
/* Authentication needed */
@@ -1652,7 +1669,8 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
/* XXX: RFC2617 3.2.3 Authentication-Info: ? */
if (add_auth_cookie_flag)
/* If authorization is required and passed */
- add_auth_cookie(pu.host, pu.port, qstr_unquote(realm)->ptr, ss);
+ add_auth_cookie(pu.host, pu.port, pu.file,
+ qstr_unquote(realm)->ptr, ss);
if (status == HTST_CONNECT) {
of = &f;
goto load_doc;
diff --git a/fm.h b/fm.h
index 3fe38a6..a8dbd50 100644
--- a/fm.h
+++ b/fm.h
@@ -1,4 +1,4 @@
-/* $Id: fm.h,v 1.51 2002/02/19 15:25:19 ukai Exp $ */
+/* $Id: fm.h,v 1.52 2002/02/19 15:50:18 ukai Exp $ */
/*
* w3m: WWW wo Miru utility
*
@@ -600,6 +600,7 @@ struct html_feed_environ {
struct auth_cookie {
Str host;
int port;
+ Str file;
Str realm;
Str cookie;
struct auth_cookie *next;
diff --git a/ftp.c b/ftp.c
index 4c47d05..d3301a7 100644
--- a/ftp.c
+++ b/ftp.c
@@ -1,4 +1,4 @@
-/* $Id: ftp.c,v 1.10 2002/01/11 20:05:58 ukai Exp $ */
+/* $Id: ftp.c,v 1.11 2002/02/19 15:50:18 ukai Exp $ */
#include <stdio.h>
#include <pwd.h>
#include <Str.h>
@@ -411,7 +411,7 @@ openFTP(ParsedURL *pu)
if (pu->pass)
pass = pu->pass;
else if (pu->user) {
- pwd = find_auth_cookie(pu->host, pu->port, pu->user);
+ pwd = find_auth_cookie(pu->host, pu->port, pu->file, pu->user);
if (pwd == NULL) {
if (fmInitialized) {
term_raw();
@@ -441,7 +441,7 @@ openFTP(ParsedURL *pu)
if (FtpError(s))
return NULL;
if (add_auth_cookie_flag)
- add_auth_cookie(pu->host, pu->port, pu->user, pwd);
+ add_auth_cookie(pu->host, pu->port, pu->file, pu->user, pwd);
if (pu->file == NULL || *pu->file == '\0')
goto ftp_dir;
else
diff --git a/proto.h b/proto.h
index 4f42d8b..1b722e5 100644
--- a/proto.h
+++ b/proto.h
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.35 2002/02/05 12:31:27 ukai Exp $ */
+/* $Id: proto.h,v 1.36 2002/02/19 15:50:18 ukai Exp $ */
/*
* This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended.
@@ -128,6 +128,9 @@ extern char *acceptableEncoding();
extern int dir_exist(char *path);
extern Str convertLine(URLFile *uf, Str line, char *code, int mode);
extern Buffer *loadFile(char *path);
+extern void get_auth_cookie(char *auth_header,
+ TextList *extra_header, ParsedURL *pu,
+ HRequest *hr, FormList *request);
extern Buffer *loadGeneralFile(char *path, ParsedURL *current, char *referer,
int flag, FormList *request);
extern int is_boundary(int, int);
@@ -512,8 +515,9 @@ extern Buffer *dirBuffer(char *dirname);
extern void set_environ(char *var, char *value);
extern FILE *localcgi_post(char *, char *, FormList *, char *);
extern FILE *localcgi_get(char *, char *, char *);
-extern Str find_auth_cookie(char *host, int port, char *realm);
-extern void add_auth_cookie(char *host, int port, char *realm, Str cookie);
+extern Str find_auth_cookie(char *host, int port, char *file, char *realm);
+extern void add_auth_cookie(char *host, int port, char *file, char *realm,
+ Str cookie);
extern char *last_modified(Buffer *buf);
extern Str romanNumeral(int n);
extern Str romanAlphabet(int n);
diff --git a/url.c b/url.c
index 50db641..9f659db 100644
--- a/url.c
+++ b/url.c
@@ -1,4 +1,4 @@
-/* $Id: url.c,v 1.43 2002/02/08 11:25:24 ukai Exp $ */
+/* $Id: url.c,v 1.44 2002/02/19 15:50:18 ukai Exp $ */
#include <stdio.h>
#include "config.h"
#include "fm.h"
@@ -1535,6 +1535,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
#ifdef USE_SSL
case SCM_HTTPS:
#endif /* USE_SSL */
+ get_auth_cookie("Authorization:", extra_header, pu, hr, request);
if (pu->file == NULL)
pu->file = allocStr("/", -1);
if (request && request->method == FORM_METHOD_POST && request->body)