Re: [PATCH] wget: new option FEATURE_WGET_FTP to enable/disable FTP

2021-03-09 Thread Denys Vlasenko
Applied, except for

-   h->protocol = P_FTP;
+   h->protocol = NULL;

bit (->protocol[0] must exist).

On Sun, Jan 17, 2021 at 7:35 PM Sergey Ponomarev  wrote:
>
> Introduce a separate option FTPS_SUPPORTED instead of not obvious 
> ENABLE_FEATURE_WGET_HTTPS.
>
> function old new   delta
> P_FTP  4   -  -4
> P_FTPS 5   -  -5
> reset_beg_range_to_zero   41   - -41
> parse_url431 366 -65
> parse_pasv_epsv  154   --154
> .rodata   115566  115408-158
> ftpcmd   204   --204
> spawn_ssl_client 291   --291
> wget_main   29982664-334
> --
> (add/remove: 0/7 grow/shrink: 0/3 up/down: 0/-1256) Total: -1256 bytes
>
> Signed-off-by: Sergey Ponomarev 
> ---
>  networking/wget.c | 43 ---
>  1 file changed, 32 insertions(+), 11 deletions(-)
>
> diff --git a/networking/wget.c b/networking/wget.c
> index e660c279c..51cac1f90 100644
> --- a/networking/wget.c
> +++ b/networking/wget.c
> @@ -25,6 +25,13 @@
>  //config:  default y
>  //config:  depends on WGET
>  //config:
> +//config:config FEATURE_WGET_FTP
> +//config:  bool "Enable FTP protocol (+1k)"
> +//config:  default y
> +//config:  depends on WGET
> +//config:  help
> +//config:  For support FTPS enable FEATURE_WGET_HTTPS
> +//config:
>  //config:config FEATURE_WGET_AUTHENTICATION
>  //config:  bool "Enable HTTP authentication"
>  //config:  default y
> @@ -48,12 +55,12 @@
>  //config:
>  //config:config FEATURE_WGET_HTTPS
>  //config:  bool "Support HTTPS using internal TLS code"
> -//it also enables FTPS support, but it's not well tested yet
>  //config:  default y
>  //config:  depends on WGET
>  //config:  select TLS
>  //config:  help
>  //config:  wget will use internal TLS code to connect to https:// URLs.
> +//config:  It also enables FTPS support, but it's not well tested yet.
>  //config:  Note:
>  //config:  On NOMMU machines, ssl_helper applet should be available
>  //config:  in the $PATH for this to work. Make sure to select that 
> applet.
> @@ -173,6 +180,7 @@
>
>
>  #define SSL_SUPPORTED (ENABLE_FEATURE_WGET_OPENSSL || 
> ENABLE_FEATURE_WGET_HTTPS)
> +#define FTPS_SUPPORTED (ENABLE_FEATURE_WGET_FTP && ENABLE_FEATURE_WGET_HTTPS)
>
>  struct host_info {
> char *allocated;
> @@ -182,14 +190,16 @@ struct host_info {
> char   *host;
> int port;
>  };
> -static const char P_FTP[] ALIGN1 = "ftp";
>  static const char P_HTTP[] ALIGN1 = "http";
>  #if SSL_SUPPORTED
> -# if ENABLE_FEATURE_WGET_HTTPS
> -static const char P_FTPS[] ALIGN1 = "ftps";
> -# endif
>  static const char P_HTTPS[] ALIGN1 = "https";
>  #endif
> +#if ENABLE_FEATURE_WGET_FTP
> +static const char P_FTP[] ALIGN1 = "ftp";
> +#endif
> +#if FTPS_SUPPORTED
> +static const char P_FTPS[] ALIGN1 = "ftps";
> +#endif
>
>  #if ENABLE_FEATURE_WGET_LONG_OPTIONS
>  /* User-specified headers prevent using our corresponding built-in headers.  
> */
> @@ -482,6 +492,7 @@ static char fgets_trim_sanitize(FILE *fp, const char *fmt)
> return c;
>  }
>
> +#if ENABLE_FEATURE_WGET_FTP
>  static int ftpcmd(const char *s1, const char *s2, FILE *fp)
>  {
> int result;
> @@ -507,6 +518,7 @@ static int ftpcmd(const char *s1, const char *s2, FILE 
> *fp)
> G.wget_buf[3] = ' ';
> return result;
>  }
> +#endif
>
>  static void parse_url(const char *src_url, struct host_info *h)
>  {
> @@ -515,21 +527,24 @@ static void parse_url(const char *src_url, struct 
> host_info *h)
> free(h->allocated);
> h->allocated = url = xstrdup(src_url);
>
> -   h->protocol = P_FTP;
> +   h->protocol = NULL;
> p = strstr(url, "://");
> if (p) {
> *p = '\0';
> h->host = p + 3;
> +#if ENABLE_FEATURE_WGET_FTP
> if (strcmp(url, P_FTP) == 0) {
> h->port = bb_lookup_std_port(P_FTP, "tcp", 21);
> +   h->protocol = P_FTP;
> } else
> -#if SSL_SUPPORTED
> -# if ENABLE_FEATURE_WGET_HTTPS
> +#endif
> +#if FTPS_SUPPORTED
> if (strcmp(url, P_FTPS) == 0) {
> h->port = bb_lookup_std_port(P_FTPS, "tcp", 990);
> h->protocol = P_FTPS;
> } else
> -# endif
> +#endif
> +#if SSL_SUPPORTED
> if (strcmp(url, P_HTTPS) == 0) {
> h->port = bb_lookup_std_port(P_HTTPS

Re: [PATCH] wget: new option FEATURE_WGET_FTP to enable/disable FTP

2021-01-17 Thread Sergey Ponomarev
The good idea, I also was confused. The reason is that if you enabled
internal tls then FTPS itself ads only dozen bytes. So no practical reason
to disable it.
The whole FTP disabling gives only additional  1-1.5 kb


On Mon, Jan 18, 2021 at 02:04 Kang-Che Sung  wrote:

>
>
> On Monday, January 18, 2021, Sergey Ponomarev  wrote:
> > Introduce a separate option FTPS_SUPPORTED instead of not obvious
> ENABLE_FEATURE_WGET_HTTPS.
> >
>
> I juat wonder...
> If you are bothered to add FTP configure option, how about making FTPS
> separate from HTTPS as well?

-- 
Sergey Ponomarev , skype:stokito
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] wget: new option FEATURE_WGET_FTP to enable/disable FTP

2021-01-17 Thread Kang-Che Sung
On Monday, January 18, 2021, Sergey Ponomarev  wrote:
> Introduce a separate option FTPS_SUPPORTED instead of not obvious
ENABLE_FEATURE_WGET_HTTPS.
>

I juat wonder...
If you are bothered to add FTP configure option, how about making FTPS
separate from HTTPS as well?
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] wget: new option FEATURE_WGET_FTP to enable/disable FTP

2021-01-17 Thread Sergey Ponomarev
Introduce a separate option FTPS_SUPPORTED instead of not obvious 
ENABLE_FEATURE_WGET_HTTPS.

function old new   delta
P_FTP  4   -  -4
P_FTPS 5   -  -5
reset_beg_range_to_zero   41   - -41
parse_url431 366 -65
parse_pasv_epsv  154   --154
.rodata   115566  115408-158
ftpcmd   204   --204
spawn_ssl_client 291   --291
wget_main   29982664-334
--
(add/remove: 0/7 grow/shrink: 0/3 up/down: 0/-1256) Total: -1256 bytes

Signed-off-by: Sergey Ponomarev 
---
 networking/wget.c | 43 ---
 1 file changed, 32 insertions(+), 11 deletions(-)

diff --git a/networking/wget.c b/networking/wget.c
index e660c279c..51cac1f90 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -25,6 +25,13 @@
 //config:  default y
 //config:  depends on WGET
 //config:
+//config:config FEATURE_WGET_FTP
+//config:  bool "Enable FTP protocol (+1k)"
+//config:  default y
+//config:  depends on WGET
+//config:  help
+//config:  For support FTPS enable FEATURE_WGET_HTTPS
+//config:
 //config:config FEATURE_WGET_AUTHENTICATION
 //config:  bool "Enable HTTP authentication"
 //config:  default y
@@ -48,12 +55,12 @@
 //config:
 //config:config FEATURE_WGET_HTTPS
 //config:  bool "Support HTTPS using internal TLS code"
-//it also enables FTPS support, but it's not well tested yet
 //config:  default y
 //config:  depends on WGET
 //config:  select TLS
 //config:  help
 //config:  wget will use internal TLS code to connect to https:// URLs.
+//config:  It also enables FTPS support, but it's not well tested yet.
 //config:  Note:
 //config:  On NOMMU machines, ssl_helper applet should be available
 //config:  in the $PATH for this to work. Make sure to select that applet.
@@ -173,6 +180,7 @@
 
 
 #define SSL_SUPPORTED (ENABLE_FEATURE_WGET_OPENSSL || 
ENABLE_FEATURE_WGET_HTTPS)
+#define FTPS_SUPPORTED (ENABLE_FEATURE_WGET_FTP && ENABLE_FEATURE_WGET_HTTPS)
 
 struct host_info {
char *allocated;
@@ -182,14 +190,16 @@ struct host_info {
char   *host;
int port;
 };
-static const char P_FTP[] ALIGN1 = "ftp";
 static const char P_HTTP[] ALIGN1 = "http";
 #if SSL_SUPPORTED
-# if ENABLE_FEATURE_WGET_HTTPS
-static const char P_FTPS[] ALIGN1 = "ftps";
-# endif
 static const char P_HTTPS[] ALIGN1 = "https";
 #endif
+#if ENABLE_FEATURE_WGET_FTP
+static const char P_FTP[] ALIGN1 = "ftp";
+#endif
+#if FTPS_SUPPORTED
+static const char P_FTPS[] ALIGN1 = "ftps";
+#endif
 
 #if ENABLE_FEATURE_WGET_LONG_OPTIONS
 /* User-specified headers prevent using our corresponding built-in headers.  */
@@ -482,6 +492,7 @@ static char fgets_trim_sanitize(FILE *fp, const char *fmt)
return c;
 }
 
+#if ENABLE_FEATURE_WGET_FTP
 static int ftpcmd(const char *s1, const char *s2, FILE *fp)
 {
int result;
@@ -507,6 +518,7 @@ static int ftpcmd(const char *s1, const char *s2, FILE *fp)
G.wget_buf[3] = ' ';
return result;
 }
+#endif
 
 static void parse_url(const char *src_url, struct host_info *h)
 {
@@ -515,21 +527,24 @@ static void parse_url(const char *src_url, struct 
host_info *h)
free(h->allocated);
h->allocated = url = xstrdup(src_url);
 
-   h->protocol = P_FTP;
+   h->protocol = NULL;
p = strstr(url, "://");
if (p) {
*p = '\0';
h->host = p + 3;
+#if ENABLE_FEATURE_WGET_FTP
if (strcmp(url, P_FTP) == 0) {
h->port = bb_lookup_std_port(P_FTP, "tcp", 21);
+   h->protocol = P_FTP;
} else
-#if SSL_SUPPORTED
-# if ENABLE_FEATURE_WGET_HTTPS
+#endif
+#if FTPS_SUPPORTED
if (strcmp(url, P_FTPS) == 0) {
h->port = bb_lookup_std_port(P_FTPS, "tcp", 990);
h->protocol = P_FTPS;
} else
-# endif
+#endif
+#if SSL_SUPPORTED
if (strcmp(url, P_HTTPS) == 0) {
h->port = bb_lookup_std_port(P_HTTPS, "tcp", 443);
h->protocol = P_HTTPS;
@@ -796,6 +811,7 @@ static void spawn_ssl_client(const char *host, int 
network_fd, int flags)
 }
 #endif
 
+#if ENABLE_FEATURE_WGET_FTP
 static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, 
len_and_sockaddr *lsa)
 {
FILE *sfp;
@@ -803,7 +819,7 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct 
host_info *target, len_and_