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
*
* 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)
#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);
/* "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)
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;
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];
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}"
)
<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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -u testuser:testpass --ntlm -L -d "stuff to send away"
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
# Verify data after the test has been "shot"
HTTP with NTLM delegation to winbind helper
</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=%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
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -u testuser:anypasswd --ntlm-wb
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
# Verify data after the test has been "shot"
<name>
HTTP with NTLM authorization when talking HTTP/1.0 (known to 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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -u testuser:testpass --ntlm -0
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
# Verify data after the test has been "shot"
<name>
HTTP authorization retry (Basic)
</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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER basic basic
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
# Verify data after the test has been "shot"
<name>
HTTP authorization retry (Basic switching to 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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER basic digest
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
# Verify data after the test has been "shot"
<name>
HTTP authorization retry (Digest switching to Basic)
</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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER digest basic
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
# Verify data after the test has been "shot"
<name>
HTTP authorization retry (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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER digest digest
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
# Verify data after the test has been "shot"
<name>
IMAP NTLM graceful cancellation
</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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
'imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/;MAILINDEX=1' -u testuser:testpass
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
#
<name>
IMAP NTLM authentication with SASL downgrade
</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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
'imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/;MAILINDEX=1' -u user:secret
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
#
<name>
POP3 NTLM graceful cancellation
</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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
pop3://%HOSTIP:%POP3PORT/%TESTNUMBER -u testuser:testpass
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
#
<name>
POP3 NTLM authentication with SASL downgrade
</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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
pop3://%HOSTIP:%POP3PORT/%TESTNUMBER -u user:secret
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
#
<name>
SMTP NTLM graceful cancellation
</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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER --mail-rcpt recipient@example.com --mail-from sender@example.com -u testuser:testpass -T -
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
#
<stdin>
mail body\r
</stdin>
- <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=%PWD/libtest/.libs/libhostname.so
- </setenv>
<command>
smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER --mail-rcpt recipient@example.com --mail-from sender@example.com -u user:secret -T -
</command>
-<precheck>
-chkhostname curlhost
-</precheck>
</client>
#
#
# SPDX-License-Identifier: curl
-chkhostname
lib[1234][0-9][0-9][0-9]
lib[56][0-9][0-9]
lib1521.c
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"
# 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
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
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 \
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)
+++ /dev/null
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 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 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;
-}
+++ /dev/null
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 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 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;
-}