1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00
Commit Graph

3277 Commits

Author SHA1 Message Date
Steve Holme
f5e9c636e8 sws.c: Fixed compilation warning
sws.c:2191 warning: 'rc' may be used uninitialized in this function
2014-12-06 22:18:42 +00:00
Stefan Bühler
557ca620e4 fix gdb libtool invocation path 2014-12-04 14:38:15 -08:00
Peter Wu
970c22f970 libcurl: add UNIX domain sockets support
The ability to do HTTP requests over a UNIX domain socket has been
requested before, in Apr 2008 [0][1] and Sep 2010 [2]. While a
discussion happened, no patch seems to get through. I decided to give it
a go since I need to test a nginx HTTP server which listens on a UNIX
domain socket.

One patch [3] seems to make it possible to use the
CURLOPT_OPENSOCKETFUNCTION function to gain a UNIX domain socket.
Another person wrote a Go program which can do HTTP over a UNIX socket
for Docker[4] which uses a special URL scheme (though the name contains
cURL, it has no relation to the cURL library).

This patch considers support for UNIX domain sockets at the same level
as HTTP proxies / IPv6, it acts as an intermediate socket provider and
not as a separate protocol. Since this feature affects network
operations, a new feature flag was added ("unix-sockets") with a
corresponding CURL_VERSION_UNIX_SOCKETS macro.

A new CURLOPT_UNIX_SOCKET_PATH option is added and documented. This
option enables UNIX domain sockets support for all requests on the
handle (replacing IP sockets and skipping proxies).

A new configure option (--enable-unix-sockets) and CMake option
(ENABLE_UNIX_SOCKETS) can disable this optional feature. Note that I
deliberately did not mark this feature as advanced, this is a
feature/component that should easily be available.

 [0]: http://curl.haxx.se/mail/lib-2008-04/0279.html
 [1]: http://daniel.haxx.se/blog/2008/04/14/http-over-unix-domain-sockets/
 [2]: http://sourceforge.net/p/curl/feature-requests/53/
 [3]: http://curl.haxx.se/mail/lib-2008-04/0361.html
 [4]: https://github.com/Soulou/curl-unix-socket

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-12-04 02:52:19 +01:00
Peter Wu
479abdd32e tests: add two HTTP over UNIX socket tests
test1435: a simple test that checks whether a HTTP request can be
performed over the UNIX socket. The hostname/port are interpreted
by sws and should be ignored by cURL.

test1436: test for the ability to do two requests to the same host,
interleaved with one to a different hostname.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-12-04 02:52:19 +01:00
Peter Wu
f1cc2a2c0c tests: add HTTP UNIX socket server testing support
The variable `$ipvnum` can now contain "unix" besides the integers 4
and 6 since the variable. Functions which receive this parameter
have their `$port` parameter renamed to `$port_or_path` to support a
path to the UNIX domain socket (as a "port" is only meaningful for TCP).

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-12-04 02:52:19 +01:00
Peter Wu
99fb36797a sws: try to remove socket and retry bind
If sws is killed it might leave a stale socket file on the filesystem
which would cause an EADDRINUSE error. After this patch, it is checked
whether the socket is really stale and if so, the socket file gets
removed and another bind is executed.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-12-04 02:52:18 +01:00
Peter Wu
e9c7a86220 sws: add UNIX domain socket support
This extends sws with a --unix-socket option which causes the port to
be ignored (as the server now listens on the path specified by
--unix-socket). This feature will be available in the following patch
that enables checking for UNIX domain socket support.

Proxy support (CONNECT) is not considered nor tested. It does not make
sense anyway, first connecting through a TCP proxy, then let that TCP
proxy connect to a UNIX socket.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-12-04 02:52:18 +01:00
Peter Wu
fb7d7e0022 sws: restrict TCP_NODELAY to IP sockets
TCP_NODELAY does not make sense for Unix sockets, so enable it only if
the socket is using IP.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-12-04 02:52:18 +01:00
Steve Holme
d784000a14 sws.c: Fixed compilation warning when IPv6 is disabled
sws.c:69: warning: comma at end of enumerator list
2014-12-03 00:01:49 +00:00
Peter Wu
cf6c5c222d sws: move away from IPv4/IPv4-only assumption
Instead of depending the socket domain type on use_ipv6, specify the
domain type (AF_INET / AF_INET6) as variable. An enum is used here with
switch to avoid compiler warnings in connect_to, complaining that rc
is possibly undefined (which is not possible as socket_domain is
always set).

Besides abstracting the socket type, make the debugging messages be
independent on IP (introduce location_str which points to "port XXXXX").
Rename "ipv_inuse" to "socket_type" and tighten the scope (main).

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-30 23:21:14 +01:00
Bill Nagel
b359badd49 curl tool: Enable support for the SMB protocol
This patch enables SMB/CIFS support in the curl command-line tool.
2014-11-30 21:32:44 +00:00
Steve Holme
733686e430 tests: Disable test 1013 until SMB is fully added 2014-11-29 21:36:20 +00:00
Peter Wu
86981ac9f5 runtests.pl: fix startup of IPv6 servers
Commit curl-7_23_1-143-g8218064 changed the parameter of
responsive_http_server to accept types other than IPv6 (converting
from a boolean to a string), but only considered the lower-case "ipv6"
and not the "IPv6" variant. This caused all servers to start in IPv4
mode instead.

This patch converts the remaining cases to "ipv6". While not strictly
necessary for the run*server variants, these got also converted for
consistency and to prevent future errors.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-28 23:49:10 +01:00
Peter Wu
bb6047cd64 runtests.pl: fix warning message, remove duplicate value
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-28 23:49:10 +01:00
Steve Holme
c5399c827d tests: Added SMTP with --crlf test case 2014-11-26 23:58:42 +00:00
Daniel Stenberg
9cfa822fea testcurl: bump the version of this script! 2014-11-25 11:22:09 +01:00
Daniel Stenberg
c1e8744177 testcurl: skip reading the setup file if given enough cmdline info
This makes it much easier to run multiple tests in the same directory,
just altering the command lines used.
2014-11-25 10:36:47 +01:00
be1a505189 SSL: Add PEM format support for public key pinning 2014-11-24 19:30:09 +01:00
Steve Holme
85070e46cc runtests.pl: Re-aligned feature support comments 2014-11-22 23:17:59 +00:00
Steve Holme
9ce5e89fcc runtests.pl: Use Kerberos and SPNEGO as proxies for the crypto feature
In addition to NTLM, use Kerberos and SPNEGO as proxies to the crypto
feature.

...and converted tab characters, from commit 4b4e8a5853, to spaces.
2014-11-22 17:14:11 +00:00
Steve Holme
2e2f981bcc runtests.pl: Added support for SPNEGO 2014-11-22 13:52:57 +00:00
Steve Holme
8cc7e74a8f runtests.pl: Added Kerberos detection 2014-11-22 12:26:59 +00:00
Steve Holme
5b437c7637 runtests.pl: Added GSS-API detection 2014-11-22 12:12:42 +00:00
Steve Holme
84d752d1ad FILEFORMAT: Added SSPI, GSS-API and Kerberos to the features list 2014-11-21 18:44:58 +00:00
Steve Holme
10cbc33a4c FILEFORMAT: Added test requires feature not present information
Such as !SSPI as we do for the NTLM and Digest tests.
2014-11-21 18:42:40 +00:00
Daniel Stenberg
4c3cfc7558 test1801: first real http2 test case 2014-11-20 23:33:34 +01:00
Daniel Stenberg
ac5eb7fdfb sws: initial tiny steps toward http2 support 2014-11-20 23:33:34 +01:00
Daniel Stenberg
52655b4c90 FILEFORMAT: mention the new upgrade support 2014-11-20 23:33:34 +01:00
Daniel Stenberg
07e0957e1f test1800: first plain-text http2 test case
Verifies the upgrade request, but gets a plain 1.1 response
2014-11-20 23:33:34 +01:00
Peter Wu
8bdecd3617 test22: expand a backtick command
This is the only user of the backtick operator in the command. As the
commands will soon not be executed by a shell anymore (but by perl),
replace the command with its output.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-13 23:06:44 +01:00
Peter Wu
dd469eec40 symbol-scan.pl: do not require autotools
Makes test1119 pass when building with cmake.

configurehelp.pm is generated by configure (autotools). As cmake does
not provide a separate variable for the C preprocessor, default to cpp.
Before commit ef24ecde68 ("symbol-scan:
use configure script knowledge about how to run the C preprocessor"),
this tool would also use 'cpp'.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-10 09:09:44 +01:00
Peter Wu
17d27805f9 cmake: add ENABLE_THREADED_RESOLVER, rename ARES
Fix detection of the AsynchDNS feature which not just depends on
pthreads support, but also on whether USE_POSIX_THREADS is set or not.
Caught by test 1014.

This patch adds a new ENABLE_THREADED_RESOLVER option (corresponding to
--enable-threaded-resolver of autotools) which also needs a check for
HAVE_PTHREAD_H.

For symmetry with autotools, CURL_USE_ARES is renamed to ENABLE_ARES
(--enable-ares). Checks that test for the availability actually use
USE_ARES instead as that is the result of whether a-res is available or
not (in practice this does not matter as CARES is marked as required
package, but nevertheless it is better to write the intent).

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-10 09:09:25 +01:00
Peter Wu
767aaf587c cmake: build libhostname for test suite
Used by some test cases via LD_PRELOAD in order to fake the host name.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-10 09:08:46 +01:00
Peter Wu
7bdfdd09e4 tests: fix libhostname visibility
I noticed that a patched cmake build would pass tests with a fake local
hostname, but the autotools build skips them:

    got unexpected host name back, LD_PRELOAD failed

It turns out that -fvisibility=hidden hides the symbol, and since the
tests are not part of libcurl, it fails too. Just remove the LIBCURL
guard.

Broken since cURL 7.30 (commit 83a42ee20e,
"curl.h: stricter CURL_EXTERN linkage decorations logic").

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-10 09:06:48 +01:00
Peter Wu
a5ad43afe8 tests: fix memleak in server/resolve.c
This makes LeakSanitizer happy.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-10 09:06:48 +01:00
Dan Fandrich
e2828af607 test552: Don't run HTTP digest tests for SSPI based builds
Technical difficulties prevented this from going into the
previous commit.
2014-11-06 22:31:07 +01:00
Steve Holme
b5c496f109 tests: Don't run HTTP digest tests for SSPI based builds
Added !SSPI to the features list of the HTTP digest tests, as SSPI
based builds now use the Windows SSPI messaging API rather than the
internal functions, and we can't control the random numbers that get
used as part of the digest.
2014-11-06 20:36:08 +00:00
Daniel Stenberg
d997c8b2f6 lib544.c: use duphandle for test 545
To verify that curl_easy_duphandle() works fine on a handle that has
gotten data stored with *_COPYPOSTFIELDS.
2014-11-05 08:05:14 +01:00
Daniel Stenberg
445aab4b73 tests: add new feature 'SSLpinning'
... and make test 2034 and 2035 require it, and have it set when built
with OpenSSL or GnuTLS.
2014-11-04 23:02:09 +01:00
Daniel Stenberg
9bc2582c31 resume: consider a resume from [content-length] to be OK
Basically since servers often then don't respond well to this and
instead send the full contents and then libcurl would instead error out
with the assumption that the server doesn't support resume. As the data
is then already transfered, this is now considered fine.

Test case 1434 added to verify this. Test case 1042 slightly modified.

Reported-by: hugo
Bug: http://curl.haxx.se/bug/view.cgi?id=1443
2014-11-01 23:09:24 +01:00
Daniel Stenberg
95765567d0 HTTP: return larger than 3 digit response codes too
HTTP 1.1 is clearly specified to only allow three digit response codes,
and libcurl used sscanf("%3d") for that purpose. This made libcurl
support smaller numbers but not larger. It does now, but we will not
make any specific promises nor document this further since it is going
outside of what HTTP is.

Bug: http://curl.haxx.se/bug/view.cgi?id=1441
Reported-by: Balaji
2014-10-27 16:28:10 +01:00
Dan Fandrich
382cee0a77 Added the "flaky" keyword to a number of tests
Each shows evidence of flakiness on at least one platform on
the autobuilds. Users can use this keyword to skip these tests
if desired.
2014-10-26 13:50:38 +01:00
Daniel Stenberg
d938d5e6f8 test545: make it not use a trailing zero
CURLOPT_COPYPOSTFIELDS with a given CURLOPT_POSTFIELDSIZE does not
require a trailing zero of the data and by making sure this test doesn't
use one we know it works (combined with valgrind).
2014-10-16 23:40:49 +02:00
Patrick Monnerat
265b9a2e49 vtls: remove QsoSSL 2014-10-13 16:33:47 +02:00
Peter Wu
476499c75c tests: move TESTCASES to Makefile.inc, add show for cmake
This change allows runtests.pl to be run from the CMake builddir:

    export srcdir=/tmp/curl/tests;
    perl -I$srcdir $srcdir/runtests.pl -l

In order to make this possible, all test cases have been moved from
Makefile.am to Makefile.inc.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-10-13 11:50:21 +02:00
Peter Wu
87a3a924ce tests/http_pipe.py: Python 3 support
The 2to3 tool converted socketserver (which I manually fixed up with an
import fallback) and the print(e) line. The xrange option was converted
to range, but it seems better to use the '*' operator here for
simplicity.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-10-10 16:58:20 +02:00
Daniel Stenberg
bf7023d165 test2036: verify -O with no slash at all in the URL
Similar to test 76 but that test's URL has a slash just no file name
part.
2014-10-09 16:50:26 +02:00
Jakub Zakrzewski
a3154295c5 Cmake: Got rid of setup_curl_dependencies
There is no need for such function. Include_directories propagate by
themselves and having a function with one simple link statement makes
little sense.
2014-10-09 13:48:30 +02:00
93e450793c SSL: implement public key pinning
Option --pinnedpubkey takes a path to a public key in DER format and
only connect if it matches (currently only implemented with OpenSSL).

Provides CURLOPT_PINNEDPUBLICKEY for curl_easy_setopt().

Extract a public RSA key from a website like so:
openssl s_client -connect google.com:443 2>&1 < /dev/null | \
sed -n '/-----BEGIN/,/-----END/p' | openssl x509 -noout -pubkey \
| openssl rsa -pubin -outform DER > google.com.der
2014-10-07 14:44:19 +02:00
Dan Fandrich
46d71e7fd2 test506: Fixed a couple of memory leaks in test 2014-09-26 06:57:52 +02:00