mirror of
https://github.com/curl/curl.git
synced 2026-07-26 01:47:15 +03:00
tests: delete libhostname.so and chkhostname
Before this patch, `libhostname.so` and `chkhostname` were a test facility for overriding `gethostname()` in non-debug builds on Linux and other Unix platforms supporting `LD_PRELOAD`. `gethostname()` has a single use with SMTP. The alternative way to override `gethostname()` is building in debug mode, which allows to do this via the `CURL_GETHOSTNAME` env, on all platforms. Drop the `LD_PRELOAD` solution in favour of the above. Also: - delete inactive NTLM code with a `gethostname()` call made from it. - streamline NTLM code by dropping a `printf()` and a macro. - tests: stop setting `CURL_GETHOSTNAME` where unnecessary. Closes #14695
This commit is contained in:
parent
59b419f1a5
commit
09437d8cd4
23 changed files with 5 additions and 307 deletions
1
tests/libtest/.gitignore
vendored
1
tests/libtest/.gitignore
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* 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;
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue