[w3m-dev 03307] add password_file support
* file.c (find_auth_user_passwd): added * fm.h (passwd_file): added * rc.c (CMT_PASSWDFILE): added (passwdfile): added From: Fumitoshi UKAI <ukai@debian.or.jp>
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2002-09-11 Fumitoshi UKAI <ukai@debian.or.jp>
|
||||||
|
|
||||||
|
* [w3m-dev 03307] add password_file support
|
||||||
|
* file.c (find_auth_user_passwd): added
|
||||||
|
* fm.h (passwd_file): added
|
||||||
|
* rc.c (CMT_PASSWDFILE): added
|
||||||
|
(passwdfile): added
|
||||||
|
|
||||||
2002-09-09 Hiroyuki Ito <hito@crl.go.jp>
|
2002-09-09 Hiroyuki Ito <hito@crl.go.jp>
|
||||||
|
|
||||||
* [w3m-dev 03300] framebuffer: 8bit color support
|
* [w3m-dev 03300] framebuffer: 8bit color support
|
||||||
@@ -3767,4 +3775,4 @@
|
|||||||
* release-0-2-1
|
* release-0-2-1
|
||||||
* import w3m-0.2.1
|
* import w3m-0.2.1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.424 2002/09/09 14:03:44 ukai Exp $
|
$Id: ChangeLog,v 1.425 2002/09/10 17:27:39 ukai Exp $
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
w3m 0.4?
|
w3m 0.4?
|
||||||
|
|
||||||
|
* rc: passwd_file: passwd file for HTTP auth
|
||||||
* func: MARK_WORD
|
* func: MARK_WORD
|
||||||
* rc: imgsize: obsoleted
|
* rc: imgsize: obsoleted
|
||||||
* w3m-img for framebuffer merged
|
* w3m-img for framebuffer merged
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: file.c,v 1.96 2002/08/27 16:25:54 ukai Exp $ */
|
/* $Id: file.c,v 1.97 2002/09/10 17:27:46 ukai Exp $ */
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "myctype.h"
|
#include "myctype.h"
|
||||||
@@ -1342,6 +1342,89 @@ findAuthentication(struct http_auth *hauth, Buffer *buf, char *auth_field)
|
|||||||
return hauth->scheme ? hauth : NULL;
|
return hauth->scheme ? hauth : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* passwd */
|
||||||
|
/*
|
||||||
|
* machine <name>
|
||||||
|
* port <port>
|
||||||
|
* path <file>
|
||||||
|
* realm <realm>
|
||||||
|
* login <login>
|
||||||
|
* passwd <passwd>
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
find_auth_user_passwd(char *host, int port, char *file, char *realm,
|
||||||
|
Str *uname, Str *pwd)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
FILE *fp;
|
||||||
|
Str line;
|
||||||
|
char *d, *tok;
|
||||||
|
int matched = 0;
|
||||||
|
|
||||||
|
*uname = NULL;
|
||||||
|
*pwd = NULL;
|
||||||
|
if (stat(expandName(passwd_file), &st) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* check permissions, if group or others readable or writable,
|
||||||
|
* refuse it, because it's insecure.
|
||||||
|
*/
|
||||||
|
if ((st.st_mode & (S_IRWXG | S_IRWXO)) != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fp = fopen(expandName(passwd_file), "r");
|
||||||
|
if (fp == NULL)
|
||||||
|
return 0; /* never? */
|
||||||
|
|
||||||
|
while ((line = Strfgets(fp))->length > 0) {
|
||||||
|
d = line->ptr;
|
||||||
|
if (d[0] == '#')
|
||||||
|
continue;
|
||||||
|
tok = strtok(d, " \t\n\r");
|
||||||
|
if (tok == NULL)
|
||||||
|
continue;
|
||||||
|
d = strtok(NULL, "\n\r");
|
||||||
|
if (d == NULL)
|
||||||
|
continue;
|
||||||
|
if (strcmp(tok, "machine") == 0) {
|
||||||
|
if (matched && *uname && *pwd)
|
||||||
|
return 1;
|
||||||
|
*uname = NULL;
|
||||||
|
*pwd = NULL;
|
||||||
|
if (strcmp(d, host) == 0)
|
||||||
|
matched = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (strcmp(tok, "port") == 0) {
|
||||||
|
if (matched && (atoi(d) != port))
|
||||||
|
matched = 0;
|
||||||
|
}
|
||||||
|
else if (strcmp(tok, "path") == 0) {
|
||||||
|
if (matched && file && (strcmp(d, file) != 0))
|
||||||
|
matched = 0;
|
||||||
|
}
|
||||||
|
else if (strcmp(tok, "realm") == 0) {
|
||||||
|
if (matched && realm && (strcmp(d, realm) != 0))
|
||||||
|
matched = 0;
|
||||||
|
}
|
||||||
|
else if (strcmp(tok, "login") == 0) {
|
||||||
|
if (matched)
|
||||||
|
*uname = Strnew_charp(d);
|
||||||
|
}
|
||||||
|
else if (strcmp(tok, "password") == 0 || strcmp(tok, "passwd") == 0) {
|
||||||
|
if (matched)
|
||||||
|
*pwd = Strnew_charp(d);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* ignore? */ ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (matched && *uname && *pwd)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static Str
|
static Str
|
||||||
getAuthCookie(struct http_auth *hauth, char *auth_header,
|
getAuthCookie(struct http_auth *hauth, char *auth_header,
|
||||||
TextList *extra_header, ParsedURL *pu, HRequest *hr,
|
TextList *extra_header, ParsedURL *pu, HRequest *hr,
|
||||||
@@ -1386,53 +1469,61 @@ getAuthCookie(struct http_auth *hauth, char *auth_header,
|
|||||||
else
|
else
|
||||||
ss = find_auth_cookie(pu->host, pu->port, pu->file, realm);
|
ss = find_auth_cookie(pu->host, pu->port, pu->file, realm);
|
||||||
if (realm && ss == NULL) {
|
if (realm && ss == NULL) {
|
||||||
if (QuietMessage)
|
if (find_auth_user_passwd(pu->host, pu->port, pu->file, realm,
|
||||||
return ss;
|
&uname, &pwd)) {
|
||||||
/* input username and password */
|
/* found username & password in passwd file */ ;
|
||||||
sleep(2);
|
|
||||||
if (fmInitialized) {
|
|
||||||
char *pp;
|
|
||||||
term_raw();
|
|
||||||
if ((pp =
|
|
||||||
inputStr(Sprintf("Username for %s: ", realm)->ptr,
|
|
||||||
NULL)) == NULL)
|
|
||||||
return NULL;
|
|
||||||
uname = Str_conv_to_system(Strnew_charp(pp));
|
|
||||||
if ((pp =
|
|
||||||
inputLine(Sprintf("Password for %s: ", realm)->ptr, NULL,
|
|
||||||
IN_PASSWORD)) == NULL)
|
|
||||||
return NULL;
|
|
||||||
pwd = Str_conv_to_system(Strnew_charp(pp));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int proxy = !strncasecmp("Proxy-Authorization:", auth_header,
|
if (QuietMessage)
|
||||||
auth_header_len);
|
return ss;
|
||||||
|
/* input username and password */
|
||||||
/*
|
sleep(2);
|
||||||
* If post file is specified as '-', stdin is closed at this point.
|
if (fmInitialized) {
|
||||||
* In this case, w3m cannot read username from stdin.
|
char *pp;
|
||||||
* So exit with error message.
|
term_raw();
|
||||||
* (This is same behavior as lwp-request.)
|
if ((pp =
|
||||||
*/
|
inputStr(Sprintf("Username for %s: ", realm)->ptr,
|
||||||
if (feof(stdin) || ferror(stdin)) {
|
NULL)) == NULL)
|
||||||
fprintf(stderr, "w3m: Authorization required for %s\n", realm);
|
return NULL;
|
||||||
exit(1);
|
uname = Str_conv_to_system(Strnew_charp(pp));
|
||||||
|
if ((pp =
|
||||||
|
inputLine(Sprintf("Password for %s: ", realm)->ptr, NULL,
|
||||||
|
IN_PASSWORD)) == NULL)
|
||||||
|
return NULL;
|
||||||
|
pwd = Str_conv_to_system(Strnew_charp(pp));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
int proxy = !strncasecmp("Proxy-Authorization:", auth_header,
|
||||||
|
auth_header_len);
|
||||||
|
|
||||||
printf(proxy ? "Proxy Username for %s: " : "Username for %s: ",
|
/*
|
||||||
realm);
|
* If post file is specified as '-', stdin is closed at this
|
||||||
fflush(stdout);
|
* point.
|
||||||
uname = Strfgets(stdin);
|
* In this case, w3m cannot read username from stdin.
|
||||||
Strchop(uname);
|
* So exit with error message.
|
||||||
|
* (This is same behavior as lwp-request.)
|
||||||
|
*/
|
||||||
|
if (feof(stdin) || ferror(stdin)) {
|
||||||
|
fprintf(stderr, "w3m: Authorization required for %s\n",
|
||||||
|
realm);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(proxy ? "Proxy Username for %s: " : "Username for %s: ",
|
||||||
|
realm);
|
||||||
|
fflush(stdout);
|
||||||
|
uname = Strfgets(stdin);
|
||||||
|
Strchop(uname);
|
||||||
#ifdef HAVE_GETPASSPHRASE
|
#ifdef HAVE_GETPASSPHRASE
|
||||||
pwd = Strnew_charp((char *)
|
pwd = Strnew_charp((char *)
|
||||||
getpassphrase(proxy ? "Proxy Password: " :
|
getpassphrase(proxy ? "Proxy Password: " :
|
||||||
"Password: "));
|
"Password: "));
|
||||||
#else
|
#else
|
||||||
pwd = Strnew_charp((char *)
|
pwd = Strnew_charp((char *)
|
||||||
getpass(proxy ? "Proxy Password: " :
|
getpass(proxy ? "Proxy Password: " :
|
||||||
"Password: "));
|
"Password: "));
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ss = hauth->cred(hauth, uname, pwd, pu, hr, request);
|
ss = hauth->cred(hauth, uname, pwd, pu, hr, request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: fm.h,v 1.62 2002/08/20 17:49:39 ukai Exp $ */
|
/* $Id: fm.h,v 1.63 2002/09/10 17:27:47 ukai Exp $ */
|
||||||
/*
|
/*
|
||||||
* w3m: WWW wo Miru utility
|
* w3m: WWW wo Miru utility
|
||||||
*
|
*
|
||||||
@@ -838,6 +838,7 @@ global char *ExtBrowser init(DEF_EXT_BROWSER);
|
|||||||
global char *ExtBrowser2 init(NULL);
|
global char *ExtBrowser2 init(NULL);
|
||||||
global char *ExtBrowser3 init(NULL);
|
global char *ExtBrowser3 init(NULL);
|
||||||
global int BackgroundExtViewer init(TRUE);
|
global int BackgroundExtViewer init(TRUE);
|
||||||
|
global char *passwd_file init(NULL);
|
||||||
global char *ftppasswd init(NULL);
|
global char *ftppasswd init(NULL);
|
||||||
#ifdef FTPPASS_HOSTNAMEGEN
|
#ifdef FTPPASS_HOSTNAMEGEN
|
||||||
global int ftppass_hostnamegen init(TRUE);
|
global int ftppass_hostnamegen init(TRUE);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: rc.c,v 1.47 2002/07/22 16:27:31 ukai Exp $ */
|
/* $Id: rc.c,v 1.48 2002/09/10 17:27:50 ukai Exp $ */
|
||||||
/*
|
/*
|
||||||
* Initialization file etc.
|
* Initialization file etc.
|
||||||
*/
|
*/
|
||||||
@@ -127,6 +127,7 @@ static char *config_file = NULL;
|
|||||||
#define CMT_EXTBRZ "外部ブラウザ"
|
#define CMT_EXTBRZ "外部ブラウザ"
|
||||||
#define CMT_EXTBRZ2 "外部ブラウザその2"
|
#define CMT_EXTBRZ2 "外部ブラウザその2"
|
||||||
#define CMT_EXTBRZ3 "外部ブラウザその3"
|
#define CMT_EXTBRZ3 "外部ブラウザその3"
|
||||||
|
#define CMT_PASSWDFILE "パスワードファイル"
|
||||||
#define CMT_FTPPASS "FTPのパスワード(普通は自分のmail addressを使う)"
|
#define CMT_FTPPASS "FTPのパスワード(普通は自分のmail addressを使う)"
|
||||||
#ifdef FTPPASS_HOSTNAMEGEN
|
#ifdef FTPPASS_HOSTNAMEGEN
|
||||||
#define CMT_FTPPASS_HOSTNAMEGEN "FTPのパスワードのドメイン名を自動生成する"
|
#define CMT_FTPPASS_HOSTNAMEGEN "FTPのパスワードのドメイン名を自動生成する"
|
||||||
@@ -268,6 +269,7 @@ static char *config_file = NULL;
|
|||||||
#define CMT_EXTBRZ "External Browser"
|
#define CMT_EXTBRZ "External Browser"
|
||||||
#define CMT_EXTBRZ2 "Second External Browser"
|
#define CMT_EXTBRZ2 "Second External Browser"
|
||||||
#define CMT_EXTBRZ3 "Third External Browser"
|
#define CMT_EXTBRZ3 "Third External Browser"
|
||||||
|
#define CMT_PASSWDFILE "Password file"
|
||||||
#define CMT_FTPPASS "Password for anonymous FTP (your mail address)"
|
#define CMT_FTPPASS "Password for anonymous FTP (your mail address)"
|
||||||
#ifdef FTPPASS_HOSTNAMEGEN
|
#ifdef FTPPASS_HOSTNAMEGEN
|
||||||
#define CMT_FTPPASS_HOSTNAMEGEN "Generate domain part of password for FTP"
|
#define CMT_FTPPASS_HOSTNAMEGEN "Generate domain part of password for FTP"
|
||||||
@@ -665,6 +667,8 @@ struct param_ptr params8[] = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
struct param_ptr params9[] = {
|
struct param_ptr params9[] = {
|
||||||
|
{"passwd_file", P_STRING, PI_TEXT, (void *)&passwd_file, CMT_PASSWDFILE,
|
||||||
|
NULL},
|
||||||
{"ftppasswd", P_STRING, PI_TEXT, (void *)&ftppasswd, CMT_FTPPASS, NULL},
|
{"ftppasswd", P_STRING, PI_TEXT, (void *)&ftppasswd, CMT_FTPPASS, NULL},
|
||||||
#ifdef FTPPASS_HOSTNAMEGEN
|
#ifdef FTPPASS_HOSTNAMEGEN
|
||||||
{"ftppass_hostnamegen", P_INT, PI_ONOFF, (void *)&ftppass_hostnamegen,
|
{"ftppass_hostnamegen", P_INT, PI_ONOFF, (void *)&ftppass_hostnamegen,
|
||||||
|
|||||||
Reference in New Issue
Block a user