]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
NTLM tests: boost coverage by forcing the hostname
authorKamil Dudka <kdudka@redhat.com>
Thu, 29 Jul 2010 22:47:49 +0000 (00:47 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 29 Jul 2010 22:51:24 +0000 (00:51 +0200)
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.

36 files changed:
lib/Makefile.inc
lib/curl_gethostname.c [new file with mode: 0644]
lib/curl_gethostname.h [new file with mode: 0644]
lib/http_ntlm.c
lib/smtp.c
tests/data/test1008
tests/data/test1021
tests/data/test1100
tests/data/test150
tests/data/test155
tests/data/test159
tests/data/test169
tests/data/test209
tests/data/test213
tests/data/test239
tests/data/test243
tests/data/test265
tests/data/test267
tests/data/test547
tests/data/test548
tests/data/test551
tests/data/test555
tests/data/test67
tests/data/test68
tests/data/test69
tests/data/test81
tests/data/test89
tests/data/test90
tests/data/test91
tests/libtest/.gitignore
tests/libtest/Makefile.am
tests/libtest/Makefile.inc
tests/libtest/chkhostname.c [new file with mode: 0644]
tests/libtest/hostname.c [new file with mode: 0644]
tests/libtest/sethostname.c [new file with mode: 0644]
tests/runtests.pl

index 17e2d36e77dbda7a95cd6802e152a7b2a0d5141c..bfd3abedc5cc5b718123ddc873c55268ac7565a8 100644 (file)
@@ -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 (file)
index 0000000..5a8c649
--- /dev/null
@@ -0,0 +1,52 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, 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 <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#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 (file)
index 0000000..0e393af
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef HEADER_CURL_GETHOSTNAME_H
+#define HEADER_CURL_GETHOSTNAME_H
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, 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 */
index 0e831ca33835ceb8e2980ed90717b262a357b84b..f5b696a69ed3e964ac40941eaf7a9a1ee3ff0bc2 100644 (file)
@@ -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;
     }
index edc3ff659cf520db35addcb84d12cf27ee49e11a..1133fe527a60d57627d5fbc02ca9cd956c84b852 100644 (file)
@@ -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 <curl/mprintf.h>
@@ -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 */
index 6154446866c55b31518274672c5cdc64cd4e1d79..563a5c0303fbbca44413bbe7847b4d94c2949b7c 100644 (file)
@@ -86,9 +86,18 @@ NTLM
  <name>
 HTTP proxy CONNECT auth NTLM with chunked-encoded 407 response
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://test.remote.haxx.se:1008/path/10080002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -96,11 +105,6 @@ http://test.remote.haxx.se:1008/path/10080002 --proxy http://%HOSTIP:%HTTPPORT -
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/
-</strippart>
 <protocol>
 CONNECT test.remote.haxx.se:1008 HTTP/1.1\r
 Host: test.remote.haxx.se:1008\r
@@ -109,7 +113,7 @@ Proxy-Connection: Keep-Alive
 \r
 CONNECT test.remote.haxx.se:1008 HTTP/1.1\r
 Host: test.remote.haxx.se:1008\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=\r
 Proxy-Connection: Keep-Alive\r
 \r
 GET /path/10080002 HTTP/1.1\r
index 233cbc4db4efaeb330948f6305d12e2dfac10b87..0bc8af3cc5a02789f292d4d74fadab2dd856d464 100644 (file)
@@ -95,9 +95,18 @@ NTLM
  <name>
 HTTP proxy CONNECT with any proxyauth and proxy offers NTLM and close
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://test.remote.haxx.se:1021/path/10210002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-anyauth --proxytunnel
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -105,11 +114,6 @@ http://test.remote.haxx.se:1021/path/10210002 --proxy http://%HOSTIP:%HTTPPORT -
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/
-</strippart>
 <protocol>
 CONNECT test.remote.haxx.se:1021 HTTP/1.1\r
 Host: test.remote.haxx.se:1021\r
@@ -122,7 +126,7 @@ Proxy-Connection: Keep-Alive
 \r
 CONNECT test.remote.haxx.se:1021 HTTP/1.1\r
 Host: test.remote.haxx.se:1021\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=\r
 Proxy-Connection: Keep-Alive\r
 \r
 GET /path/10210002 HTTP/1.1\r
index 40d9f641ec101c8f20b2fc51bb0ae1568653ed6d..00bd64431e6e2425114a9aabf23f19daa423ca03 100644 (file)
@@ -70,9 +70,18 @@ http
  <name>
 HTTP POST with NTLM authorization and following a 302 redirect
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/1100 -u testuser:testpass --ntlm -L -d "stuff to send away" 
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # 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
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol>
 POST /1100 HTTP/1.1\r
 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -95,7 +99,7 @@ Content-Length: 0
 Content-Type: application/x-www-form-urlencoded\r
 \r
 POST /1100 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index 8dcb3621a295868ebc7d56d9f57c0aba7577157b..fc922e2f28c0d2342d75011334f056202f86bff9 100644 (file)
@@ -57,9 +57,18 @@ http
  <name>
 HTTP with NTLM authorization and --fail
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/150 -u testuser:testpass --ntlm --fail
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -67,11 +76,6 @@ http://%HOSTIP:%HTTPPORT/150 -u testuser:testpass --ntlm --fail
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol>
 GET /150 HTTP/1.1\r
 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -80,7 +84,7 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 GET /150 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index 5d228db6250aae7b4ffedaa556a386c4226524dc..53ee1dbbd538add53621e14c1cee0d5b38c99f7b 100644 (file)
@@ -75,9 +75,18 @@ http
  <name>
 HTTP PUT with --anyauth authorization (picking NTLM)
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/155 -T log/put155 -u testuser:testpass --anyauth
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 <file name="log/put155">
 This is data we upload with PUT
 a second line
@@ -91,11 +100,6 @@ four is the number of lines
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol>
 PUT /155 HTTP/1.1\r
 Host: %HOSTIP:%HTTPPORT\r
@@ -111,7 +115,7 @@ Content-Length: 0
 Expect: 100-continue\r
 \r
 PUT /155 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 User-Agent: curl/7.10.5 (i686-pc-linux-gnu) libcurl/7.10.5 OpenSSL/0.9.7a ipv6 zlib/1.1.3\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index 3b018212a1e607ec714a2a01beb0c412cf1aad13..ede46249208b6c33fe8db6ed26f398bf609da4a1 100644 (file)
@@ -56,9 +56,18 @@ http
  <name>
 HTTP with NTLM authorization when talking HTTP/1.0
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/159 -u testuser:testpass --ntlm -0
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -66,11 +75,6 @@ http://%HOSTIP:%HTTPPORT/159 -u testuser:testpass --ntlm -0
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol>
 GET /159 HTTP/1.0\r
 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -79,7 +83,7 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 GET /159 HTTP/1.0\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index 0ad2f8808df597bc4befbddcb05ad4e0878d3cb2..5af7f9f5c073f8544a6f375672ee2790b4c2bc72 100644 (file)
@@ -81,9 +81,18 @@ NTLM
  <name>
 HTTP with proxy-requiring-NTLM to site-requiring-Digest
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://data.from.server.requiring.digest.hohoho.com/169 --proxy http://%HOSTIP:%HTTPPORT --proxy-user foo:bar --proxy-ntlm --digest --user digest:alot
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -91,11 +100,6 @@ http://data.from.server.requiring.digest.hohoho.com/169 --proxy http://%HOSTIP:%
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAAAwADAHAAAAA).*/$1/
-</strippart>
 <protocol>
 GET http://data.from.server.requiring.digest.hohoho.com/169 HTTP/1.1\r
 Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -105,7 +109,7 @@ Accept: */*
 Proxy-Connection: Keep-Alive\r
 \r
 GET http://data.from.server.requiring.digest.hohoho.com/169 HTTP/1.1\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAAAwADAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAAAwADAHAAAAAIAAgAcwAAAAAAAAAAAAAABoKBAIP6B+XVQ6vQsx3DfDXUVhd9436GAxPu0IYcl2Z7LxHmNeOAWQ+vxUmhuCFJBUgXCWZvb2N1cmxob3N0\r
 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\r
 Host: data.from.server.requiring.digest.hohoho.com\r
 Accept: */*\r
index ef372c4de7328c775ba0c8d12d2fb402cd1554e1..e27b6e38bd31b61fef803ef19419a4e4dd3c9e9f 100644 (file)
@@ -79,9 +79,18 @@ NTLM
  <name>
 HTTP proxy CONNECT auth NTLM
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://test.remote.haxx.se:209/path/2090002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # 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
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/
-</strippart>
 <protocol>
 CONNECT test.remote.haxx.se:209 HTTP/1.1\r
 Host: test.remote.haxx.se:209\r
@@ -102,7 +106,7 @@ Proxy-Connection: Keep-Alive
 \r
 CONNECT test.remote.haxx.se:209 HTTP/1.1\r
 Host: test.remote.haxx.se:209\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=\r
 Proxy-Connection: Keep-Alive\r
 \r
 GET /path/2090002 HTTP/1.1\r
index 801d9e7ad2950b3d43ba39b81e86d5db065ac27c..8bab387836b44e40ef772eaf3423f2aea62b7f4d 100644 (file)
@@ -79,9 +79,18 @@ NTLM
  <name>
 HTTP 1.0 proxy CONNECT auth NTLM and then POST
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://test.remote.haxx.se:213/path/2130002 --proxy1.0 http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel -d "postit"
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # 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
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/
-</strippart>
 <protocol nonewline="yes">
 CONNECT test.remote.haxx.se:213 HTTP/1.0\r
 Host: test.remote.haxx.se:213\r
@@ -102,7 +106,7 @@ Proxy-Connection: Keep-Alive
 \r
 CONNECT test.remote.haxx.se:213 HTTP/1.0\r
 Host: test.remote.haxx.se:213\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=\r
 Proxy-Connection: Keep-Alive\r
 \r
 POST /path/2130002 HTTP/1.1\r
index 2674b8e3a8983b7bd0b6e823e8ca9876060aaa1d..e88908989651ed27ba266725abe1ececbd184eff 100644 (file)
@@ -56,9 +56,18 @@ NTLM
  <name>
 HTTP proxy-auth NTLM and then POST
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/239 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm -d "postit"
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -66,11 +75,6 @@ http://%HOSTIP:%HTTPPORT/239 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/
-</strippart>
 <protocol nonewline="yes">
 POST http://%HOSTIP:%HTTPPORT/239 HTTP/1.1\r
 Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -82,7 +86,7 @@ Content-Length: 0
 Content-Type: application/x-www-form-urlencoded\r
 \r
 POST http://%HOSTIP:%HTTPPORT/239 HTTP/1.1\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index f24fd771750a88b431167464fe5431fe1eead575..3effb8202ac5e5c9617737242030806f96e6f9b7 100644 (file)
@@ -77,9 +77,18 @@ NTLM
  <name>
 HTTP POST with --proxy-anyauth, picking NTLM
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/243 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-anyauth -d "postit"
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -87,11 +96,6 @@ http://%HOSTIP:%HTTPPORT/243 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/
-</strippart>
 <protocol nonewline="yes">
 POST http://%HOSTIP:%HTTPPORT/243 HTTP/1.1\r
 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\r
@@ -111,7 +115,7 @@ Content-Length: 0
 Content-Type: application/x-www-form-urlencoded\r
 \r
 POST http://%HOSTIP:%HTTPPORT/243 HTTP/1.1\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index bd8a24c0a2e8119899b1188d195062e3a2ef3655..e47dbe8e778a38a2d0c14e74b54a62eae7216ba7 100644 (file)
@@ -82,9 +82,18 @@ NTLM
  <name>
 HTTP proxy CONNECT auth NTLM and then POST, response-body in the 407
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://test.remote.haxx.se:265/path/2650002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel -d "postit"
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # 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
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/
-</strippart>
 <protocol nonewline="yes">
 CONNECT test.remote.haxx.se:265 HTTP/1.1\r
 Host: test.remote.haxx.se:265\r
@@ -105,7 +109,7 @@ Proxy-Connection: Keep-Alive
 \r
 CONNECT test.remote.haxx.se:265 HTTP/1.1\r
 Host: test.remote.haxx.se:265\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=\r
 Proxy-Connection: Keep-Alive\r
 \r
 POST /path/2650002 HTTP/1.1\r
index 4e356b6856ea20205998cd146423d0988f99b213..aa61b357b20dc30277f33de48496d19384805022 100644 (file)
@@ -63,9 +63,18 @@ http
  <name>
 HTTP POST with NTLM authorization and added custom headers
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/267 -u testuser:testpass --ntlm -d "data" -H "Header1: yes" -H "Header2: no"
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -73,11 +82,6 @@ http://%HOSTIP:%HTTPPORT/267 -u testuser:testpass --ntlm -d "data" -H "Header1:
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol nonewline="yes">
 POST /267 HTTP/1.1\r
 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -90,7 +94,7 @@ Content-Length: 0
 Content-Type: application/x-www-form-urlencoded\r
 \r
 POST /267 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index d2e9d9ea1bd01ac064fc5f7f699a168783e0341a..8ac0c9dd5d6e57ee265c828a1ac968142b5c1581 100644 (file)
@@ -80,9 +80,18 @@ NTLM
  <name>
 HTTP proxy auth NTLM with POST data from read callback
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://test.remote.haxx.se/path/547 http://%HOSTIP:%HTTPPORT s1lly:pers0n
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -90,11 +99,6 @@ http://test.remote.haxx.se/path/547 http://%HOSTIP:%HTTPPORT s1lly:pers0n
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/
-</strippart>
 <protocol>
 POST http://test.remote.haxx.se/path/547 HTTP/1.1\r
 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\r
@@ -115,7 +119,7 @@ Content-Length: 0
 Content-Type: application/x-www-form-urlencoded\r
 \r
 POST http://test.remote.haxx.se/path/547 HTTP/1.1\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAIYrD1xJmhNBNL9fLzuk9PV9436GAxPu0EKWzqQ/sZDVLXnp1JrySgl8A+cibE6z4HMxbGx5Y3VybGhvc3Q=\r
 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\r
 Host: test.remote.haxx.se\r
 Accept: */*\r
index 215b44fd9438e781731aa23a5a75ba217e0ee425..d811fcaebc04a2a8300e35d5d0589944f98e2dcb 100644 (file)
@@ -80,9 +80,18 @@ NTLM
  <name>
 HTTP proxy auth NTLM with POST data from CURLOPT_POSTFIELDS
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://test.remote.haxx.se/path/548 http://%HOSTIP:%HTTPPORT s1lly:pers0n
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -90,11 +99,6 @@ http://test.remote.haxx.se/path/548 http://%HOSTIP:%HTTPPORT s1lly:pers0n
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/
-</strippart>
 <protocol>
 POST http://test.remote.haxx.se/path/548 HTTP/1.1\r
 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\r
@@ -115,7 +119,7 @@ Content-Length: 0
 Content-Type: application/x-www-form-urlencoded\r
 \r
 POST http://test.remote.haxx.se/path/548 HTTP/1.1\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAIYrD1xJmhNBNL9fLzuk9PV9436GAxPu0EKWzqQ/sZDVLXnp1JrySgl8A+cibE6z4HMxbGx5Y3VybGhvc3Q=\r
 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\r
 Host: test.remote.haxx.se\r
 Accept: */*\r
index 28b5af5a726f5fe623417ac19b27b9ef62c73f5c..8027d91cf75eece9c111fd86af7e2426de8512c3 100644 (file)
@@ -75,11 +75,6 @@ http://test.remote.haxx.se/path/551 http://%HOSTIP:%HTTPPORT s1lly:pers0n
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
-<strippart>
-s/^(Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA).*/$1/
-</strippart>
 <protocol>
 POST http://test.remote.haxx.se/path/551 HTTP/1.1\r
 Host: test.remote.haxx.se\r
index d433569c0202d20f5b9ee6ea65e68ed76118986e..74dc210b10aab7bbbca363d016c127f4dfb0aa75 100644 (file)
@@ -85,9 +85,18 @@ NTLM
  <name>
 HTTP proxy auth NTLM with POST data from read callback multi-if
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://test.remote.haxx.se/path/555 http://%HOSTIP:%HTTPPORT s1lly:pers0n
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -95,10 +104,7 @@ http://test.remote.haxx.se/path/555 http://%HOSTIP:%HTTPPORT s1lly:pers0n
 <strip>
 ^User-Agent: curl/.*
 </strip>
-# 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!
 <strippart>
-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)
 </strippart>
@@ -122,7 +128,7 @@ Content-Length: 0
 Content-Type: application/x-www-form-urlencoded\r
 \r
 POST http://test.remote.haxx.se/path/555 HTTP/1.1\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAIYrD1xJmhNBNL9fLzuk9PV9436GAxPu0EKWzqQ/sZDVLXnp1JrySgl8A+cibE6z4HMxbGx5Y3VybGhvc3Q=\r
 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\r
 Host: test.remote.haxx.se\r
 Accept: */*\r
index 46d120b13c35637dfb427c05ce0408b30ea50d3f..d6d60efe7c4880b4baeec88fd20c60b8f42f2000 100644 (file)
@@ -63,9 +63,18 @@ http
  <name>
 HTTP with NTLM authorization
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/67 -u testuser:testpass --ntlm
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -73,11 +82,6 @@ http://%HOSTIP:%HTTPPORT/67 -u testuser:testpass --ntlm
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol>
 GET /67 HTTP/1.1\r
 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -86,7 +90,7 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 GET /67 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index 9cceaf7a29748d6a1da3f4f8997de85becb82db3..5b79a7a98c60a893ecc41d0dc994c21076bacdd9 100644 (file)
@@ -62,9 +62,18 @@ http
  <name>
 HTTP with NTLM authorization and wrong password
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/68 -u testuser:testpass --ntlm
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -72,11 +81,6 @@ http://%HOSTIP:%HTTPPORT/68 -u testuser:testpass --ntlm
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol>
 GET /68 HTTP/1.1\r
 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -85,7 +89,7 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 GET /68 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index 1bf0f735fa6b91cc68d4a88fa9677f80d9bfaf77..d6b8de62c5c3c3ad281bef8ff2d2b971a5c43623 100644 (file)
@@ -79,9 +79,18 @@ http
  <name>
 HTTP with NTLM, Basic or Wild-and-crazy authorization
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/69 -u testuser:testpass --anyauth
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -89,11 +98,6 @@ http://%HOSTIP:%HTTPPORT/69 -u testuser:testpass --anyauth
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol>
 GET /69 HTTP/1.1\r
 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\r
@@ -107,7 +111,7 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 GET /69 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index 9a12cc1a7eed4fcbbd0022a3ec8767aa9ba6304e..47b37e963af4b31b8ebfaac62da56541d39ce7a3 100644 (file)
@@ -62,9 +62,18 @@ http
  <name>
 HTTP with proxy using NTLM authorization
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/81 --proxy-user testuser:testpass -x http://%HOSTIP:%HTTPPORT --proxy-ntlm
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -72,11 +81,6 @@ http://%HOSTIP:%HTTPPORT/81 --proxy-user testuser:testpass -x http://%HOSTIP:%HT
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol>
 GET http://%HOSTIP:%HTTPPORT/81 HTTP/1.1\r
 Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -86,7 +90,7 @@ Accept: */*
 Proxy-Connection: Keep-Alive\r
 \r
 GET http://%HOSTIP:%HTTPPORT/81 HTTP/1.1\r
-Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index 06effd1b736784b66ccba1990fe72e8587a3b2f7..3512fbe55181783edca3c1b5de52de56546d87ec 100644 (file)
@@ -96,9 +96,18 @@ http
  <name>
 HTTP with NTLM and follow-location
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/89 -u testuser:testpass --ntlm -L
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -106,11 +115,6 @@ http://%HOSTIP:%HTTPPORT/89 -u testuser:testpass --ntlm -L
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol>
 GET /89 HTTP/1.1\r
 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -119,7 +123,7 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 GET /89 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
@@ -131,7 +135,7 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 GET /you/890010 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index 387608b5ba991f51ed7f5bacab7dfdddffb01788..55c98f4a03bbf3b07566efb37dd9b89d9e9e36c0 100644 (file)
@@ -134,9 +134,18 @@ http
  <name>
 HTTP with NTLM via --anyauth, and then follow-location with NTLM again
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/90 -u testuser:testpass --anyauth -L
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -144,11 +153,6 @@ http://%HOSTIP:%HTTPPORT/90 -u testuser:testpass --anyauth -L
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
-</strippart>
 <protocol>
 GET /90 HTTP/1.1\r
 Host: %HOSTIP:%HTTPPORT\r
@@ -161,7 +165,7 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 GET /90 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
@@ -177,7 +181,7 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 GET /you/900010 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index e3b81b3b4c4501caf9c0dbc639db3c945bd42776..90ace92ed3e8a74ebb85dbd7c58cf47832f80e68 100644 (file)
@@ -80,9 +80,18 @@ http
  <name>
 HTTP with NTLM/Negotiate/Basic, anyauth and user with domain, with size 0
  </name>
+ <setenv>
+# 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
+ </setenv>
  <command>
 http://%HOSTIP:%HTTPPORT/91 --anyauth -u mydomain\\myself:secret
 </command>
+<precheck>
+chkhostname curlhost
+</precheck>
 </client>
 
 # Verify data after the test has been "shot"
@@ -90,11 +99,6 @@ http://%HOSTIP:%HTTPPORT/91 --anyauth -u mydomain\\myself:secret
 <strip>
 ^User-Agent:.*
 </strip>
-# 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!
-<strippart>
-s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAgACABwAAAABgAGAHgAAAA).*/$1/
-</strippart>
 <protocol>
 GET /91 HTTP/1.1\r
 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\r
@@ -108,7 +112,7 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 GET /91 HTTP/1.1\r
-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAgACABwAAAABgAGAHgAAAA
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAgACABwAAAABgAGAHgAAAAIAAgAfgAAAAAAAAAAAAAABoKBAMIyJpR5mHpg2FZha5kRaFZ9436GAxPu0C5llxexSQ5QzVkiLSfkcpVyRgCXXqR+Am15ZG9tYWlubXlzZWxmY3VybGhvc3Q=\r
 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\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
index 3311a821e8be1f9c1fdc6e0bb0b22896bc4b24a6..cabcb671cec7afa957c1ea6ccf5960ed5f2aa99a 100644 (file)
@@ -1,2 +1,2 @@
+chkhostname
 lib5[0-9][0-9]
-
index 70b0f12a4a768f34717c1b6a64b3f28939cf0191..2a0e3eaa406f5736efd0cf80834d4407807f0009 100644 (file)
@@ -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
index 814c01e6ca4275d825e4c7081f028574738460b1..28ed6831c05028cbbf158e33ac3f14d43e275ede 100644 (file)
@@ -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 (file)
index 0000000..686eb47
--- /dev/null
@@ -0,0 +1,26 @@
+#include "curl_gethostname.h"
+
+#include <stdio.h>
+
+#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 (file)
index 0000000..ca7fcca
--- /dev/null
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ */
+
+#include <string.h>
+#include <unistd.h>
+
+#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 (file)
index 0000000..667f689
--- /dev/null
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#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;
+};
index 6abca9fce8b79ce9a6ab73482d6c4807ef430dea..8bb5d69e977fd085a43135876d4a6b6aa0ed7c34 100755 (executable)
@@ -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");