diff --git a/configure.ac b/configure.ac
index 5874b40022..71514c8642 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4064,14 +4064,6 @@ AM_CONDITIONAL(USE_MANUAL, test x"$USE_MANUAL" = x1)
CURL_CHECK_LIB_ARES
-if test "x$curl_cv_native_windows" != "xyes" &&
- test "x$enable_shared" = "xyes"; then
- build_libhostname=yes
-else
- build_libhostname=no
-fi
-AM_CONDITIONAL(BUILD_LIBHOSTNAME, test x$build_libhostname = xyes)
-
if test "x$want_ares" != xyes; then
CURL_CHECK_OPTION_THREADED_RESOLVER
diff --git a/lib/curl_gethostname.c b/lib/curl_gethostname.c
index cd111231d9..7b28421275 100644
--- a/lib/curl_gethostname.c
+++ b/lib/curl_gethostname.c
@@ -39,15 +39,6 @@
*
* Note: The function always returns the un-qualified hostname rather
* than being provider dependent.
- *
- * For libcurl shared library release builds the test suite preloads
- * another shared library named libhostname using the LD_PRELOAD
- * mechanism which intercepts, and might override, the gethostname()
- * function call. In this case a given platform must support the
- * LD_PRELOAD mechanism and additionally have environment variable
- * CURL_GETHOSTNAME set in order to override the returned hostname.
- *
- * For libcurl static library release builds no overriding takes place.
*/
int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen)
@@ -78,9 +69,6 @@ int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen)
#else /* DEBUGBUILD */
- /* The call to system's gethostname() might get intercepted by the
- libhostname library when libcurl is built as a non-debug shared
- library when running the test suite. */
name[0] = '\0';
err = gethostname(name, namelen);
diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c
index abebdeda74..0050b4132c 100644
--- a/lib/vauth/ntlm.c
+++ b/lib/vauth/ntlm.c
@@ -59,10 +59,6 @@
/* "NTLMSSP" signature is always in ASCII regardless of the platform */
#define NTLMSSP_SIGNATURE "\x4e\x54\x4c\x4d\x53\x53\x50"
-/* The fixed hostname we provide, in order to not leak our real local host
- name. Copy the name used by Firefox. */
-#define NTLM_HOSTNAME "WORKSTATION"
-
#if DEBUG_ME
# define DEBUG_OUT(x) x
static void ntlm_print_flags(FILE *handle, unsigned long flags)
@@ -490,7 +486,9 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
unsigned char *ptr_ntresp = &ntresp[0];
unsigned char *ntlmv2resp = NULL;
bool unicode = (ntlm->flags & NTLMFLAG_NEGOTIATE_UNICODE) ? TRUE : FALSE;
- char host[HOSTNAME_MAX + 1] = "";
+ /* The fixed hostname we provide, in order to not leak our real local host
+ name. Copy the name used by Firefox. */
+ static const char host[] = "WORKSTATION";
const char *user;
const char *domain = "";
size_t hostoff = 0;
@@ -515,21 +513,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
user = userp;
userlen = strlen(user);
-
-#ifndef NTLM_HOSTNAME
- /* Get the machine's un-qualified hostname as NTLM does not like the fully
- qualified domain name */
- if(Curl_gethostname(host, sizeof(host))) {
- infof(data, "gethostname() failed, continuing without");
- hostlen = 0;
- }
- else {
- hostlen = strlen(host);
- }
-#else
- (void)msnprintf(host, sizeof(host), "%s", NTLM_HOSTNAME);
- hostlen = sizeof(NTLM_HOSTNAME)-1;
-#endif
+ hostlen = sizeof(host) - 1;
if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) {
unsigned char ntbuffer[0x18];
diff --git a/packages/OS400/make-tests.sh b/packages/OS400/make-tests.sh
index 8ff64d2fb8..3a2125965c 100755
--- a/packages/OS400/make-tests.sh
+++ b/packages/OS400/make-tests.sh
@@ -139,13 +139,6 @@ build_all_programs()
cd libtest || exit 1
get_make_vars Makefile.inc
- # Special case: redefine chkhostname compilation parameters.
-
- # shellcheck disable=SC2034
- chkhostname_SOURCES=chkhostname.c
- # shellcheck disable=SC2034
- chkhostname_LDADD=curl_gethostname.o
-
# shellcheck disable=SC2153
build_all_programs "" "${TARGETLIB}/${SRVPGM}"
)
diff --git a/tests/data/test1100 b/tests/data/test1100
index 268f367f21..13eaeb3177 100644
--- a/tests/data/test1100
+++ b/tests/data/test1100
@@ -73,18 +73,9 @@ 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=%PWD/libtest/.libs/libhostname.so
-
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -u testuser:testpass --ntlm -L -d "stuff to send away"
-
-chkhostname curlhost
-
# Verify data after the test has been "shot"
diff --git a/tests/data/test1310 b/tests/data/test1310
index f3c1cfa3da..c935a783f0 100644
--- a/tests/data/test1310
+++ b/tests/data/test1310
@@ -65,10 +65,6 @@ http
HTTP with NTLM delegation to winbind helper
-# 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=%PWD/libtest/.libs/libhostname.so
# set path to fake_auth instead of real ntlm_auth to generate NTLM type1 and type 3 messages
CURL_NTLM_WB_FILE=%PWD/server/fake_ntlm
# set source directory so fake_ntlm can find the test files
@@ -81,9 +77,6 @@ CURL_NTLM_AUTH_TESTNUM=%TESTNUMBER
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -u testuser:anypasswd --ntlm-wb
-
-chkhostname curlhost
-
# Verify data after the test has been "shot"
diff --git a/tests/data/test159 b/tests/data/test159
index 887c4795fa..cc183855a7 100644
--- a/tests/data/test159
+++ b/tests/data/test159
@@ -53,18 +53,9 @@ http
HTTP with NTLM authorization when talking HTTP/1.0 (known to 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=%PWD/libtest/.libs/libhostname.so
-
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -u testuser:testpass --ntlm -0
-
-chkhostname curlhost
-
# Verify data after the test has been "shot"
diff --git a/tests/data/test2023 b/tests/data/test2023
index e395ece9d6..759e682803 100644
--- a/tests/data/test2023
+++ b/tests/data/test2023
@@ -112,18 +112,9 @@ libauthretry
HTTP authorization retry (Basic)
-
-# 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=%PWD/libtest/.libs/libhostname.so
-
http://%HOSTIP:%HTTPPORT/%TESTNUMBER basic basic
-
-chkhostname curlhost
-
# Verify data after the test has been "shot"
diff --git a/tests/data/test2024 b/tests/data/test2024
index 07bf931a22..915f76919b 100644
--- a/tests/data/test2024
+++ b/tests/data/test2024
@@ -126,18 +126,9 @@ libauthretry
HTTP authorization retry (Basic switching to 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=%PWD/libtest/.libs/libhostname.so
-
http://%HOSTIP:%HTTPPORT/%TESTNUMBER basic digest
-
-chkhostname curlhost
-
# Verify data after the test has been "shot"
diff --git a/tests/data/test2026 b/tests/data/test2026
index 81d252a305..96e2ad4963 100644
--- a/tests/data/test2026
+++ b/tests/data/test2026
@@ -162,18 +162,9 @@ libauthretry
HTTP authorization retry (Digest switching to Basic)
-
-# 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=%PWD/libtest/.libs/libhostname.so
-
http://%HOSTIP:%HTTPPORT/%TESTNUMBER digest basic
-
-chkhostname curlhost
-
# Verify data after the test has been "shot"
diff --git a/tests/data/test2027 b/tests/data/test2027
index 0a9338777f..45baa64bc0 100644
--- a/tests/data/test2027
+++ b/tests/data/test2027
@@ -185,18 +185,9 @@ libauthretry
HTTP authorization retry (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=%PWD/libtest/.libs/libhostname.so
-
http://%HOSTIP:%HTTPPORT/%TESTNUMBER digest digest
-
-chkhostname curlhost
-
# Verify data after the test has been "shot"
diff --git a/tests/data/test831 b/tests/data/test831
index 382432368d..1ef3d45c41 100644
--- a/tests/data/test831
+++ b/tests/data/test831
@@ -34,18 +34,9 @@ SSL
IMAP NTLM graceful cancellation
-
-# 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=%PWD/libtest/.libs/libhostname.so
-
'imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/;MAILINDEX=1' -u testuser:testpass
-
-chkhostname curlhost
-
#
diff --git a/tests/data/test834 b/tests/data/test834
index e142ca2196..ccdf0d1fdb 100644
--- a/tests/data/test834
+++ b/tests/data/test834
@@ -45,18 +45,9 @@ SSL
IMAP NTLM authentication with SASL downgrade
-
-# 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=%PWD/libtest/.libs/libhostname.so
-
'imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/;MAILINDEX=1' -u user:secret
-
-chkhostname curlhost
-
#
diff --git a/tests/data/test877 b/tests/data/test877
index 2502370624..e2cb4b3765 100644
--- a/tests/data/test877
+++ b/tests/data/test877
@@ -35,18 +35,9 @@ SSL
POP3 NTLM graceful cancellation
-
-# 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=%PWD/libtest/.libs/libhostname.so
-
pop3://%HOSTIP:%POP3PORT/%TESTNUMBER -u testuser:testpass
-
-chkhostname curlhost
-
#
diff --git a/tests/data/test880 b/tests/data/test880
index dfa2e688c6..21536d81f5 100644
--- a/tests/data/test880
+++ b/tests/data/test880
@@ -47,18 +47,9 @@ SSL
POP3 NTLM authentication with SASL downgrade
-
-# 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=%PWD/libtest/.libs/libhostname.so
-
pop3://%HOSTIP:%POP3PORT/%TESTNUMBER -u user:secret
-
-chkhostname curlhost
-
#
diff --git a/tests/data/test933 b/tests/data/test933
index 71f3893005..3c25ffa5ca 100644
--- a/tests/data/test933
+++ b/tests/data/test933
@@ -34,18 +34,9 @@ SSL
SMTP NTLM graceful cancellation
-
-# 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=%PWD/libtest/.libs/libhostname.so
-
smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER --mail-rcpt recipient@example.com --mail-from sender@example.com -u testuser:testpass -T -
-
-chkhostname curlhost
-
#
diff --git a/tests/data/test936 b/tests/data/test936
index f57f63ec86..723cebca37 100644
--- a/tests/data/test936
+++ b/tests/data/test936
@@ -40,18 +40,9 @@ SMTP NTLM authentication with SASL downgrade
mail body
-
-# 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=%PWD/libtest/.libs/libhostname.so
-
smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER --mail-rcpt recipient@example.com --mail-from sender@example.com -u user:secret -T -
-
-chkhostname curlhost
-
#
diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore
index 9541d16e17..2b4dc1a362 100644
--- a/tests/libtest/.gitignore
+++ b/tests/libtest/.gitignore
@@ -2,7 +2,6 @@
#
# SPDX-License-Identifier: curl
-chkhostname
lib[1234][0-9][0-9][0-9]
lib[56][0-9][0-9]
lib1521.c
diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt
index 0e4f4daa29..73bc345034 100644
--- a/tests/libtest/CMakeLists.txt
+++ b/tests/libtest/CMakeLists.txt
@@ -54,25 +54,6 @@ foreach(_target IN LISTS noinst_PROGRAMS)
PROJECT_LABEL "Test libtest ${_target}")
endforeach()
-# Allows for hostname override to make tests machine independent.
-# TODO: this cmake build assumes a shared build, detect static linking here!
-if(NOT WIN32)
- add_library(hostname MODULE EXCLUDE_FROM_ALL "sethostname.c")
- add_dependencies(testdeps hostname)
- target_include_directories(hostname PRIVATE
- "${CURL_BINARY_DIR}/lib" # for "curl_config.h"
- "${CURL_SOURCE_DIR}/lib" # for "curl_setup.h"
- )
- # Output to .libs for compatibility with autotools, the test data expects a
- # library at (tests)/libtest/.libs/libhostname.so
- set_target_properties(hostname PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.libs")
- if(CURL_HIDES_PRIVATE_SYMBOLS)
- set_property(TARGET hostname APPEND PROPERTY COMPILE_DEFINITIONS "CURL_HIDDEN_SYMBOLS")
- set_property(TARGET hostname APPEND PROPERTY COMPILE_FLAGS ${CURL_CFLAG_SYMBOLS_HIDE})
- endif()
-endif()
-
add_custom_command(
OUTPUT "lib1521.c"
COMMAND ${PERL_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl" < "${CURL_SOURCE_DIR}/include/curl/curl.h" > "lib1521.c"
diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am
index f03a687c1e..d5b394463f 100644
--- a/tests/libtest/Makefile.am
+++ b/tests/libtest/Makefile.am
@@ -63,14 +63,7 @@ LDADD = $(SUPPORTFILES_LIBS)
# noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS)
include Makefile.inc
-# Preloading of libhostname allows host name overriding,
-# this is used to make some tests machine independent.
-
-if BUILD_LIBHOSTNAME
-noinst_LTLIBRARIES = libhostname.la
-else
noinst_LTLIBRARIES =
-endif
if USE_CPPFLAG_CURL_STATICLIB
AM_CPPFLAGS += -DCURL_STATICLIB
@@ -79,35 +72,12 @@ endif
AM_LDFLAGS =
AM_CFLAGS =
-libhostname_la_CPPFLAGS_EXTRA =
-libhostname_la_LDFLAGS_EXTRA = -module -avoid-version -rpath /nowhere
-libhostname_la_CFLAGS_EXTRA =
-
libstubgss_la_LDFLAGS_EXTRA =
if CURL_LT_SHLIB_USE_NO_UNDEFINED
-libhostname_la_LDFLAGS_EXTRA += -no-undefined
libstubgss_la_LDFLAGS_EXTRA += -no-undefined
endif
-if CURL_LT_SHLIB_USE_MIMPURE_TEXT
-libhostname_la_LDFLAGS_EXTRA += -mimpure-text
-endif
-
-if DOING_CURL_SYMBOL_HIDING
-libhostname_la_CPPFLAGS_EXTRA += -DCURL_HIDDEN_SYMBOLS
-libhostname_la_CFLAGS_EXTRA += $(CFLAG_CURL_SYMBOL_HIDING)
-endif
-
-libhostname_la_CPPFLAGS = $(AM_CPPFLAGS) $(libhostname_la_CPPFLAGS_EXTRA)
-libhostname_la_LDFLAGS = $(AM_LDFLAGS) $(libhostname_la_LDFLAGS_EXTRA)
-libhostname_la_CFLAGS = $(AM_CFLAGS) $(libhostname_la_CFLAGS_EXTRA)
-
-libhostname_la_SOURCES = sethostname.c
-
-libhostname_la_LIBADD =
-libhostname_la_DEPENDENCIES =
-
# Build a stub gssapi implementation for testing
if BUILD_STUB_GSS
noinst_LTLIBRARIES += libstubgss.la
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index 371f266562..0c1414938a 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -38,7 +38,7 @@ TIMEDIFF = ../../lib/timediff.c ../../lib/timediff.h
SUPPORTFILES = $(TIMEDIFF) first.c test.h
# These are all libcurl test programs
-noinst_PROGRAMS = chkhostname libauthretry libntlmconnect libprereq \
+noinst_PROGRAMS = libauthretry libntlmconnect libprereq \
lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 lib508 lib509 \
lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 lib518 lib519 \
lib520 lib521 lib523 lib524 lib525 lib526 lib527 lib529 lib530 lib532 \
@@ -80,10 +80,6 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect libprereq \
lib3010 lib3025 lib3026 lib3027 \
lib3100 lib3101 lib3102 lib3103
-chkhostname_SOURCES = chkhostname.c ../../lib/curl_gethostname.c
-chkhostname_LDADD = @CURL_NETWORK_LIBS@
-chkhostname_DEPENDENCIES =
-
libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
libntlmconnect_LDADD = $(TESTUTIL_LIBS)
diff --git a/tests/libtest/chkhostname.c b/tests/libtest/chkhostname.c
deleted file mode 100644
index e49da133c9..0000000000
--- a/tests/libtest/chkhostname.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 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 https://curl.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.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
-#include "curl_setup.h"
-
-#include "curl_gethostname.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/sethostname.c b/tests/libtest/sethostname.c
deleted file mode 100644
index 1e07d26bc6..0000000000
--- a/tests/libtest/sethostname.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 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 https://curl.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.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
-#include "curl_setup.h"
-
-/*
- * we force our own host name, in order to make some tests machine independent
- */
-
-int gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen)
-{
- const char *force_hostname = getenv("CURL_GETHOSTNAME");
- if(force_hostname) {
- strncpy(name, force_hostname, namelen);
- name[namelen-1] = '\0';
- return 0;
- }
-
- /* LD_PRELOAD used, but no hostname set, we'll just return a failure */
- return -1;
-}