aboutsummaryrefslogtreecommitdiff
path: root/networking/wget.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-07 01:39:40 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-07 01:39:40 +0200
commit1c6c670ed44a77ab4784ea0d4ac5411d7b0648d8 (patch)
tree477c1daf40605269b4ee5912c5402d3f9e60aabc /networking/wget.c
parent3b650c1e7b0bcbb4dfebab6fd87449e6b1e0b788 (diff)
downloadbusybox-w32-1c6c670ed44a77ab4784ea0d4ac5411d7b0648d8.tar.gz
busybox-w32-1c6c670ed44a77ab4784ea0d4ac5411d7b0648d8.tar.bz2
busybox-w32-1c6c670ed44a77ab4784ea0d4ac5411d7b0648d8.zip
wget: make openssl/ssl_helper choice configurable
I got sick of not being able to wget a https file... Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r--networking/wget.c105
1 files changed, 95 insertions, 10 deletions
diff --git a/networking/wget.c b/networking/wget.c
index f744ea2de..baa7e0e78 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -9,6 +9,89 @@
9 * Kuhn's copyrights are licensed GPLv2-or-later. File as a whole remains GPLv2. 9 * Kuhn's copyrights are licensed GPLv2-or-later. File as a whole remains GPLv2.
10 */ 10 */
11 11
12//config:config WGET
13//config: bool "wget"
14//config: default y
15//config: help
16//config: wget is a utility for non-interactive download of files from HTTP
17//config: and FTP servers.
18//config:
19//config:config FEATURE_WGET_STATUSBAR
20//config: bool "Enable a nifty process meter (+2k)"
21//config: default y
22//config: depends on WGET
23//config: help
24//config: Enable the transfer progress bar for wget transfers.
25//config:
26//config:config FEATURE_WGET_AUTHENTICATION
27//config: bool "Enable HTTP authentication"
28//config: default y
29//config: depends on WGET
30//config: help
31//config: Support authenticated HTTP transfers.
32//config:
33//config:config FEATURE_WGET_LONG_OPTIONS
34//config: bool "Enable long options"
35//config: default y
36//config: depends on WGET && LONG_OPTS
37//config: help
38//config: Support long options for the wget applet.
39//config:
40//config:config FEATURE_WGET_TIMEOUT
41//config: bool "Enable timeout option -T SEC"
42//config: default y
43//config: depends on WGET
44//config: help
45//config: Supports network read and connect timeouts for wget,
46//config: so that wget will give up and timeout, through the -T
47//config: command line option.
48//config:
49//config: Currently only connect and network data read timeout are
50//config: supported (i.e., timeout is not applied to the DNS query). When
51//config: FEATURE_WGET_LONG_OPTIONS is also enabled, the --timeout option
52//config: will work in addition to -T.
53//config:
54//config:choice
55//config: prompt "Choose how to handle https:// URLs"
56//config: depends on WGET
57//config: default FEATURE_WGET_OPENSSL
58//config: help
59//config: Choose how wget establishes SSL connection for https:// URLs.
60//config:
61//config: Busybox itself contains no SSL code. wget will spawn
62//config: a helper program to talk over HTTPS.
63//config:
64//config: OpenSSL has a simple SSL client for debug purposes.
65//config: If you select "openssl" helper, wget will effectively call
66//config: "openssl s_client -quiet -connect IP:443 2>/dev/null"
67//config: and pipe its data through it.
68//config: Note inconvenient API: host resolution is done twice,
69//config: and there is no guarantee openssl's idea of IPv6 address
70//config: format is the same as ours.
71//config: Another problem is that s_client prints debug information
72//config: to stderr, and it needs to be suppressed. This means
73//config: all error messages get suppressed too.
74//config: openssl is also a big binary, often dynamically linked
75//config: against ~15 libraries.
76//config:
77//config: ssl_helper is a tool which can be built statically
78//config: from busybox sources against a small embedded SSL library.
79//config: Please see networking/ssl_helper/README.
80//config: It does not require double host resolution and emits
81//config: error messages to stderr.
82//config:
83//config:config FEATURE_WGET_OPENSSL
84//config: bool "openssl"
85//config:
86//config:config FEATURE_WGET_SSL_HELPER
87//config: bool "ssl_helper"
88//config:
89//config:endchoice
90
91//applet:IF_WGET(APPLET(wget, BB_DIR_USR_BIN, BB_SUID_DROP))
92
93//kbuild:lib-$(CONFIG_WGET) += wget.o
94
12//usage:#define wget_trivial_usage 95//usage:#define wget_trivial_usage
13//usage: IF_FEATURE_WGET_LONG_OPTIONS( 96//usage: IF_FEATURE_WGET_LONG_OPTIONS(
14//usage: "[-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document FILE]\n" 97//usage: "[-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document FILE]\n"
@@ -520,6 +603,7 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_
520 return sfp; 603 return sfp;
521} 604}
522 605
606#if ENABLE_FEATURE_WGET_OPENSSL
523static int spawn_https_helper(const char *host, unsigned port) 607static int spawn_https_helper(const char *host, unsigned port)
524{ 608{
525 char *allocated = NULL; 609 char *allocated = NULL;
@@ -569,12 +653,11 @@ static int spawn_https_helper(const char *host, unsigned port)
569 close(sp[1]); 653 close(sp[1]);
570 return sp[0]; 654 return sp[0];
571} 655}
656#endif
572 657
573/* See networking/ssl_helper/README */ 658/* See networking/ssl_helper/README how to build one */
574#define SSL_HELPER 0 659#if ENABLE_FEATURE_WGET_SSL_HELPER
575 660static void spawn_https_helper(int network_fd)
576#if SSL_HELPER
577static void spawn_https_helper1(int network_fd)
578{ 661{
579 int sp[2]; 662 int sp[2];
580 int pid; 663 int pid;
@@ -851,19 +934,21 @@ static void download_one_url(const char *url)
851 int status; 934 int status;
852 935
853 /* Open socket to http(s) server */ 936 /* Open socket to http(s) server */
937#if ENABLE_FEATURE_WGET_OPENSSL
854 if (target.protocol == P_HTTPS) { 938 if (target.protocol == P_HTTPS) {
855/* openssl-based helper 939 /* openssl-based helper
856 * Inconvenient API since we can't give it an open fd 940 * Inconvenient API since we can't give it an open fd
857 */ 941 */
858 int fd = spawn_https_helper(server.host, server.port); 942 int fd = spawn_https_helper(server.host, server.port);
859 sfp = fdopen(fd, "r+"); 943 sfp = fdopen(fd, "r+");
860 if (!sfp) 944 if (!sfp)
861 bb_perror_msg_and_die(bb_msg_memory_exhausted); 945 bb_perror_msg_and_die(bb_msg_memory_exhausted);
862 } else 946 } else
947#endif
863 sfp = open_socket(lsa); 948 sfp = open_socket(lsa);
864#if SSL_HELPER 949#if ENABLE_FEATURE_WGET_SSL_HELPER
865 if (target.protocol == P_HTTPS) 950 if (target.protocol == P_HTTPS)
866 spawn_https_helper1(fileno(sfp)); 951 spawn_https_helper(fileno(sfp));
867#endif 952#endif
868 /* Send HTTP request */ 953 /* Send HTTP request */
869 if (use_proxy) { 954 if (use_proxy) {