diff options
author | gL2n30Y06arv2 <gL2n30Y06arv2@hotmail.com> | 2009-12-29 17:49:28 +0000 |
---|---|---|
committer | Marty Connor <mdc@etherboot.org> | 2010-01-20 18:18:47 -0500 |
commit | 93805d97652b0f7a00028fe1e9ad461a7b5d423c (patch) | |
tree | 156ba6c0573f5fde62634541c2cb98647a93bd5d | |
parent | 3d9dd93a1452e28c728483b03e352691238491ed (diff) | |
download | ipxe-93805d97652b0f7a00028fe1e9ad461a7b5d423c.tar.gz |
[ftp] User and password URI support for the FTP protocol
The default user and password are used for anonymous FTP by default.
This patch adds support for an explicit user name and password in an FTP
URI:
imgfetch ftp://user:password@server.com/path/to/file
Edited-by: Stefan Hajnoczi <stefanha@gmail.com>. Bugs are my fault.
Signed-off-by: Marty Connor <mdc@etherboot.org>
-rw-r--r-- | src/net/tcp/ftp.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/net/tcp/ftp.c b/src/net/tcp/ftp.c index 0719bf728..920e537ab 100644 --- a/src/net/tcp/ftp.c +++ b/src/net/tcp/ftp.c @@ -131,11 +131,33 @@ static const char * ftp_uri_path ( struct ftp_request *ftp ) { return ftp->uri->path; } +/** + * Retrieve FTP user + * + * @v ftp FTP request + * @ret user FTP user + */ +static const char * ftp_user ( struct ftp_request *ftp ) { + static char *ftp_default_user = "anonymous"; + return ftp->uri->user ? ftp->uri->user : ftp_default_user; +} + +/** + * Retrieve FTP password + * + * @v ftp FTP request + * @ret password FTP password + */ +static const char * ftp_password ( struct ftp_request *ftp ) { + static char *ftp_default_password = "etherboot@etherboot.org"; + return ftp->uri->password ? ftp->uri->password : ftp_default_password; +} + /** FTP control channel strings */ static struct ftp_control_string ftp_strings[] = { [FTP_CONNECT] = { NULL, NULL }, - [FTP_USER] = { "USER anonymous", NULL }, - [FTP_PASS] = { "PASS etherboot@etherboot.org", NULL }, + [FTP_USER] = { "USER ", ftp_user }, + [FTP_PASS] = { "PASS ", ftp_password }, [FTP_TYPE] = { "TYPE I", NULL }, [FTP_PASV] = { "PASV", NULL }, [FTP_RETR] = { "RETR ", ftp_uri_path }, |