Просмотр исходного кода

[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>
tags/v1.0.0-rc1
gL2n30Y06arv2 14 лет назад
Родитель
Сommit
93805d9765
1 измененных файлов: 24 добавлений и 2 удалений
  1. 24
    2
      src/net/tcp/ftp.c

+ 24
- 2
src/net/tcp/ftp.c Просмотреть файл

@@ -131,11 +131,33 @@ static const char * ftp_uri_path ( struct ftp_request *ftp ) {
131 131
 	return ftp->uri->path;
132 132
 }
133 133
 
134
+/**
135
+ * Retrieve FTP user
136
+ *
137
+ * @v ftp		FTP request
138
+ * @ret user		FTP user
139
+ */
140
+static const char * ftp_user ( struct ftp_request *ftp ) {
141
+	static char *ftp_default_user = "anonymous";
142
+	return ftp->uri->user ? ftp->uri->user : ftp_default_user;
143
+}
144
+
145
+/**
146
+ * Retrieve FTP password
147
+ *
148
+ * @v ftp		FTP request
149
+ * @ret password	FTP password
150
+ */
151
+static const char * ftp_password ( struct ftp_request *ftp ) {
152
+	static char *ftp_default_password = "etherboot@etherboot.org";
153
+	return ftp->uri->password ? ftp->uri->password : ftp_default_password;
154
+}
155
+
134 156
 /** FTP control channel strings */
135 157
 static struct ftp_control_string ftp_strings[] = {
136 158
 	[FTP_CONNECT]	= { NULL, NULL },
137
-	[FTP_USER]	= { "USER anonymous", NULL },
138
-	[FTP_PASS]	= { "PASS etherboot@etherboot.org", NULL },
159
+	[FTP_USER]	= { "USER ", ftp_user },
160
+	[FTP_PASS]	= { "PASS ", ftp_password },
139 161
 	[FTP_TYPE]	= { "TYPE I", NULL },
140 162
 	[FTP_PASV]	= { "PASV", NULL },
141 163
 	[FTP_RETR]	= { "RETR ", ftp_uri_path },

Загрузка…
Отмена
Сохранить