Skip to content

Commit

Permalink
[ftp] User and password URI support for the FTP protocol
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gL2n30Y06arv2 authored and Marty Connor committed Jan 20, 2010
1 parent 3d9dd93 commit 93805d9
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/net/tcp/ftp.c
Expand Up @@ -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 },
Expand Down

0 comments on commit 93805d9

Please sign in to comment.