From b5c3feda1788301bea7f1dd4f9bb240d13862bd0 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Fri, 30 Jul 2010 00:47:49 +0200 Subject: [PATCH] NTLM tests: boost coverage by forcing the hostname A shared library tests/libtest/.libs/lihostname.so is preloaded in NTLM test-cases to override the system implementation of gethostname(). It makes it possible to test the NTLM authentication for exact match, and this way test the implementation of MD4 and DES. If LD_PRELOAD doesn't work, a debug build willl also workk as debug builds are now made to prefer a specific environment variable and will then return that content as host name instead of the actual one. Kamil wrote the bulk of this, Daniel Stenberg polished it. --- lib/Makefile.inc | 4 +-- lib/curl_gethostname.c | 52 +++++++++++++++++++++++++++++ lib/curl_gethostname.h | 34 +++++++++++++++++++ lib/http_ntlm.c | 3 +- lib/smtp.c | 7 ++-- tests/data/test1008 | 16 +++++---- tests/data/test1021 | 16 +++++---- tests/data/test1100 | 16 +++++---- tests/data/test150 | 16 +++++---- tests/data/test155 | 16 +++++---- tests/data/test159 | 16 +++++---- tests/data/test169 | 16 +++++---- tests/data/test209 | 16 +++++---- tests/data/test213 | 16 +++++---- tests/data/test239 | 16 +++++---- tests/data/test243 | 16 +++++---- tests/data/test265 | 16 +++++---- tests/data/test267 | 16 +++++---- tests/data/test547 | 16 +++++---- tests/data/test548 | 16 +++++---- tests/data/test551 | 5 --- tests/data/test555 | 14 +++++--- tests/data/test67 | 16 +++++---- tests/data/test68 | 16 +++++---- tests/data/test69 | 16 +++++---- tests/data/test81 | 16 +++++---- tests/data/test89 | 18 ++++++---- tests/data/test90 | 18 ++++++---- tests/data/test91 | 16 +++++---- tests/libtest/.gitignore | 2 +- tests/libtest/Makefile.am | 10 ++++++ tests/libtest/Makefile.inc | 4 ++- tests/libtest/chkhostname.c | 26 +++++++++++++++ tests/libtest/hostname.c | 32 ++++++++++++++++++ tests/libtest/sethostname.c | 28 ++++++++++++++++ tests/runtests.pl | 80 +++++++++++++++++++++++++++++++-------------- 36 files changed, 481 insertions(+), 176 deletions(-) create mode 100644 lib/curl_gethostname.c create mode 100644 lib/curl_gethostname.h create mode 100644 tests/libtest/chkhostname.c create mode 100644 tests/libtest/hostname.c create mode 100644 tests/libtest/sethostname.c diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 17e2d36..bfd3abe 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -20,7 +20,7 @@ CSOURCES = file.c timeval.c base64.c hostip.c progress.c formdata.c \ strdup.c socks.c ssh.c nss.c qssl.c rawstr.c curl_addrinfo.c \ socks_gssapi.c socks_sspi.c curl_sspi.c slist.c nonblock.c \ curl_memrchr.c imap.c pop3.c smtp.c pingpong.c rtsp.c curl_threads.c \ - warnless.c hmac.c polarssl.c curl_rtmp.c openldap.c + warnless.c hmac.c polarssl.c curl_rtmp.c openldap.c curl_gethostname.c HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h \ progress.h formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h \ @@ -34,5 +34,5 @@ HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h \ tftp.h sockaddr.h splay.h strdup.h setup_once.h socks.h ssh.h nssg.h \ curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h slist.h nonblock.h \ curl_memrchr.h imap.h pop3.h smtp.h pingpong.h rtsp.h curl_threads.h \ - warnless.h curl_hmac.h polarssl.h curl_rtmp.h + warnless.h curl_hmac.h polarssl.h curl_rtmp.h curl_gethostname.h diff --git a/lib/curl_gethostname.c b/lib/curl_gethostname.c new file mode 100644 index 0000000..5a8c649 --- /dev/null +++ b/lib/curl_gethostname.c @@ -0,0 +1,52 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "setup.h" +#include "curl_gethostname.h" + +#include +#include +#include + +#define GETHOSTNAME_ENV_VAR "CURL_GETHOSTNAME" + +int Curl_gethostname(char *name, size_t namelen) { +#ifdef HAVE_GETHOSTNAME + +#ifdef CURLDEBUG + /* we check the environment variable only in case of debug build */ + const char *force_hostname = getenv(GETHOSTNAME_ENV_VAR); + if(force_hostname) { + strncpy(name, force_hostname, namelen); + return 0; + } +#endif + /* no override requested */ + return gethostname(name, namelen); + +#else + /* no gethostname() available on system, we should always fail */ + (void) name; + (void) namelen; + return -1; +#endif +} diff --git a/lib/curl_gethostname.h b/lib/curl_gethostname.h new file mode 100644 index 0000000..0e393af --- /dev/null +++ b/lib/curl_gethostname.h @@ -0,0 +1,34 @@ +#ifndef HEADER_CURL_GETHOSTNAME_H +#define HEADER_CURL_GETHOSTNAME_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "setup.h" + +/* wrapper around gethostname(), which makes it possible to override the + * returned value during testing. It reads the value of CURL_GETHOSTNAME + * environment variable when built with --enable-curldebug. The function always + * returns -1, if gethostname() is not available on system. + */ +int Curl_gethostname(char *name, size_t namelen); + +#endif /* HEADER_CURL_GETHOSTNAME_H */ diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c index 0e831ca..f5b696a 100644 --- a/lib/http_ntlm.c +++ b/lib/http_ntlm.c @@ -58,6 +58,7 @@ #include "curl_base64.h" #include "http_ntlm.h" #include "url.h" +#include "curl_gethostname.h" #include "curl_memory.h" #define _MPRINTF_REPLACE /* use our functions only */ @@ -994,7 +995,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, user = userp; userlen = strlen(user); - if(gethostname(host, HOSTNAME_MAX)) { + if(Curl_gethostname(host, HOSTNAME_MAX)) { infof(conn->data, "gethostname() failed, continuing without!"); hostlen = 0; } diff --git a/lib/smtp.c b/lib/smtp.c index edc3ff6..1133fe5 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -91,6 +91,7 @@ #include "curl_base64.h" #include "curl_md5.h" #include "curl_hmac.h" +#include "curl_gethostname.h" #define _MPRINTF_REPLACE /* use our functions only */ #include @@ -1110,12 +1111,10 @@ static CURLcode smtp_connect(struct connectdata *conn, pp->conn = conn; if(!*path) { -#ifdef HAVE_GETHOSTNAME - if(!gethostname(localhost, sizeof localhost)) + if(!Curl_gethostname(localhost, sizeof localhost)) path = localhost; else -#endif - path = "localhost"; + path = "localhost"; } /* url decode the path and use it as domain with EHLO */ diff --git a/tests/data/test1008 b/tests/data/test1008 index 6154446..563a5c0 100644 --- a/tests/data/test1008 +++ b/tests/data/test1008 @@ -86,9 +86,18 @@ NTLM HTTP proxy CONNECT auth NTLM with chunked-encoded 407 response + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://test.remote.haxx.se:1008/path/10080002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -96,11 +105,6 @@ http://test.remote.haxx.se:1008/path/10080002 --proxy http://%HOSTIP:%HTTPPORT - ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ - CONNECT test.remote.haxx.se:1008 HTTP/1.1 Host: test.remote.haxx.se:1008 @@ -109,7 +113,7 @@ Proxy-Connection: Keep-Alive CONNECT test.remote.haxx.se:1008 HTTP/1.1 Host: test.remote.haxx.se:1008 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q= Proxy-Connection: Keep-Alive GET /path/10080002 HTTP/1.1 diff --git a/tests/data/test1021 b/tests/data/test1021 index 233cbc4..0bc8af3 100644 --- a/tests/data/test1021 +++ b/tests/data/test1021 @@ -95,9 +95,18 @@ NTLM HTTP proxy CONNECT with any proxyauth and proxy offers NTLM and close + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://test.remote.haxx.se:1021/path/10210002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-anyauth --proxytunnel + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -105,11 +114,6 @@ http://test.remote.haxx.se:1021/path/10210002 --proxy http://%HOSTIP:%HTTPPORT - ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ - CONNECT test.remote.haxx.se:1021 HTTP/1.1 Host: test.remote.haxx.se:1021 @@ -122,7 +126,7 @@ Proxy-Connection: Keep-Alive CONNECT test.remote.haxx.se:1021 HTTP/1.1 Host: test.remote.haxx.se:1021 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q= Proxy-Connection: Keep-Alive GET /path/10210002 HTTP/1.1 diff --git a/tests/data/test1100 b/tests/data/test1100 index 40d9f64..00bd644 100644 --- a/tests/data/test1100 +++ b/tests/data/test1100 @@ -70,9 +70,18 @@ http HTTP POST with NTLM authorization and following a 302 redirect + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/1100 -u testuser:testpass --ntlm -L -d "stuff to send away" + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -80,11 +89,6 @@ http://%HOSTIP:%HTTPPORT/1100 -u testuser:testpass --ntlm -L -d "stuff to send a ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - POST /1100 HTTP/1.1 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= @@ -95,7 +99,7 @@ Content-Length: 0 Content-Type: application/x-www-form-urlencoded POST /1100 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test150 b/tests/data/test150 index 8dcb362..fc922e2 100644 --- a/tests/data/test150 +++ b/tests/data/test150 @@ -57,9 +57,18 @@ http HTTP with NTLM authorization and --fail + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/150 -u testuser:testpass --ntlm --fail + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -67,11 +76,6 @@ http://%HOSTIP:%HTTPPORT/150 -u testuser:testpass --ntlm --fail ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - GET /150 HTTP/1.1 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= @@ -80,7 +84,7 @@ Host: %HOSTIP:%HTTPPORT Accept: */* GET /150 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test155 b/tests/data/test155 index 5d228db..53ee1db 100644 --- a/tests/data/test155 +++ b/tests/data/test155 @@ -75,9 +75,18 @@ http HTTP PUT with --anyauth authorization (picking NTLM) + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/155 -T log/put155 -u testuser:testpass --anyauth + +chkhostname curlhost + This is data we upload with PUT a second line @@ -91,11 +100,6 @@ four is the number of lines ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - PUT /155 HTTP/1.1 Host: %HOSTIP:%HTTPPORT @@ -111,7 +115,7 @@ Content-Length: 0 Expect: 100-continue PUT /155 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.5 (i686-pc-linux-gnu) libcurl/7.10.5 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test159 b/tests/data/test159 index 3b01821..ede4624 100644 --- a/tests/data/test159 +++ b/tests/data/test159 @@ -56,9 +56,18 @@ http HTTP with NTLM authorization when talking HTTP/1.0 + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/159 -u testuser:testpass --ntlm -0 + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -66,11 +75,6 @@ http://%HOSTIP:%HTTPPORT/159 -u testuser:testpass --ntlm -0 ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - GET /159 HTTP/1.0 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= @@ -79,7 +83,7 @@ Host: %HOSTIP:%HTTPPORT Accept: */* GET /159 HTTP/1.0 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test169 b/tests/data/test169 index 0ad2f88..5af7f9f 100644 --- a/tests/data/test169 +++ b/tests/data/test169 @@ -81,9 +81,18 @@ NTLM HTTP with proxy-requiring-NTLM to site-requiring-Digest + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://data.from.server.requiring.digest.hohoho.com/169 --proxy http://%HOSTIP:%HTTPPORT --proxy-user foo:bar --proxy-ntlm --digest --user digest:alot + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -91,11 +100,6 @@ http://data.from.server.requiring.digest.hohoho.com/169 --proxy http://%HOSTIP:% ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAAAwADAHAAAAA).*/$1/ - GET http://data.from.server.requiring.digest.hohoho.com/169 HTTP/1.1 Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= @@ -105,7 +109,7 @@ Accept: */* Proxy-Connection: Keep-Alive GET http://data.from.server.requiring.digest.hohoho.com/169 HTTP/1.1 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAAAwADAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAAAwADAHAAAAAIAAgAcwAAAAAAAAAAAAAABoKBAIP6B+XVQ6vQsx3DfDXUVhd9436GAxPu0IYcl2Z7LxHmNeOAWQ+vxUmhuCFJBUgXCWZvb2N1cmxob3N0 User-Agent: curl/7.12.0-CVS (i686-pc-linux-gnu) libcurl/7.12.0-CVS OpenSSL/0.9.6b ipv6 zlib/1.1.4 GSS libidn/0.4.3 Host: data.from.server.requiring.digest.hohoho.com Accept: */* diff --git a/tests/data/test209 b/tests/data/test209 index ef372c4..e27b6e3 100644 --- a/tests/data/test209 +++ b/tests/data/test209 @@ -79,9 +79,18 @@ NTLM HTTP proxy CONNECT auth NTLM + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://test.remote.haxx.se:209/path/2090002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -89,11 +98,6 @@ http://test.remote.haxx.se:209/path/2090002 --proxy http://%HOSTIP:%HTTPPORT --p ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ - CONNECT test.remote.haxx.se:209 HTTP/1.1 Host: test.remote.haxx.se:209 @@ -102,7 +106,7 @@ Proxy-Connection: Keep-Alive CONNECT test.remote.haxx.se:209 HTTP/1.1 Host: test.remote.haxx.se:209 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q= Proxy-Connection: Keep-Alive GET /path/2090002 HTTP/1.1 diff --git a/tests/data/test213 b/tests/data/test213 index 801d9e7..8bab387 100644 --- a/tests/data/test213 +++ b/tests/data/test213 @@ -79,9 +79,18 @@ NTLM HTTP 1.0 proxy CONNECT auth NTLM and then POST + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://test.remote.haxx.se:213/path/2130002 --proxy1.0 http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel -d "postit" + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -89,11 +98,6 @@ http://test.remote.haxx.se:213/path/2130002 --proxy1.0 http://%HOSTIP:%HTTPPORT ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ - CONNECT test.remote.haxx.se:213 HTTP/1.0 Host: test.remote.haxx.se:213 @@ -102,7 +106,7 @@ Proxy-Connection: Keep-Alive CONNECT test.remote.haxx.se:213 HTTP/1.0 Host: test.remote.haxx.se:213 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q= Proxy-Connection: Keep-Alive POST /path/2130002 HTTP/1.1 diff --git a/tests/data/test239 b/tests/data/test239 index 2674b8e..e889089 100644 --- a/tests/data/test239 +++ b/tests/data/test239 @@ -56,9 +56,18 @@ NTLM HTTP proxy-auth NTLM and then POST + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/239 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm -d "postit" + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -66,11 +75,6 @@ http://%HOSTIP:%HTTPPORT/239 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ - POST http://%HOSTIP:%HTTPPORT/239 HTTP/1.1 Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= @@ -82,7 +86,7 @@ Content-Length: 0 Content-Type: application/x-www-form-urlencoded POST http://%HOSTIP:%HTTPPORT/239 HTTP/1.1 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q= User-Agent: curl/7.13.2-CVS (i686-pc-linux-gnu) libcurl/7.13.2-CVS OpenSSL/0.9.7e zlib/1.2.2 libidn/0.5.13 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test243 b/tests/data/test243 index f24fd77..3effb82 100644 --- a/tests/data/test243 +++ b/tests/data/test243 @@ -77,9 +77,18 @@ NTLM HTTP POST with --proxy-anyauth, picking NTLM + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/243 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-anyauth -d "postit" + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -87,11 +96,6 @@ http://%HOSTIP:%HTTPPORT/243 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ - POST http://%HOSTIP:%HTTPPORT/243 HTTP/1.1 User-Agent: curl/7.13.2-CVS (i686-pc-linux-gnu) libcurl/7.13.2-CVS OpenSSL/0.9.7e zlib/1.2.2 libidn/0.5.13 @@ -111,7 +115,7 @@ Content-Length: 0 Content-Type: application/x-www-form-urlencoded POST http://%HOSTIP:%HTTPPORT/243 HTTP/1.1 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q= User-Agent: curl/7.13.2-CVS (i686-pc-linux-gnu) libcurl/7.13.2-CVS OpenSSL/0.9.7e zlib/1.2.2 libidn/0.5.13 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test265 b/tests/data/test265 index bd8a24c..e47dbe8 100644 --- a/tests/data/test265 +++ b/tests/data/test265 @@ -82,9 +82,18 @@ NTLM HTTP proxy CONNECT auth NTLM and then POST, response-body in the 407 + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://test.remote.haxx.se:265/path/2650002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel -d "postit" + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -92,11 +101,6 @@ http://test.remote.haxx.se:265/path/2650002 --proxy http://%HOSTIP:%HTTPPORT --p ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ - CONNECT test.remote.haxx.se:265 HTTP/1.1 Host: test.remote.haxx.se:265 @@ -105,7 +109,7 @@ Proxy-Connection: Keep-Alive CONNECT test.remote.haxx.se:265 HTTP/1.1 Host: test.remote.haxx.se:265 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q= Proxy-Connection: Keep-Alive POST /path/2650002 HTTP/1.1 diff --git a/tests/data/test267 b/tests/data/test267 index 4e356b6..aa61b35 100644 --- a/tests/data/test267 +++ b/tests/data/test267 @@ -63,9 +63,18 @@ http HTTP POST with NTLM authorization and added custom headers + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/267 -u testuser:testpass --ntlm -d "data" -H "Header1: yes" -H "Header2: no" + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -73,11 +82,6 @@ http://%HOSTIP:%HTTPPORT/267 -u testuser:testpass --ntlm -d "data" -H "Header1: ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - POST /267 HTTP/1.1 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= @@ -90,7 +94,7 @@ Content-Length: 0 Content-Type: application/x-www-form-urlencoded POST /267 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test547 b/tests/data/test547 index d2e9d9e..8ac0c9d 100644 --- a/tests/data/test547 +++ b/tests/data/test547 @@ -80,9 +80,18 @@ NTLM HTTP proxy auth NTLM with POST data from read callback + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://test.remote.haxx.se/path/547 http://%HOSTIP:%HTTPPORT s1lly:pers0n + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -90,11 +99,6 @@ http://test.remote.haxx.se/path/547 http://%HOSTIP:%HTTPPORT s1lly:pers0n ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ - POST http://test.remote.haxx.se/path/547 HTTP/1.1 User-Agent: curl/7.13.2-CVS (i686-pc-linux-gnu) libcurl/7.13.2-CVS OpenSSL/0.9.7e zlib/1.2.2 libidn/0.5.13 @@ -115,7 +119,7 @@ Content-Length: 0 Content-Type: application/x-www-form-urlencoded POST http://test.remote.haxx.se/path/547 HTTP/1.1 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAIYrD1xJmhNBNL9fLzuk9PV9436GAxPu0EKWzqQ/sZDVLXnp1JrySgl8A+cibE6z4HMxbGx5Y3VybGhvc3Q= User-Agent: curl/7.13.2-CVS (i686-pc-linux-gnu) libcurl/7.13.2-CVS OpenSSL/0.9.7e zlib/1.2.2 libidn/0.5.13 Host: test.remote.haxx.se Accept: */* diff --git a/tests/data/test548 b/tests/data/test548 index 215b44f..d811fca 100644 --- a/tests/data/test548 +++ b/tests/data/test548 @@ -80,9 +80,18 @@ NTLM HTTP proxy auth NTLM with POST data from CURLOPT_POSTFIELDS + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://test.remote.haxx.se/path/548 http://%HOSTIP:%HTTPPORT s1lly:pers0n + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -90,11 +99,6 @@ http://test.remote.haxx.se/path/548 http://%HOSTIP:%HTTPPORT s1lly:pers0n ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ - POST http://test.remote.haxx.se/path/548 HTTP/1.1 User-Agent: curl/7.13.2-CVS (i686-pc-linux-gnu) libcurl/7.13.2-CVS OpenSSL/0.9.7e zlib/1.2.2 libidn/0.5.13 @@ -115,7 +119,7 @@ Content-Length: 0 Content-Type: application/x-www-form-urlencoded POST http://test.remote.haxx.se/path/548 HTTP/1.1 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAIYrD1xJmhNBNL9fLzuk9PV9436GAxPu0EKWzqQ/sZDVLXnp1JrySgl8A+cibE6z4HMxbGx5Y3VybGhvc3Q= User-Agent: curl/7.13.2-CVS (i686-pc-linux-gnu) libcurl/7.13.2-CVS OpenSSL/0.9.7e zlib/1.2.2 libidn/0.5.13 Host: test.remote.haxx.se Accept: */* diff --git a/tests/data/test551 b/tests/data/test551 index 28b5af5..8027d91 100644 --- a/tests/data/test551 +++ b/tests/data/test551 @@ -75,11 +75,6 @@ http://test.remote.haxx.se/path/551 http://%HOSTIP:%HTTPPORT s1lly:pers0n ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ - POST http://test.remote.haxx.se/path/551 HTTP/1.1 Host: test.remote.haxx.se diff --git a/tests/data/test555 b/tests/data/test555 index d433569..74dc210 100644 --- a/tests/data/test555 +++ b/tests/data/test555 @@ -85,9 +85,18 @@ NTLM HTTP proxy auth NTLM with POST data from read callback multi-if + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://test.remote.haxx.se/path/555 http://%HOSTIP:%HTTPPORT s1lly:pers0n + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -95,10 +104,7 @@ http://test.remote.haxx.se/path/555 http://%HOSTIP:%HTTPPORT s1lly:pers0n ^User-Agent: curl/.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! -s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/ # remove CR that CURLOPT_TRANSFERTEXT added, when CharConv enabled: s/^(this is the blurb we want to upload)\r\n/$1\n/ if($has_charconv) @@ -122,7 +128,7 @@ Content-Length: 0 Content-Type: application/x-www-form-urlencoded POST http://test.remote.haxx.se/path/555 HTTP/1.1 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAIYrD1xJmhNBNL9fLzuk9PV9436GAxPu0EKWzqQ/sZDVLXnp1JrySgl8A+cibE6z4HMxbGx5Y3VybGhvc3Q= User-Agent: curl/7.13.2-CVS (i686-pc-linux-gnu) libcurl/7.13.2-CVS OpenSSL/0.9.7e zlib/1.2.2 libidn/0.5.13 Host: test.remote.haxx.se Accept: */* diff --git a/tests/data/test67 b/tests/data/test67 index 46d120b..d6d60ef 100644 --- a/tests/data/test67 +++ b/tests/data/test67 @@ -63,9 +63,18 @@ http HTTP with NTLM authorization + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/67 -u testuser:testpass --ntlm + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -73,11 +82,6 @@ http://%HOSTIP:%HTTPPORT/67 -u testuser:testpass --ntlm ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - GET /67 HTTP/1.1 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= @@ -86,7 +90,7 @@ Host: %HOSTIP:%HTTPPORT Accept: */* GET /67 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test68 b/tests/data/test68 index 9cceaf7..5b79a7a 100644 --- a/tests/data/test68 +++ b/tests/data/test68 @@ -62,9 +62,18 @@ http HTTP with NTLM authorization and wrong password + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/68 -u testuser:testpass --ntlm + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -72,11 +81,6 @@ http://%HOSTIP:%HTTPPORT/68 -u testuser:testpass --ntlm ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - GET /68 HTTP/1.1 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= @@ -85,7 +89,7 @@ Host: %HOSTIP:%HTTPPORT Accept: */* GET /68 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test69 b/tests/data/test69 index 1bf0f73..d6b8de6 100644 --- a/tests/data/test69 +++ b/tests/data/test69 @@ -79,9 +79,18 @@ http HTTP with NTLM, Basic or Wild-and-crazy authorization + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/69 -u testuser:testpass --anyauth + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -89,11 +98,6 @@ http://%HOSTIP:%HTTPPORT/69 -u testuser:testpass --anyauth ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - GET /69 HTTP/1.1 User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 @@ -107,7 +111,7 @@ Host: %HOSTIP:%HTTPPORT Accept: */* GET /69 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test81 b/tests/data/test81 index 9a12cc1..47b37e9 100644 --- a/tests/data/test81 +++ b/tests/data/test81 @@ -62,9 +62,18 @@ http HTTP with proxy using NTLM authorization + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/81 --proxy-user testuser:testpass -x http://%HOSTIP:%HTTPPORT --proxy-ntlm + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -72,11 +81,6 @@ http://%HOSTIP:%HTTPPORT/81 --proxy-user testuser:testpass -x http://%HOSTIP:%HT ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - GET http://%HOSTIP:%HTTPPORT/81 HTTP/1.1 Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= @@ -86,7 +90,7 @@ Accept: */* Proxy-Connection: Keep-Alive GET http://%HOSTIP:%HTTPPORT/81 HTTP/1.1 -Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test89 b/tests/data/test89 index 06effd1..3512fbe 100644 --- a/tests/data/test89 +++ b/tests/data/test89 @@ -96,9 +96,18 @@ http HTTP with NTLM and follow-location + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/89 -u testuser:testpass --ntlm -L + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -106,11 +115,6 @@ http://%HOSTIP:%HTTPPORT/89 -u testuser:testpass --ntlm -L ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - GET /89 HTTP/1.1 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= @@ -119,7 +123,7 @@ Host: %HOSTIP:%HTTPPORT Accept: */* GET /89 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* @@ -131,7 +135,7 @@ Host: %HOSTIP:%HTTPPORT Accept: */* GET /you/890010 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.8-pre1 (i686-pc-linux-gnu) libcurl/7.10.8-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 GSS Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test90 b/tests/data/test90 index 387608b..55c98f4 100644 --- a/tests/data/test90 +++ b/tests/data/test90 @@ -134,9 +134,18 @@ http HTTP with NTLM via --anyauth, and then follow-location with NTLM again + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/90 -u testuser:testpass --anyauth -L + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -144,11 +153,6 @@ http://%HOSTIP:%HTTPPORT/90 -u testuser:testpass --anyauth -L ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/ - GET /90 HTTP/1.1 Host: %HOSTIP:%HTTPPORT @@ -161,7 +165,7 @@ Host: %HOSTIP:%HTTPPORT Accept: */* GET /90 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* @@ -177,7 +181,7 @@ Host: %HOSTIP:%HTTPPORT Accept: */* GET /you/900010 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= User-Agent: curl/7.10.8-pre1 (i686-pc-linux-gnu) libcurl/7.10.8-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 GSS Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test91 b/tests/data/test91 index e3b81b3..90ace92 100644 --- a/tests/data/test91 +++ b/tests/data/test91 @@ -80,9 +80,18 @@ http HTTP with NTLM/Negotiate/Basic, anyauth and user with domain, with size 0 + +# we force our own host name, in order to make the test machine independent +CURL_GETHOSTNAME=curlhost +# we try to use the LD_PRELOAD hack, if not a debug build +LD_PRELOAD=./libtest/.libs/libhostname.so + http://%HOSTIP:%HTTPPORT/91 --anyauth -u mydomain\\myself:secret + +chkhostname curlhost + # Verify data after the test has been "shot" @@ -90,11 +99,6 @@ http://%HOSTIP:%HTTPPORT/91 --anyauth -u mydomain\\myself:secret ^User-Agent:.* -# We strip off a large chunk of the type-2 NTLM message since it depends on -# the local host name and thus differs on different machines! - -s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAgACABwAAAABgAGAHgAAAA).*/$1/ - GET /91 HTTP/1.1 User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 @@ -108,7 +112,7 @@ Host: %HOSTIP:%HTTPPORT Accept: */* GET /91 HTTP/1.1 -Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAgACABwAAAABgAGAHgAAAA +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAgACABwAAAABgAGAHgAAAAIAAgAfgAAAAAAAAAAAAAABoKBAMIyJpR5mHpg2FZha5kRaFZ9436GAxPu0C5llxexSQ5QzVkiLSfkcpVyRgCXXqR+Am15ZG9tYWlubXlzZWxmY3VybGhvc3Q= User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore index 3311a82..cabcb67 100644 --- a/tests/libtest/.gitignore +++ b/tests/libtest/.gitignore @@ -1,2 +1,2 @@ +chkhostname lib5[0-9][0-9] - diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 70b0f12..2a0e3ea 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -53,6 +53,16 @@ endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ test1022.pl Makefile.inc +if STATICLIB +# this means no shared option is enabled so we can disable the LD_PRELOAD +# attempt +libhostname_la_CFLAGS = -DDISABLE_PRELOAD +endif + +# we force our own host name, in order to make some tests machine independent +lib_LTLIBRARIES = libhostname.la +libhostname_la_SOURCES = sethostname.c + # Dependencies (may need to be overriden) LDADD = $(top_builddir)/lib/libcurl.la DEPENDENCIES = $(top_builddir)/lib/libcurl.la diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 814c01e..28ed683 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -12,7 +12,9 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ - lib568 lib569 lib570 lib571 lib572 lib573 + lib568 lib569 lib570 lib571 lib572 lib573 chkhostname + +chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c lib500_SOURCES = lib500.c $(SUPPORTFILES) diff --git a/tests/libtest/chkhostname.c b/tests/libtest/chkhostname.c new file mode 100644 index 0000000..686eb47 --- /dev/null +++ b/tests/libtest/chkhostname.c @@ -0,0 +1,26 @@ +#include "curl_gethostname.h" + +#include + +#define HOSTNAME_MAX 1024 + +int main(int argc, char *argv[]) +{ + char buff[HOSTNAME_MAX]; + if (argc != 2) { + printf("Usage: %s EXPECTED_HOSTNAME\n", argv[0]); + return 1; + } + + if (Curl_gethostname(buff, HOSTNAME_MAX)) { + printf("Curl_gethostname() failed\n"); + return 1; + } + + /* compare the name returned by Curl_gethostname() with the expected one */ + if(strncmp(buff, argv[1], HOSTNAME_MAX)) { + printf("got unexpected host name back, LD_PRELOAD failed\n"); + return 1; + } + return 0; +} diff --git a/tests/libtest/hostname.c b/tests/libtest/hostname.c new file mode 100644 index 0000000..ca7fcca --- /dev/null +++ b/tests/libtest/hostname.c @@ -0,0 +1,32 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include +#include + +#define HOSTNAME "curlhost" +#define HOSTNAME_LEN sizeof(HOSTNAME) + +/* + * we force our own host name, in order to make some tests machine independent + */ +int gethostname(char *name, size_t namelen) { + char buff[HOSTNAME_LEN + /* terminating zero */ 1]; + size_t max = (namelen < HOSTNAME_LEN) + ? namelen + : HOSTNAME_LEN; + + if(!name || !namelen) + return -1; + + strcpy(buff, HOSTNAME); + buff[max - 1] = '\0'; + strcpy(name, buff); + return 0; +}; diff --git a/tests/libtest/sethostname.c b/tests/libtest/sethostname.c new file mode 100644 index 0000000..667f689 --- /dev/null +++ b/tests/libtest/sethostname.c @@ -0,0 +1,28 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include +#include +#include + +#define GETHOSTNAME_ENV_VAR "CURL_GETHOSTNAME" + +/* + * we force our own host name, in order to make some tests machine independent + */ +int gethostname(char *name, size_t namelen) { + const char *force_hostname = getenv(GETHOSTNAME_ENV_VAR); + if(force_hostname) { + strncpy(name, force_hostname, namelen); + return 0; + } + + /* LD_PRELOAD used, but no hostname set, we'll just return a failure */ + return -1; +}; diff --git a/tests/runtests.pl b/tests/runtests.pl index 6abca9f..8bb5d69 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -148,6 +148,7 @@ my $SERVER2IN="$LOGDIR/server2.input"; # what curl sent the second server my $CURLLOG="$LOGDIR/curl.log"; # all command lines run my $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy ftp server instructions here my $SERVERLOGS_LOCK="$LOGDIR/serverlogs.lock"; # server logs advisor read lock +my $CURLCONFIG="../curl-config"; # curl-config from current build # Normally, all test cases should be run, but at times it is handy to # simply run a particular one: @@ -204,6 +205,8 @@ my $has_nss; # built with NSS my $has_yassl; # built with yassl my $has_polarssl;# built with polarssl +my $has_shared; # built shared + my $ssllib; # name of the lib we use (for human presentation) my $has_crypto; # set if libcurl is built with cryptographic support my $has_textaware; # set if running on a system that has a text mode concept @@ -436,7 +439,8 @@ sub startnew { sub checkcmd { my ($cmd)=@_; my @paths=(split(":", $ENV{'PATH'}), "/usr/sbin", "/usr/local/sbin", - "/sbin", "/usr/bin", "/usr/local/bin" ); + "/sbin", "/usr/bin", "/usr/local/bin", + "./libtest/.libs", "./libtest"); for(@paths) { if( -x "$_/$cmd" && ! -d "$_/$cmd") { # executable bit but not a directory! @@ -2042,6 +2046,9 @@ sub checksystem { die "can't run torture tests since curl was not built with curldebug"; } + $has_shared = `sh $CURLCONFIG --built-shared`; + chomp $has_shared; + # curl doesn't list cryptographic support separately, so assume it's # always available $has_crypto=1; @@ -2064,8 +2071,9 @@ sub checksystem { logmsg sprintf(" HTTP IPv6 %s\n", $http_ipv6?"ON ":"OFF"); logmsg sprintf("* FTP IPv6 %8s", $ftp_ipv6?"ON ":"OFF"); logmsg sprintf(" Libtool lib: %s\n", $libtool?"ON ":"OFF"); + logmsg sprintf("* Shared build: %s\n", $has_shared); if($ssl_version) { - logmsg sprintf("* SSL library: %s\n", $ssllib); + logmsg sprintf("* SSL library: %13s\n", $ssllib); } logmsg "* Ports:\n"; @@ -2350,13 +2358,59 @@ sub singletest { # timestamp required servers verification end $timesrvrend{$testnum} = Time::HiRes::time() if($timestats); + # test definition may instruct to (un)set environment vars + # this is done this early, so that the precheck can use environment + # variables and still bail out fine on errors + my %oldenv; + my @setenv = getpart("client", "setenv"); + if(@setenv) { + foreach my $s (@setenv) { + chomp $s; + subVariables \$s; + if($s =~ /([^=]*)=(.*)/) { + my ($var, $content) = ($1, $2); + # remember current setting, to restore it once test runs + $oldenv{$var} = ($ENV{$var})?"$ENV{$var}":'notset'; + # set new value + if(!$content) { + delete $ENV{$var} if($ENV{$var}); + } + else { + if(($has_shared ne "yes") && ($var =~ /^LD_PRELOAD/)) { + # print "Skipping LD_PRELOAD due to no shared build\n"; + next; + } + $ENV{$var} = "$content"; + } + } + } + } + if(!$why) { + # TODO: + # Add a precheck cache. If a precheck command was already invoked + # exactly like this, then use the previous result to speed up + # successive test invokes! + my @precheck = getpart("client", "precheck"); if(@precheck) { $cmd = $precheck[0]; chomp $cmd; subVariables \$cmd; if($cmd) { + my @p = split(/ /, $cmd); + if($p[0] !~ /\//) { + # the first word, the command, does not contain a slash so + # we will scan the "improved" PATH to find the command to + # be able to run it + my $fullp = checktestcmd($p[0]); + + if($fullp) { + $p[0] = $fullp; + } + $cmd = join(" ", @p); + } + my @o = `$cmd 2>/dev/null`; if($o[0]) { $why = $o[0]; @@ -2453,28 +2507,6 @@ sub singletest { writearray($FTPDCMD, \@ftpservercmd); } - # test definition may instruct to (un)set environment vars - my %oldenv; - my @setenv = getpart("client", "setenv"); - if(@setenv) { - foreach my $s (@setenv) { - chomp $s; - subVariables \$s; - if($s =~ /([^=]*)=(.*)/) { - my ($var, $content) = ($1, $2); - # remember current setting, to restore it once test runs - $oldenv{$var} = ($ENV{$var})?"$ENV{$var}":'notset'; - # set new value - if(!$content) { - delete $ENV{$var} if($ENV{$var}); - } - else { - $ENV{$var} = "$content"; - } - } - } - } - # get the command line options to use my @blaha; ($cmd, @blaha)= getpart("client", "command"); -- 2.7.4