aboutsummaryrefslogtreecommitdiffstats
path: root/ftp.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-10-30 17:21:35 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-10-30 17:21:35 +0000
commitc5a144b682a3eb716f5c39475b30a4c02ab0100c (patch)
tree218372e5f2197ca0cc6bf0ea71a3e3a47ec822ba /ftp.c
parentfix indent (diff)
downloadw3m-c5a144b682a3eb716f5c39475b30a4c02ab0100c.tar.gz
w3m-c5a144b682a3eb716f5c39475b30a4c02ab0100c.zip
[w3m-dev 03365] ~/.netrc support
* etc.c (add_auth_pass_entry): add netrc arg add new entry to tail (find_auth_pass_entry): ent->host == NULL is "default" (loadPasswd): rewrite with next_token, parsePasswd, openPasswdFile load ~/.netrc (next_token): added (parsePasswd): added (openPasswdFile): added * ftp.c (openFTP): use find_auth_user_passwd * NEWS: ~/.netrc From: Fumitoshi UKAI <ukai@debian.or.jp>
Diffstat (limited to '')
-rw-r--r--ftp.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/ftp.c b/ftp.c
index 800ad7a..5c33b7a 100644
--- a/ftp.c
+++ b/ftp.c
@@ -1,4 +1,4 @@
-/* $Id: ftp.c,v 1.12 2002/08/20 17:49:39 ukai Exp $ */
+/* $Id: ftp.c,v 1.13 2002/10/30 17:21:42 ukai Exp $ */
#include <stdio.h>
#include <pwd.h>
#include <Str.h>
@@ -391,8 +391,8 @@ openFTP(ParsedURL *pu)
Str tmp2 = Strnew();
Str tmp3 = Strnew();
STATUS s;
- char *user;
- char *pass;
+ char *user = NULL;
+ char *pass = NULL;
Str pwd = NULL;
int add_auth_cookie_flag;
char *realpathname = NULL;
@@ -402,13 +402,26 @@ openFTP(ParsedURL *pu)
#endif
add_auth_cookie_flag = 0;
- if (pu->user)
+ if (pu->user == NULL && pu->pass == NULL) {
+ Str uname, pwd;
+ if (find_auth_user_passwd(pu, NULL, &uname, &pwd, 0)) {
+ if (uname)
+ user = uname->ptr;
+ if (pwd)
+ pass = pwd->ptr;
+ }
+ }
+ if (user)
+ /* do nothing */ ;
+ else if (pu->user)
user = pu->user;
else {
Strcat_charp(tmp3, "anonymous");
user = tmp3->ptr;
}
- if (pu->pass)
+ if (pass)
+ /* do nothing */ ;
+ else if (pu->pass)
pass = pu->pass;
else if (pu->user) {
pwd = find_auth_cookie(pu->host, pu->port, pu->file, pu->user);