[elinks-dev] FSP and passwords

Witold Filipczyk witekfl at poczta.onet.pl
Sat Dec 9 13:41:51 MST 2006


Hey,
Password protected directories doesn't work with the FSP code.
get_uri_string(uri, URI_PASSWORD) simply doesn't work.
I don't know how to use branches, so I'm including the patch here:
diff --git a/src/protocol/fsp/fsp.c b/src/protocol/fsp/fsp.c
index c66848a..e8eac96 100644
--- a/src/protocol/fsp/fsp.c
+++ b/src/protocol/fsp/fsp.c
@@ -180,10 +180,19 @@ do_fsp(struct connection *conn)
 	struct stat sb;
 	struct uri *uri = conn->uri;
 	unsigned char *host = get_uri_string(uri, URI_HOST);
-	unsigned char *password = get_uri_string(uri, URI_PASSWORD);
 	unsigned char *data = get_uri_string(uri, URI_DATA);
 	unsigned short port = (unsigned short)get_uri_port(uri);
-	FSP_SESSION *ses = fsp_open_session(host, port, password);
+	FSP_SESSION *ses;
+
+	if (uri->password) {
+		unsigned char tmp = uri->password[uri->passwordlen];
+
+		uri->password[uri->passwordlen] = '\0';
+		ses = fsp_open_session(host, port, uri->password);
+		uri->password[uri->passwordlen] = tmp;
+	} else {
+		ses = fsp_open_session(host, port, NULL);
+	}
 
 	if (!ses)
 		fsp_error("Session initialization failed.");

Use it with fake user, eg: fsp://user:password@...
In directory listings, IMHO, this password should be added to base href,
otherwise it must be added by hand for every followed link.
The same case is for smb2(not applied yet).

-- 
Witek



More information about the elinks-dev mailing list