tests: factor out the test server management code
—
$ git checkout -f d39db811929f85c3a9e09bc8b7a092681ba279f8
Previous HEAD position was f25627014e runtests: don't use the SMB server verification time as reference
HEAD is now at d39db81192 tests: factor out the test server management code
$ git clean -fdx
Removing Makefile
Removing Makefile.in
Removing aclocal.m4
Removing autom4te.cache/
Removing compile
Removing config.guess
Removing config.log
Removing config.status
Removing config.sub
Removing configure
Removing curl-config
Removing depcomp
Removing docs/Makefile
Removing docs/Makefile.in
Removing docs/cmdline-opts/Makefile
Removing docs/cmdline-opts/Makefile.in
Removing docs/curl.1
Removing docs/examples/.deps/
Removing docs/examples/Makefile
Removing docs/examples/Makefile.in
Removing docs/libcurl/Makefile
Removing docs/libcurl/Makefile.in
Removing docs/libcurl/opts/Makefile
Removing docs/libcurl/opts/Makefile.in
Removing include/Makefile
Removing include/Makefile.in
Removing include/curl/Makefile
Removing include/curl/Makefile.in
Removing install-sh
Removing lib/.deps/
Removing lib/.dirstamp
Removing lib/.libs/
Removing lib/Makefile
Removing lib/Makefile.in
Removing lib/curl_config.h
Removing lib/curl_config.h.in
Removing lib/curl_multibyte.o
Removing lib/dynbuf.o
Removing lib/libcurl.la
Removing lib/libcurl.plist
Removing lib/libcurl.vers
Removing lib/libcurl_la-altsvc.lo
Removing lib/libcurl_la-altsvc.o
Removing lib/libcurl_la-amigaos.lo
Removing lib/libcurl_la-amigaos.o
Removing lib/libcurl_la-asyn-ares.lo
Removing lib/libcurl_la-asyn-ares.o
Removing lib/libcurl_la-asyn-thread.lo
Removing lib/libcurl_la-asyn-thread.o
Removing lib/libcurl_la-base64.lo
Removing lib/libcurl_la-base64.o
Removing lib/libcurl_la-bufq.lo
Removing lib/libcurl_la-bufq.o
Removing lib/libcurl_la-bufref.lo
Removing lib/libcurl_la-bufref.o
Removing lib/libcurl_la-c-hyper.lo
Removing lib/libcurl_la-c-hyper.o
Removing lib/libcurl_la-cf-h1-proxy.lo
Removing lib/libcurl_la-cf-h1-proxy.o
Removing lib/libcurl_la-cf-h2-proxy.lo
Removing lib/libcurl_la-cf-h2-proxy.o
Removing lib/libcurl_la-cf-haproxy.lo
Removing lib/libcurl_la-cf-haproxy.o
Removing lib/libcurl_la-cf-https-connect.lo
Removing lib/libcurl_la-cf-https-connect.o
Removing lib/libcurl_la-cf-socket.lo
Removing lib/libcurl_la-cf-socket.o
Removing lib/libcurl_la-cfilters.lo
Removing lib/libcurl_la-cfilters.o
Removing lib/libcurl_la-conncache.lo
Removing lib/libcurl_la-conncache.o
Removing lib/libcurl_la-connect.lo
Removing lib/libcurl_la-connect.o
Removing lib/libcurl_la-content_encoding.lo
Removing lib/libcurl_la-content_encoding.o
Removing lib/libcurl_la-cookie.lo
Removing lib/libcurl_la-cookie.o
Removing lib/libcurl_la-curl_addrinfo.lo
Removing lib/libcurl_la-curl_addrinfo.o
Removing lib/libcurl_la-curl_des.lo
Removing lib/libcurl_la-curl_des.o
Removing lib/libcurl_la-curl_endian.lo
Removing lib/libcurl_la-curl_endian.o
Removing lib/libcurl_la-curl_fnmatch.lo
Removing lib/libcurl_la-curl_fnmatch.o
Removing lib/libcurl_la-curl_get_line.lo
Removing lib/libcurl_la-curl_get_line.o
Removing lib/libcurl_la-curl_gethostname.lo
Removing lib/libcurl_la-curl_gethostname.o
Removing lib/libcurl_la-curl_gssapi.lo
Removing lib/libcurl_la-curl_gssapi.o
Removing lib/libcurl_la-curl_log.lo
Removing lib/libcurl_la-curl_log.o
Removing lib/libcurl_la-curl_memrchr.lo
Removing lib/libcurl_la-curl_memrchr.o
Removing lib/libcurl_la-curl_multibyte.lo
Removing lib/libcurl_la-curl_multibyte.o
Removing lib/libcurl_la-curl_ntlm_core.lo
Removing lib/libcurl_la-curl_ntlm_core.o
Removing lib/libcurl_la-curl_ntlm_wb.lo
Removing lib/libcurl_la-curl_ntlm_wb.o
Removing lib/libcurl_la-curl_path.lo
Removing lib/libcurl_la-curl_path.o
Removing lib/libcurl_la-curl_range.lo
Removing lib/libcurl_la-curl_range.o
Removing lib/libcurl_la-curl_rtmp.lo
Removing lib/libcurl_la-curl_rtmp.o
Removing lib/libcurl_la-curl_sasl.lo
Removing lib/libcurl_la-curl_sasl.o
Removing lib/libcurl_la-curl_sspi.lo
Removing lib/libcurl_la-curl_sspi.o
Removing lib/libcurl_la-curl_threads.lo
Removing lib/libcurl_la-curl_threads.o
Removing lib/libcurl_la-dict.lo
Removing lib/libcurl_la-dict.o
Removing lib/libcurl_la-doh.lo
Removing lib/libcurl_la-doh.o
Removing lib/libcurl_la-dynbuf.lo
Removing lib/libcurl_la-dynbuf.o
Removing lib/libcurl_la-dynhds.lo
Removing lib/libcurl_la-dynhds.o
Removing lib/libcurl_la-easy.lo
Removing lib/libcurl_la-easy.o
Removing lib/libcurl_la-easygetopt.lo
Removing lib/libcurl_la-easygetopt.o
Removing lib/libcurl_la-easyoptions.lo
Removing lib/libcurl_la-easyoptions.o
Removing lib/libcurl_la-escape.lo
Removing lib/libcurl_la-escape.o
Removing lib/libcurl_la-file.lo
Removing lib/libcurl_la-file.o
Removing lib/libcurl_la-fileinfo.lo
Removing lib/libcurl_la-fileinfo.o
Removing lib/libcurl_la-fopen.lo
Removing lib/libcurl_la-fopen.o
Removing lib/libcurl_la-formdata.lo
Removing lib/libcurl_la-formdata.o
Removing lib/libcurl_la-ftp.lo
Removing lib/libcurl_la-ftp.o
Removing lib/libcurl_la-ftplistparser.lo
Removing lib/libcurl_la-ftplistparser.o
Removing lib/libcurl_la-getenv.lo
Removing lib/libcurl_la-getenv.o
Removing lib/libcurl_la-getinfo.lo
Removing lib/libcurl_la-getinfo.o
Removing lib/libcurl_la-gopher.lo
Removing lib/libcurl_la-gopher.o
Removing lib/libcurl_la-h2h3.lo
Removing lib/libcurl_la-h2h3.o
Removing lib/libcurl_la-hash.lo
Removing lib/libcurl_la-hash.o
Removing lib/libcurl_la-headers.lo
Removing lib/libcurl_la-headers.o
Removing lib/libcurl_la-hmac.lo
Removing lib/libcurl_la-hmac.o
Removing lib/libcurl_la-hostasyn.lo
Removing lib/libcurl_la-hostasyn.o
Removing lib/libcurl_la-hostip.lo
Removing lib/libcurl_la-hostip.o
Removing lib/libcurl_la-hostip4.lo
Removing lib/libcurl_la-hostip4.o
Removing lib/libcurl_la-hostip6.lo
Removing lib/libcurl_la-hostip6.o
Removing lib/libcurl_la-hostsyn.lo
Removing lib/libcurl_la-hostsyn.o
Removing lib/libcurl_la-hsts.lo
Removing lib/libcurl_la-hsts.o
Removing lib/libcurl_la-http.lo
Removing lib/libcurl_la-http.o
Removing lib/libcurl_la-http2.lo
Removing lib/libcurl_la-http2.o
Removing lib/libcurl_la-http_aws_sigv4.lo
Removing lib/libcurl_la-http_aws_sigv4.o
Removing lib/libcurl_la-http_chunks.lo
Removing lib/libcurl_la-http_chunks.o
Removing lib/libcurl_la-http_digest.lo
Removing lib/libcurl_la-http_digest.o
Removing lib/libcurl_la-http_negotiate.lo
Removing lib/libcurl_la-http_negotiate.o
Removing lib/libcurl_la-http_ntlm.lo
Removing lib/libcurl_la-http_ntlm.o
Removing lib/libcurl_la-http_proxy.lo
Removing lib/libcurl_la-http_proxy.o
Removing lib/libcurl_la-idn.lo
Removing lib/libcurl_la-idn.o
Removing lib/libcurl_la-if2ip.lo
Removing lib/libcurl_la-if2ip.o
Removing lib/libcurl_la-imap.lo
Removing lib/libcurl_la-imap.o
Removing lib/libcurl_la-inet_ntop.lo
Removing lib/libcurl_la-inet_ntop.o
Removing lib/libcurl_la-inet_pton.lo
Removing lib/libcurl_la-inet_pton.o
Removing lib/libcurl_la-krb5.lo
Removing lib/libcurl_la-krb5.o
Removing lib/libcurl_la-ldap.lo
Removing lib/libcurl_la-ldap.o
Removing lib/libcurl_la-llist.lo
Removing lib/libcurl_la-llist.o
Removing lib/libcurl_la-md4.lo
Removing lib/libcurl_la-md4.o
Removing lib/libcurl_la-md5.lo
Removing lib/libcurl_la-md5.o
Removing lib/libcurl_la-memdebug.lo
Removing lib/libcurl_la-memdebug.o
Removing lib/libcurl_la-mime.lo
Removing lib/libcurl_la-mime.o
Removing lib/libcurl_la-mprintf.lo
Removing lib/libcurl_la-mprintf.o
Removing lib/libcurl_la-mqtt.lo
Removing lib/libcurl_la-mqtt.o
Removing lib/libcurl_la-multi.lo
Removing lib/libcurl_la-multi.o
Removing lib/libcurl_la-netrc.lo
Removing lib/libcurl_la-netrc.o
Removing lib/libcurl_la-nonblock.lo
Removing lib/libcurl_la-nonblock.o
Removing lib/libcurl_la-noproxy.lo
Removing lib/libcurl_la-noproxy.o
Removing lib/libcurl_la-openldap.lo
Removing lib/libcurl_la-openldap.o
Removing lib/libcurl_la-parsedate.lo
Removing lib/libcurl_la-parsedate.o
Removing lib/libcurl_la-pingpong.lo
Removing lib/libcurl_la-pingpong.o
Removing lib/libcurl_la-pop3.lo
Removing lib/libcurl_la-pop3.o
Removing lib/libcurl_la-progress.lo
Removing lib/libcurl_la-progress.o
Removing lib/libcurl_la-psl.lo
Removing lib/libcurl_la-psl.o
Removing lib/libcurl_la-rand.lo
Removing lib/libcurl_la-rand.o
Removing lib/libcurl_la-rename.lo
Removing lib/libcurl_la-rename.o
Removing lib/libcurl_la-rtsp.lo
Removing lib/libcurl_la-rtsp.o
Removing lib/libcurl_la-select.lo
Removing lib/libcurl_la-select.o
Removing lib/libcurl_la-sendf.lo
Removing lib/libcurl_la-sendf.o
Removing lib/libcurl_la-setopt.lo
Removing lib/libcurl_la-setopt.o
Removing lib/libcurl_la-sha256.lo
Removing lib/libcurl_la-sha256.o
Removing lib/libcurl_la-share.lo
Removing lib/libcurl_la-share.o
Removing lib/libcurl_la-slist.lo
Removing lib/libcurl_la-slist.o
Removing lib/libcurl_la-smb.lo
Removing lib/libcurl_la-smb.o
Removing lib/libcurl_la-smtp.lo
Removing lib/libcurl_la-smtp.o
Removing lib/libcurl_la-socketpair.lo
Removing lib/libcurl_la-socketpair.o
Removing lib/libcurl_la-socks.lo
Removing lib/libcurl_la-socks.o
Removing lib/libcurl_la-socks_gssapi.lo
Removing lib/libcurl_la-socks_gssapi.o
Removing lib/libcurl_la-socks_sspi.lo
Removing lib/libcurl_la-socks_sspi.o
Removing lib/libcurl_la-speedcheck.lo
Removing lib/libcurl_la-speedcheck.o
Removing lib/libcurl_la-splay.lo
Removing lib/libcurl_la-splay.o
Removing lib/libcurl_la-strcase.lo
Removing lib/libcurl_la-strcase.o
Removing lib/libcurl_la-strdup.lo
Removing lib/libcurl_la-strdup.o
Removing lib/libcurl_la-strerror.lo
Removing lib/libcurl_la-strerror.o
Removing lib/libcurl_la-strtok.lo
Removing lib/libcurl_la-strtok.o
Removing lib/libcurl_la-strtoofft.lo
Removing lib/libcurl_la-strtoofft.o
Removing lib/libcurl_la-system_win32.lo
Removing lib/libcurl_la-system_win32.o
Removing lib/libcurl_la-telnet.lo
Removing lib/libcurl_la-telnet.o
Removing lib/libcurl_la-tftp.lo
Removing lib/libcurl_la-tftp.o
Removing lib/libcurl_la-timediff.lo
Removing lib/libcurl_la-timediff.o
Removing lib/libcurl_la-timeval.lo
Removing lib/libcurl_la-timeval.o
Removing lib/libcurl_la-transfer.lo
Removing lib/libcurl_la-transfer.o
Removing lib/libcurl_la-url.lo
Removing lib/libcurl_la-url.o
Removing lib/libcurl_la-urlapi.lo
Removing lib/libcurl_la-urlapi.o
Removing lib/libcurl_la-version.lo
Removing lib/libcurl_la-version.o
Removing lib/libcurl_la-version_win32.lo
Removing lib/libcurl_la-version_win32.o
Removing lib/libcurl_la-warnless.lo
Removing lib/libcurl_la-warnless.o
Removing lib/libcurl_la-ws.lo
Removing lib/libcurl_la-ws.o
Removing lib/nonblock.o
Removing lib/stamp-h1
Removing lib/strtoofft.o
Removing lib/timediff.o
Removing lib/vauth/.deps/
Removing lib/vauth/.dirstamp
Removing lib/vauth/libcurl_la-cleartext.lo
Removing lib/vauth/libcurl_la-cleartext.o
Removing lib/vauth/libcurl_la-cram.lo
Removing lib/vauth/libcurl_la-cram.o
Removing lib/vauth/libcurl_la-digest.lo
Removing lib/vauth/libcurl_la-digest.o
Removing lib/vauth/libcurl_la-digest_sspi.lo
Removing lib/vauth/libcurl_la-digest_sspi.o
Removing lib/vauth/libcurl_la-gsasl.lo
Removing lib/vauth/libcurl_la-gsasl.o
Removing lib/vauth/libcurl_la-krb5_gssapi.lo
Removing lib/vauth/libcurl_la-krb5_gssapi.o
Removing lib/vauth/libcurl_la-krb5_sspi.lo
Removing lib/vauth/libcurl_la-krb5_sspi.o
Removing lib/vauth/libcurl_la-ntlm.lo
Removing lib/vauth/libcurl_la-ntlm.o
Removing lib/vauth/libcurl_la-ntlm_sspi.lo
Removing lib/vauth/libcurl_la-ntlm_sspi.o
Removing lib/vauth/libcurl_la-oauth2.lo
Removing lib/vauth/libcurl_la-oauth2.o
Removing lib/vauth/libcurl_la-spnego_gssapi.lo
Removing lib/vauth/libcurl_la-spnego_gssapi.o
Removing lib/vauth/libcurl_la-spnego_sspi.lo
Removing lib/vauth/libcurl_la-spnego_sspi.o
Removing lib/vauth/libcurl_la-vauth.lo
Removing lib/vauth/libcurl_la-vauth.o
Removing lib/version_win32.o
Removing lib/vquic/.deps/
Removing lib/vquic/.dirstamp
Removing lib/vquic/libcurl_la-curl_msh3.lo
Removing lib/vquic/libcurl_la-curl_msh3.o
Removing lib/vquic/libcurl_la-curl_ngtcp2.lo
Removing lib/vquic/libcurl_la-curl_ngtcp2.o
Removing lib/vquic/libcurl_la-curl_quiche.lo
Removing lib/vquic/libcurl_la-curl_quiche.o
Removing lib/vquic/libcurl_la-vquic.lo
Removing lib/vquic/libcurl_la-vquic.o
Removing lib/vssh/.deps/
Removing lib/vssh/.dirstamp
Removing lib/vssh/libcurl_la-libssh.lo
Removing lib/vssh/libcurl_la-libssh.o
Removing lib/vssh/libcurl_la-libssh2.lo
Removing lib/vssh/libcurl_la-libssh2.o
Removing lib/vssh/libcurl_la-wolfssh.lo
Removing lib/vssh/libcurl_la-wolfssh.o
Removing lib/vtls/.deps/
Removing lib/vtls/.dirstamp
Removing lib/vtls/libcurl_la-bearssl.lo
Removing lib/vtls/libcurl_la-bearssl.o
Removing lib/vtls/libcurl_la-gskit.lo
Removing lib/vtls/libcurl_la-gskit.o
Removing lib/vtls/libcurl_la-gtls.lo
Removing lib/vtls/libcurl_la-gtls.o
Removing lib/vtls/libcurl_la-hostcheck.lo
Removing lib/vtls/libcurl_la-hostcheck.o
Removing lib/vtls/libcurl_la-keylog.lo
Removing lib/vtls/libcurl_la-keylog.o
Removing lib/vtls/libcurl_la-mbedtls.lo
Removing lib/vtls/libcurl_la-mbedtls.o
Removing lib/vtls/libcurl_la-mbedtls_threadlock.lo
Removing lib/vtls/libcurl_la-mbedtls_threadlock.o
Removing lib/vtls/libcurl_la-nss.lo
Removing lib/vtls/libcurl_la-nss.o
Removing lib/vtls/libcurl_la-openssl.lo
Removing lib/vtls/libcurl_la-openssl.o
Removing lib/vtls/libcurl_la-rustls.lo
Removing lib/vtls/libcurl_la-rustls.o
Removing lib/vtls/libcurl_la-schannel.lo
Removing lib/vtls/libcurl_la-schannel.o
Removing lib/vtls/libcurl_la-schannel_verify.lo
Removing lib/vtls/libcurl_la-schannel_verify.o
Removing lib/vtls/libcurl_la-sectransp.lo
Removing lib/vtls/libcurl_la-sectransp.o
Removing lib/vtls/libcurl_la-vtls.lo
Removing lib/vtls/libcurl_la-vtls.o
Removing lib/vtls/libcurl_la-wolfssl.lo
Removing lib/vtls/libcurl_la-wolfssl.o
Removing lib/vtls/libcurl_la-x509asn1.lo
Removing lib/vtls/libcurl_la-x509asn1.o
Removing lib/warnless.o
Removing libcurl.pc
Removing libtool
Removing ltmain.sh
Removing m4/libtool.m4
Removing m4/ltoptions.m4
Removing m4/ltsugar.m4
Removing m4/ltversion.m4
Removing m4/lt~obsolete.m4
Removing missing
Removing packages/Makefile
Removing packages/Makefile.in
Removing packages/vms/Makefile
Removing packages/vms/Makefile.in
Removing scripts/Makefile
Removing scripts/Makefile.in
Removing src/.deps/
Removing src/.libs/
Removing src/Makefile
Removing src/Makefile.in
Removing src/curl
Removing src/slist_wc.o
Removing src/tool_binmode.o
Removing src/tool_bname.o
Removing src/tool_cb_dbg.o
Removing src/tool_cb_hdr.o
Removing src/tool_cb_prg.o
Removing src/tool_cb_rea.o
Removing src/tool_cb_see.o
Removing src/tool_cb_wrt.o
Removing src/tool_cfgable.o
Removing src/tool_dirhie.o
Removing src/tool_doswin.o
Removing src/tool_easysrc.o
Removing src/tool_filetime.o
Removing src/tool_findfile.o
Removing src/tool_formparse.o
Removing src/tool_getparam.o
Removing src/tool_getpass.o
Removing src/tool_help.o
Removing src/tool_helpers.o
Removing src/tool_hugehelp.c
Removing src/tool_hugehelp.o
Removing src/tool_libinfo.o
Removing src/tool_listhelp.o
Removing src/tool_main.o
Removing src/tool_msgs.o
Removing src/tool_operate.o
Removing src/tool_operhlp.o
Removing src/tool_paramhlp.o
Removing src/tool_parsecfg.o
Removing src/tool_progress.o
Removing src/tool_setopt.o
Removing src/tool_sleep.o
Removing src/tool_stderr.o
Removing src/tool_strdup.o
Removing src/tool_urlglob.o
Removing src/tool_util.o
Removing src/tool_vms.o
Removing src/tool_writeout.o
Removing src/tool_writeout_json.o
Removing src/tool_xattr.o
Removing test-driver
Removing tests/Makefile
Removing tests/Makefile.in
Removing tests/certs/Makefile
Removing tests/certs/Makefile.in
Removing tests/certs/scripts/Makefile
Removing tests/certs/scripts/Makefile.in
Removing tests/config
Removing tests/configurehelp.pm
Removing tests/data/Makefile
Removing tests/data/Makefile.in
Removing tests/http/Makefile
Removing tests/http/Makefile.in
Removing tests/http/config.ini
Removing tests/libtest/.deps/
Removing tests/libtest/Makefile
Removing tests/libtest/Makefile.in
Removing tests/server/.deps/
Removing tests/server/Makefile
Removing tests/server/Makefile.in
Removing tests/unit/.deps/
Removing tests/unit/Makefile
Removing tests/unit/Makefile.in
$ autoreconf -fi
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
libtoolize: Remember to add 'LT_INIT' to configure.ac.
configure.ac:123: installing './compile'
configure.ac:428: installing './config.guess'
configure.ac:428: installing './config.sub'
configure.ac:123: installing './install-sh'
configure.ac:129: installing './missing'
docs/examples/Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'
$ bash -c find . -name config.guess -exec cp /usr/share/misc/config.guess {} \;
$ bash -c find . -name config.sub -exec cp /usr/share/misc/config.sub {} \;
$ chmod +x configure
$ ./configure --disable-shared --without-ssl --disable-docs
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... yes
checking whether to enable debug build options... no
checking whether to enable compiler optimizer... (assumed) yes
checking whether to enable strict compiler warnings... no
checking whether to enable compiler warnings as errors... no
checking whether to enable curl debug memory tracking... no
checking whether to enable hiding of library internal symbols... yes
checking whether to enable c-ares for DNS lookups... no
checking whether to disable dependency on -lrt... (assumed no)
checking whether to enable ECH support... no
checking for path separator... :
checking for sed... /usr/bin/sed
checking for grep... /usr/bin/grep
checking that grep -E works... yes
checking for ar... /usr/bin/ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... ccache gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether ccache gcc accepts -g... yes
checking for ccache gcc option to enable C11 features... none needed
checking whether ccache gcc understands -c and -o together... yes
checking how to run the C preprocessor... ccache gcc -E
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for stdatomic.h... yes
checking if _Atomic is available... yes
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for code coverage support... no
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of ccache gcc... gcc3
checking curl version... 8.1.0-DEV
checking for httpd... no
checking for apache2... no
checking for apachectl... no
checking for apxs... no
configure: httpd/apache2 not in PATH, http tests disabled
configure: apxs not in PATH, http tests disabled
checking for nghttpx... no
checking for caddy... no
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for grep that handles long lines and -e... (cached) /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking if OS is AIX (to define _ALL_SOURCE)... no
checking if _THREAD_SAFE is already defined... no
checking if _THREAD_SAFE is actually needed... no
checking if _THREAD_SAFE is onwards defined... no
checking if _REENTRANT is already defined... no
checking if _REENTRANT is actually needed... no
checking if _REENTRANT is onwards defined... no
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by ccache gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from ccache gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if ccache gcc supports -fno-rtti -fno-exceptions... no
checking for ccache gcc option to produce PIC... -fPIC -DPIC
checking if ccache gcc PIC flag -fPIC -DPIC works... yes
checking if ccache gcc static flag -static works... yes
checking if ccache gcc supports -c -o file.o... yes
checking if ccache gcc supports -c -o file.o... (cached) yes
checking whether the ccache gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking whether to build shared libraries with -version-info... yes
checking whether to build shared libraries with -no-undefined... no
checking whether to build shared libraries with -mimpure-text... no
checking whether to build shared libraries with PIC... yes
checking whether to build static libraries with PIC... yes
checking whether to build shared libraries only... no
checking whether to build static libraries only... yes
checking for windres... no
checking for inline... inline
checking if cpp -P is needed... yes
checking if cpp -P works... yes
checking if compiler is DEC/Compaq/HP C... no
checking if compiler is HP-UX C... no
checking if compiler is IBM C... no
checking if compiler is Intel C... no
checking if compiler is clang... no
checking if compiler is GNU C... yes
checking if compiler is LCC... no
checking if compiler is SGI MIPSpro C... no
checking if compiler is SGI MIPS C... no
checking if compiler is SunPro C... no
checking if compiler is Tiny C... no
checking if compiler accepts some basic options... yes
configure: compiler options added: -Werror-implicit-function-declaration
checking if compiler optimizer assumed setting might be used... yes
checking if compiler accepts optimizer enabling options... yes
configure: compiler options added: -O2
checking if compiler accepts strict warning options... yes
configure: compiler options added: -Wno-system-headers
checking if compiler halts on compilation errors... yes
checking if compiler halts on negative sized arrays... yes
checking if compiler halts on function prototype mismatch... yes
checking if compiler supports hiding library internal symbols... yes
checking for windows.h... no
checking whether build target is a native Windows one... no
checking whether build target supports WIN32 file API... no
checking whether build target supports WIN32 crypto API... no
checking for good-to-use Darwin CFLAGS... no
checking whether to link macOS CoreFoundation and SystemConfiguration framework... no
checking to see if the compiler supports __builtin_available()... no
checking whether to support http... yes
checking whether to support ftp... yes
checking whether to support file... yes
checking whether to support ldap... yes
checking whether to support ldaps... yes
checking whether to support rtsp... yes
checking whether to support proxies... yes
checking whether to support dict... yes
checking whether to support telnet... yes
checking whether to support tftp... yes
checking whether to support pop3... yes
checking whether to support imap... yes
checking whether to support smb... yes
checking whether to support smtp... yes
checking whether to support gopher... yes
checking whether to support mqtt... no
checking whether to provide built-in manual... yes
checking whether to enable generation of C code... yes
checking whether to use libgcc... no
checking if X/Open network library is required... no
checking for gethostbyname... yes
checking for windows.h... (cached) no
checking for winsock2.h... (cached) no
checking for proto/bsdsocket.h... no
checking for connect in libraries... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... yes
checking for monotonic clock_gettime... yes
checking for clock_gettime in libraries... no additional lib required
checking if monotonic clock_gettime works... yes
checking for pkg-config... /usr/bin/pkg-config
checking for zlib options with pkg-config... found
checking for zlib.h... yes
configure: found both libz and libz.h header
checking for BrotliDecoderDecompress in -lbrotlidec... no
checking for brotli/decode.h... no
checking for ZSTD_createDStream in -lzstd... no
checking for zstd.h... no
checking for lber.h... no
checking for ldap.h... no
checking for ldap_ssl.h... no
checking for LDAP libraries... cannot find LDAP libraries
checking whether to enable IPv6... yes
checking if struct sockaddr_in6 has sin6_scope_id member... yes
checking if argv can be written to... yes
checking if GSS-API support is requested... no
checking whether to enable Windows native SSL/TLS... no
checking whether to enable Secure Transport... no
checking whether to enable Amiga native SSL/TLS (AmiSSL v5)... no
checking for library containing psl_builtin... -lpsl
checking for library containing gsasl_init... no
checking for RTMP_Init in -lrtmp... no
checking whether versioned symbols are wanted... no
checking whether to enable Windows native IDN (Windows native builds only)... no
checking whether to build with libidn2... (assumed) yes
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for libidn2 options with pkg-config... no
configure: IDN_LIBS: "-lidn2"
configure: IDN_LDFLAGS: ""
configure: IDN_CPPFLAGS: ""
configure: IDN_DIR: ""
checking if idn2_lookup_ul can be linked... no
checking for idn2.h... no
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for libnghttp2 options with pkg-config... no
checking for nghttp2_session_set_local_window_size in -lnghttp2... no
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for fish options with pkg-config... no
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for sys/select.h... yes
checking for sys/socket.h... yes
checking for sys/ioctl.h... yes
checking for sys/uio.h... yes
checking for unistd.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for arpa/inet.h... yes
checking for net/if.h... yes
checking for netinet/in.h... yes
checking for netinet/in6.h... no
checking for sys/un.h... yes
checking for linux/tcp.h... yes
checking for netinet/tcp.h... yes
checking for netinet/udp.h... yes
checking for netdb.h... yes
checking for sys/sockio.h... no
checking for sys/stat.h... (cached) yes
checking for sys/param.h... yes
checking for termios.h... yes
checking for termio.h... yes
checking for fcntl.h... yes
checking for io.h... no
checking for pwd.h... yes
checking for utime.h... yes
checking for sys/utime.h... no
checking for sys/poll.h... yes
checking for poll.h... yes
checking for socket.h... no
checking for sys/resource.h... yes
checking for libgen.h... yes
checking for locale.h... yes
checking for stdbool.h... yes
checking for arpa/tftp.h... yes
checking for sys/filio.h... no
checking for sys/wait.h... yes
checking for setjmp.h... yes
checking for an ANSI C-conforming const... yes
checking for compiler support of C99 variadic macro style... yes
checking for compiler support of old gcc variadic macro style... yes
checking for size_t... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for struct timeval... yes
checking run-time libs availability... fine
checking size of size_t... 8
checking size of long... 8
checking size of int... 4
checking size of time_t... 8
checking size of off_t... 8
checking size of curl_off_t... 8
checking size of curl_socket_t... 4
checking for long long... yes
checking for ssize_t... yes
checking for bool... yes
checking for sa_family_t... yes
checking for suseconds_t... yes
checking if time_t is unsigned... no
checking for sys/types.h... (cached) yes
checking for poll.h... (cached) yes
checking for sys/poll.h... (cached) yes
checking for in_addr_t... yes
checking for struct sockaddr_storage... yes
checking for sys/select.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for select... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for recv... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for send... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for MSG_NOSIGNAL... yes
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking if alarm can be linked... yes
checking if alarm is prototyped... yes
checking if alarm is compilable... yes
checking if alarm usage allowed... yes
checking if alarm might be used... yes
checking for sys/types.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for libgen.h... (cached) yes
checking if basename can be linked... yes
checking if basename is prototyped... yes
checking if basename is compilable... yes
checking if basename usage allowed... yes
checking if basename might be used... yes
checking for sys/types.h... (cached) yes
checking for socket.h... (cached) no
checking if closesocket can be linked... no
checking if closesocket might be used... no
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking if CloseSocket can be linked... no
checking if CloseSocket might be used... no
checking if connect can be linked... yes
checking if connect is prototyped... yes
checking if connect is compilable... yes
checking if connect usage allowed... yes
checking if connect might be used... yes
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking for fcntl.h... (cached) yes
checking if fcntl can be linked... yes
checking if fcntl is prototyped... yes
checking if fcntl is compilable... yes
checking if fcntl usage allowed... yes
checking if fcntl might be used... yes
checking if fcntl O_NONBLOCK is compilable... yes
checking if fcntl O_NONBLOCK usage allowed... yes
checking if fcntl O_NONBLOCK might be used... yes
checking for windows.h... (cached) no
checking for winsock2.h... (cached) no
checking for ws2tcpip.h... (cached) no
checking for sys/types.h... (cached) yes
checking for netdb.h... (cached) yes
checking if freeaddrinfo can be linked... yes
checking if freeaddrinfo is prototyped... yes
checking if freeaddrinfo is compilable... yes
checking if freeaddrinfo usage allowed... yes
checking if freeaddrinfo might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/xattr.h... yes
checking if fsetxattr can be linked... yes
checking if fsetxattr is prototyped... yes
checking if fsetxattr takes 5 args.... yes
checking if fsetxattr is compilable... yes
checking if fsetxattr usage allowed... yes
checking if fsetxattr might be used... yes
checking if ftruncate can be linked... yes
checking if ftruncate is prototyped... yes
checking if ftruncate is compilable... yes
checking if ftruncate usage allowed... yes
checking if ftruncate might be used... yes
checking for sys/types.h... (cached) yes
checking for stdlib.h... (cached) yes
checking if getaddrinfo can be linked... yes
checking if getaddrinfo is prototyped... yes
checking if getaddrinfo is compilable... yes
checking if getaddrinfo seems to work... yes
checking if getaddrinfo usage allowed... yes
checking if getaddrinfo might be used... yes
checking if getaddrinfo is threadsafe... yes
checking if gethostbyname can be linked... yes
checking if gethostbyname is prototyped... yes
checking if gethostbyname is compilable... yes
checking if gethostbyname usage allowed... yes
checking if gethostbyname might be used... yes
checking if gethostbyname_r can be linked... yes
checking if gethostbyname_r is prototyped... yes
checking if gethostbyname_r takes 3 args.... no
checking if gethostbyname_r takes 5 args.... no
checking if gethostbyname_r takes 6 args.... yes
checking if gethostbyname_r is compilable... yes
checking if gethostbyname_r usage allowed... yes
checking if gethostbyname_r might be used... yes
checking if gethostname can be linked... yes
checking if gethostname is prototyped... yes
checking if gethostname is compilable... yes
checking for gethostname arg 2 data type... size_t
checking if gethostname usage allowed... yes
checking if gethostname might be used... yes
checking if getpeername can be linked... yes
checking if getpeername is prototyped... yes
checking if getpeername is compilable... yes
checking if getpeername usage allowed... yes
checking if getpeername might be used... yes
checking if getsockname can be linked... yes
checking if getsockname is prototyped... yes
checking if getsockname is compilable... yes
checking if getsockname usage allowed... yes
checking if getsockname might be used... yes
checking for net/if.h... (cached) yes
checking if if_nametoindex can be linked... yes
checking if if_nametoindex is prototyped... yes
checking if if_nametoindex is compilable... yes
checking if if_nametoindex usage allowed... yes
checking if if_nametoindex might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for netinet/in.h... (cached) yes
checking for ifaddrs.h... yes
checking if getifaddrs can be linked... yes
checking if getifaddrs is prototyped... yes
checking if getifaddrs is compilable... yes
checking if getifaddrs seems to work... yes
checking if getifaddrs usage allowed... yes
checking if getifaddrs might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking if gmtime_r can be linked... yes
checking if gmtime_r is prototyped... yes
checking if gmtime_r is compilable... yes
checking if gmtime_r seems to work... yes
checking if gmtime_r usage allowed... yes
checking if gmtime_r might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for netinet/in.h... (cached) yes
checking for arpa/inet.h... (cached) yes
checking if inet_ntop can be linked... yes
checking if inet_ntop is prototyped... yes
checking if inet_ntop is compilable... yes
checking if inet_ntop seems to work... yes
checking if inet_ntop usage allowed... yes
checking if inet_ntop might be used... yes
checking if inet_pton can be linked... yes
checking if inet_pton is prototyped... yes
checking if inet_pton is compilable... yes
checking if inet_pton seems to work... yes
checking if inet_pton usage allowed... yes
checking if inet_pton might be used... yes
checking if ioctlsocket can be linked... no
checking if ioctlsocket might be used... no
checking if IoctlSocket can be linked... no
checking if IoctlSocket might be used... no
checking if memrchr can be linked... yes
checking if memrchr is prototyped... no
checking if memrchr might be used... no
checking if poll can be linked... yes
checking if poll is prototyped... yes
checking if poll is compilable... yes
checking if poll seems to work... yes
checking if poll usage allowed... yes
checking if poll might be used... yes
checking for sys/types.h... (cached) yes
checking for signal.h... yes
checking if sigaction can be linked... yes
checking if sigaction is prototyped... yes
checking if sigaction is compilable... yes
checking if sigaction usage allowed... yes
checking if sigaction might be used... yes
checking if siginterrupt can be linked... yes
checking if siginterrupt is prototyped... yes
checking if siginterrupt is compilable... yes
checking if siginterrupt usage allowed... yes
checking if siginterrupt might be used... yes
checking if signal can be linked... yes
checking if signal is prototyped... yes
checking if signal is compilable... yes
checking if signal usage allowed... yes
checking if signal might be used... yes
checking for sys/types.h... (cached) yes
checking for setjmp.h... (cached) yes
checking if sigsetjmp can be linked... no
checking if sigsetjmp seems a macro... yes
checking if sigsetjmp is compilable... yes
checking if sigsetjmp usage allowed... yes
checking if sigsetjmp might be used... yes
checking if socket can be linked... yes
checking if socket is prototyped... yes
checking if socket is compilable... yes
checking if socket usage allowed... yes
checking if socket might be used... yes
checking if socketpair can be linked... yes
checking if socketpair is prototyped... yes
checking if socketpair is compilable... yes
checking if socketpair usage allowed... yes
checking if socketpair might be used... yes
checking if strcasecmp can be linked... yes
checking if strcasecmp is prototyped... yes
checking if strcasecmp is compilable... yes
checking if strcasecmp usage allowed... yes
checking if strcasecmp might be used... yes
checking if strcmpi can be linked... no
checking if strcmpi might be used... no
checking if strdup can be linked... yes
checking if strdup is prototyped... yes
checking if strdup is compilable... yes
checking if strdup usage allowed... yes
checking if strdup might be used... yes
checking if strerror_r can be linked... yes
checking if strerror_r is prototyped... yes
checking if strerror_r is compilable... yes
checking if strerror_r is glibc like... no
checking if strerror_r is POSIX like... yes
checking if strerror_r seems to work... yes
checking if strerror_r usage allowed... yes
checking if strerror_r might be used... yes
checking if stricmp can be linked... no
checking if stricmp might be used... no
checking if strtok_r can be linked... yes
checking if strtok_r is prototyped... yes
checking if strtok_r is compilable... yes
checking if strtok_r usage allowed... yes
checking if strtok_r might be used... yes
checking if strtoll can be linked... yes
checking if strtoll is prototyped... yes
checking if strtoll is compilable... yes
checking if strtoll usage allowed... yes
checking if strtoll might be used... yes
checking for ccache gcc options needed to detect all undeclared functions... none needed
checking whether getpwuid_r is declared... yes
checking for fnmatch... yes
checking for fchmod... yes
checking for fork... yes
checking for geteuid... yes
checking for getpass_r... no
checking deeper for getpass_r... but still no
checking for getppid... yes
checking for getpwuid... yes
checking for getpwuid_r... yes
checking for getrlimit... yes
checking for gettimeofday... yes
checking for if_nametoindex... yes
checking for mach_absolute_time... no
checking deeper for mach_absolute_time... but still no
checking for pipe... yes
checking for sched_yield... yes
checking for sendmsg... yes
checking for setlocale... yes
checking for setmode... no
checking deeper for setmode... but still no
checking for setrlimit... yes
checking for snprintf... yes
checking for utime... yes
checking for utimes... yes
checking for arc4random... no
checking deeper for arc4random... but still no
checking how to set a socket into non-blocking mode... fcntl O_NONBLOCK
checking for perl... /usr/bin/perl
checking for gnroff... no
checking for nroff... /usr/bin/nroff
checking how to use *nroff to get plain text from man pages... -man
checking whether to enable the threaded resolver... yes
checking whether to use POSIX threads for threaded resolver... auto
checking for pthread.h... yes
checking for pthread_create... yes
checking convert -I options to -isystem... yes
checking whether to enable verbose strings... yes
checking whether to enable SSPI support (Windows native builds only)... no
checking whether to enable cryptographic authentication methods... yes
checking whether to support NTLM... yes
checking whether to enable NTLM delegation to winbind's helper... no
checking whether to enable TLS-SRP authentication... yes
checking whether to enable Unix domain sockets... auto
checking for struct sockaddr_un.sun_path... yes
checking whether to support cookies... yes
checking whether to support socketpair... yes
checking whether to support HTTP authentication... yes
checking whether to support DoH... yes
checking whether to support the MIME API... yes
checking whether to support date parsing... yes
checking whether to support netrc parsing... yes
checking whether to support progress-meter... yes
checking whether to support DNS shuffling... yes
checking whether to support curl_easy_option*... yes
checking whether to support alt-svc... yes
checking whether to support headers-api... yes
configure: disables HSTS due to lack of SSL
checking whether to support WebSockets... no
checking whether hiding of library internal symbols will actually happen... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating docs/Makefile
config.status: creating docs/examples/Makefile
config.status: creating docs/libcurl/Makefile
config.status: creating docs/libcurl/opts/Makefile
config.status: creating docs/cmdline-opts/Makefile
config.status: creating include/Makefile
config.status: creating include/curl/Makefile
config.status: creating src/Makefile
config.status: creating lib/Makefile
config.status: creating scripts/Makefile
config.status: creating lib/libcurl.vers
config.status: creating lib/libcurl.plist
config.status: creating tests/Makefile
config.status: creating tests/config
config.status: creating tests/certs/Makefile
config.status: creating tests/certs/scripts/Makefile
config.status: creating tests/data/Makefile
config.status: creating tests/server/Makefile
config.status: creating tests/libtest/Makefile
config.status: creating tests/unit/Makefile
config.status: creating tests/http/config.ini
config.status: creating tests/http/Makefile
config.status: creating packages/Makefile
config.status: creating packages/vms/Makefile
config.status: creating curl-config
config.status: creating libcurl.pc
config.status: creating lib/curl_config.h
config.status: executing depfiles commands
config.status: executing libtool commands
configure: Configured to build curl/libcurl:
Host setup: x86_64-pc-linux-gnu
Install prefix: /usr/local
Compiler: ccache gcc
CFLAGS: -Werror-implicit-function-declaration -O2 -Wno-system-headers
CPPFLAGS:
LDFLAGS:
LIBS: -lpsl -lz
curl version: 8.1.0-DEV
SSL: no (--with-{openssl,gnutls,nss,mbedtls,wolfssl,schannel,secure-transport,amissl,bearssl,rustls} )
SSH: no (--with-{libssh,libssh2})
zlib: enabled
brotli: no (--with-brotli)
zstd: no (--with-zstd)
GSS-API: no (--with-gssapi)
GSASL: no (libgsasl not found)
TLS-SRP: no (--enable-tls-srp)
resolver: POSIX threaded
IPv6: enabled
Unix sockets: enabled
IDN: no (--with-{libidn2,winidn})
Build libcurl: Shared=no, Static=yes
Built-in manual: enabled
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
Code coverage: disabled
SSPI: no (--enable-sspi)
ca cert bundle: no
ca cert path:
ca fallback:
LDAP: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS: no (--enable-ldaps)
RTSP: enabled
RTMP: no (--with-librtmp)
PSL: enabled
Alt-svc: enabled (--disable-alt-svc)
Headers API: enabled (--disable-headers-api)
HSTS: no (--enable-hsts)
HTTP1: enabled (internal)
HTTP2: no (--with-nghttp2, --with-hyper)
HTTP3: no (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-msh3)
ECH: no (--enable-ech)
WebSockets: no (--enable-websockets)
Protocols: DICT FILE FTP GOPHER HTTP IMAP MQTT POP3 RTSP SMTP TELNET TFTP
Features: AsynchDNS IPv6 Largefile PSL UnixSockets alt-svc libz threadsafe
configure: WARNING: unrecognized options: --disable-docs
configure: WARNING: Cannot find libraries for LDAP support: LDAP disabled
configure: WARNING: libgsasl was not found
configure: WARNING: Cannot find libraries for IDN support: IDN disabled
configure: WARNING: unrecognized options: --disable-docs
$ make -j3
Making all in lib
make[1]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/lib'
make all-am
make[2]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/lib'
CC libcurl_la-altsvc.lo
CC libcurl_la-amigaos.lo
CC libcurl_la-asyn-ares.lo
CC libcurl_la-asyn-thread.lo
CC libcurl_la-base64.lo
CC libcurl_la-bufq.lo
CC libcurl_la-bufref.lo
CC libcurl_la-c-hyper.lo
CC libcurl_la-cf-h1-proxy.lo
CC libcurl_la-cf-h2-proxy.lo
CC libcurl_la-cf-haproxy.lo
CC libcurl_la-cf-https-connect.lo
CC libcurl_la-cf-socket.lo
CC libcurl_la-cfilters.lo
CC libcurl_la-conncache.lo
CC libcurl_la-connect.lo
CC libcurl_la-content_encoding.lo
CC libcurl_la-cookie.lo
CC libcurl_la-curl_addrinfo.lo
CC libcurl_la-curl_des.lo
CC libcurl_la-curl_endian.lo
CC libcurl_la-curl_fnmatch.lo
CC libcurl_la-curl_get_line.lo
CC libcurl_la-curl_gethostname.lo
CC libcurl_la-curl_gssapi.lo
CC libcurl_la-curl_log.lo
CC libcurl_la-curl_memrchr.lo
CC libcurl_la-curl_multibyte.lo
CC libcurl_la-curl_ntlm_core.lo
CC libcurl_la-curl_ntlm_wb.lo
CC libcurl_la-curl_path.lo
CC libcurl_la-curl_range.lo
CC libcurl_la-curl_rtmp.lo
CC libcurl_la-curl_sasl.lo
CC libcurl_la-curl_sspi.lo
CC libcurl_la-curl_threads.lo
CC libcurl_la-dict.lo
CC libcurl_la-doh.lo
CC libcurl_la-dynbuf.lo
CC libcurl_la-dynhds.lo
CC libcurl_la-easy.lo
CC libcurl_la-easygetopt.lo
CC libcurl_la-easyoptions.lo
CC libcurl_la-escape.lo
CC libcurl_la-file.lo
CC libcurl_la-fileinfo.lo
CC libcurl_la-fopen.lo
CC libcurl_la-formdata.lo
CC libcurl_la-ftp.lo
CC libcurl_la-ftplistparser.lo
CC libcurl_la-getenv.lo
CC libcurl_la-getinfo.lo
CC libcurl_la-gopher.lo
CC libcurl_la-h2h3.lo
CC libcurl_la-hash.lo
CC libcurl_la-headers.lo
CC libcurl_la-hmac.lo
CC libcurl_la-hostasyn.lo
CC libcurl_la-hostip.lo
CC libcurl_la-hostip4.lo
CC libcurl_la-hostip6.lo
CC libcurl_la-hostsyn.lo
CC libcurl_la-hsts.lo
CC libcurl_la-http.lo
CC libcurl_la-http2.lo
CC libcurl_la-http_chunks.lo
CC libcurl_la-http_digest.lo
CC libcurl_la-http_negotiate.lo
CC libcurl_la-http_ntlm.lo
CC libcurl_la-http_proxy.lo
CC libcurl_la-http_aws_sigv4.lo
CC libcurl_la-idn.lo
CC libcurl_la-if2ip.lo
CC libcurl_la-imap.lo
CC libcurl_la-inet_ntop.lo
CC libcurl_la-inet_pton.lo
CC libcurl_la-krb5.lo
CC libcurl_la-ldap.lo
CC libcurl_la-llist.lo
CC libcurl_la-md4.lo
CC libcurl_la-md5.lo
CC libcurl_la-memdebug.lo
CC libcurl_la-mime.lo
CC libcurl_la-mprintf.lo
CC libcurl_la-mqtt.lo
CC libcurl_la-multi.lo
CC libcurl_la-netrc.lo
CC libcurl_la-nonblock.lo
CC libcurl_la-noproxy.lo
CC libcurl_la-openldap.lo
CC libcurl_la-parsedate.lo
CC libcurl_la-pingpong.lo
CC libcurl_la-pop3.lo
CC libcurl_la-progress.lo
CC libcurl_la-psl.lo
CC libcurl_la-rand.lo
CC libcurl_la-rename.lo
CC libcurl_la-rtsp.lo
CC libcurl_la-select.lo
CC libcurl_la-sendf.lo
CC libcurl_la-setopt.lo
CC libcurl_la-sha256.lo
CC libcurl_la-share.lo
CC libcurl_la-slist.lo
CC libcurl_la-smb.lo
CC libcurl_la-smtp.lo
CC libcurl_la-socketpair.lo
CC libcurl_la-socks.lo
CC libcurl_la-socks_gssapi.lo
CC libcurl_la-socks_sspi.lo
CC libcurl_la-speedcheck.lo
CC libcurl_la-splay.lo
CC libcurl_la-strcase.lo
CC libcurl_la-strdup.lo
CC libcurl_la-strerror.lo
CC libcurl_la-strtok.lo
CC libcurl_la-strtoofft.lo
CC libcurl_la-system_win32.lo
CC libcurl_la-telnet.lo
CC libcurl_la-tftp.lo
CC libcurl_la-timediff.lo
CC libcurl_la-timeval.lo
CC libcurl_la-transfer.lo
CC libcurl_la-url.lo
CC libcurl_la-urlapi.lo
CC libcurl_la-version_win32.lo
CC libcurl_la-version.lo
CC libcurl_la-warnless.lo
CC libcurl_la-ws.lo
CC vauth/libcurl_la-cleartext.lo
CC vauth/libcurl_la-cram.lo
CC vauth/libcurl_la-digest.lo
CC vauth/libcurl_la-digest_sspi.lo
CC vauth/libcurl_la-gsasl.lo
CC vauth/libcurl_la-krb5_gssapi.lo
CC vauth/libcurl_la-krb5_sspi.lo
CC vauth/libcurl_la-ntlm.lo
CC vauth/libcurl_la-ntlm_sspi.lo
CC vauth/libcurl_la-oauth2.lo
CC vauth/libcurl_la-spnego_gssapi.lo
CC vauth/libcurl_la-spnego_sspi.lo
CC vauth/libcurl_la-vauth.lo
CC vtls/libcurl_la-bearssl.lo
CC vtls/libcurl_la-gskit.lo
CC vtls/libcurl_la-gtls.lo
CC vtls/libcurl_la-hostcheck.lo
CC vtls/libcurl_la-keylog.lo
CC vtls/libcurl_la-mbedtls.lo
CC vtls/libcurl_la-mbedtls_threadlock.lo
CC vtls/libcurl_la-nss.lo
CC vtls/libcurl_la-openssl.lo
CC vtls/libcurl_la-rustls.lo
CC vtls/libcurl_la-schannel.lo
CC vtls/libcurl_la-schannel_verify.lo
CC vtls/libcurl_la-sectransp.lo
CC vtls/libcurl_la-vtls.lo
CC vtls/libcurl_la-wolfssl.lo
CC vtls/libcurl_la-x509asn1.lo
CC vquic/libcurl_la-curl_msh3.lo
CC vquic/libcurl_la-curl_ngtcp2.lo
CC vquic/libcurl_la-curl_quiche.lo
CC vquic/libcurl_la-vquic.lo
CC vssh/libcurl_la-libssh.lo
CC vssh/libcurl_la-libssh2.lo
CC vssh/libcurl_la-wolfssh.lo
CCLD libcurl.la
make[2]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/lib'
make[1]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/lib'
Making all in src
make[1]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/src'
Making all in ../docs
make[2]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/docs'
Making all in .
make[3]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/docs'
if test "..x" != "..x" -a -e "./curl.1"; then \
/usr/bin/install -c -m 644 "./curl.1" /root/asi_db/builds/curl/_worktrees/w0/docs/curl.1; fi
cd cmdline-opts && make
make[4]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/docs/cmdline-opts'
GENERATE ../../docs/curl.1
make[4]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/docs/cmdline-opts'
make[3]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/docs'
Making all in cmdline-opts
make[3]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/docs/cmdline-opts'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/docs/cmdline-opts'
make[2]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/docs'
make[2]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/src'
CC slist_wc.o
CC tool_binmode.o
CC tool_bname.o
CC tool_cb_dbg.o
CC tool_cb_hdr.o
CC tool_cb_prg.o
CC tool_cb_rea.o
CC tool_cb_see.o
CC tool_cb_wrt.o
CC tool_cfgable.o
CC tool_dirhie.o
CC tool_doswin.o
CC tool_easysrc.o
CC tool_filetime.o
CC tool_findfile.o
CC tool_formparse.o
CC tool_getpass.o
CC tool_getparam.o
CC tool_help.o
CC tool_helpers.o
HUGE tool_hugehelp.c
CC tool_libinfo.o
CC tool_listhelp.o
CC tool_main.o
CC tool_msgs.o
CC tool_operate.o
CC tool_operhlp.o
CC tool_paramhlp.o
CC tool_parsecfg.o
CC tool_progress.o
CC tool_stderr.o
CC tool_strdup.o
CC tool_setopt.o
CC tool_sleep.o
CC tool_urlglob.o
CC tool_util.o
CC tool_vms.o
CC tool_writeout.o
CC tool_writeout_json.o
CC tool_xattr.o
CC ../lib/strtoofft.o
CC ../lib/timediff.o
CC ../lib/nonblock.o
CC ../lib/warnless.o
CC ../lib/curl_multibyte.o
CC ../lib/version_win32.o
CC ../lib/dynbuf.o
CC tool_hugehelp.o
CCLD curl
make[2]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/src'
make[1]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/src'
make[1]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0'
| @@ -27,12 +27,12 @@ PDFPAGES = testcurl.pdf runtests.pdf | |
| MANDISTPAGES = runtests.1.dist testcurl.1.dist | |
| EXTRA_DIST = appveyor.pm azure.pm badsymbols.pl check-deprecated.pl CMakeLists.txt \ | |
| - | dictserver.py directories.pm disable-scan.pl error-codes.pl extern-scan.pl \ |
| - | FILEFORMAT.md processhelp.pm ftpserver.pl getpart.pm http-server.pl http2-server.pl \ |
| + | dictserver.py directories.pm disable-scan.pl error-codes.pl extern-scan.pl FILEFORMAT.md \ |
| + | processhelp.pm ftpserver.pl getpart.pm globalconfig.pm http-server.pl http2-server.pl \ |
| http3-server.pl manpage-scan.pl manpage-syntax.pl markdown-uppercase.pl mem-include-scan.pl \ | |
| memanalyze.pl negtelnetserver.py nroff-scan.pl option-check.pl options-scan.pl \ | |
| pathhelp.pm README.md rtspserver.pl runtests.1 runtests.pl secureserver.pl \ | |
| - | serverhelp.pm smbserver.py sshhelp.pm sshserver.pl stunnel.pem symbol-scan.pl \ |
| + | serverhelp.pm servers.pm smbserver.py sshhelp.pm sshserver.pl stunnel.pem symbol-scan.pl \ |
| testcurl.1 testcurl.pl tftpserver.pl util.py valgrind.pm valgrind.supp version-scan.pl | |
| DISTCLEANFILES = configurehelp.pm | |
| @@ -0,0 +1,76 @@ | |
| + | #*************************************************************************** |
| + | # _ _ ____ _ |
| + | # Project ___| | | | _ \| | |
| + | # / __| | | | |_) | | |
| + | # | (__| |_| | _ <| |___ |
| + | # \___|\___/|_| \_\_____| |
| + | # |
| + | # Copyright (C) Daniel Stenberg, <[email protected]>, 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 |
| + | # |
| + | ########################################################################### |
| + | |
| + | # This module contains global variables used in multiple modules in the test |
| + | # harness but not really "owned" by any one. |
| + | |
| + | package globalconfig; |
| + | |
| + | use strict; |
| + | use warnings; |
| + | |
| + | BEGIN { |
| + | use base qw(Exporter); |
| + | |
| + | our @EXPORT = qw( |
| + | $CURL |
| + | $FTPDCMD |
| + | $LOGDIR |
| + | $perl |
| + | $PIDDIR |
| + | $proxy_address |
| + | $srcdir |
| + | $torture |
| + | $VCURL |
| + | $verbose |
| + | @protocols |
| + | ); |
| + | } |
| + | use pathhelp qw(exe_ext); |
| + | |
| + | |
| + | ####################################################################### |
| + | # global configuration variables |
| + | # |
| + | |
| + | # config variables overridden by command-line options |
| + | our $verbose; # 1 to show verbose test output |
| + | our $torture; # 1 to enable torture testing |
| + | our $proxy_address; # external HTTP proxy address |
| + | |
| + | # paths |
| + | our $srcdir = $ENV{'srcdir'} || '.'; # root of the test source code |
| + | our $perl="perl -I$srcdir"; # invoke perl like this |
| + | our $LOGDIR="log"; # root of the log directory |
| + | our $PIDDIR = "$LOGDIR/server"; # root of the server directory with PID files |
| + | our $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy server instructions here |
| + | our $CURL="../src/curl".exe_ext('TOOL'); # what curl binary to run on the tests |
| + | our $VCURL=$CURL; # what curl binary to use to verify the servers with |
| + | # VCURL is handy to set to the system one when the one you |
| + | # just built hangs or crashes and thus prevent verification |
| + | |
| + | # other config variables |
| + | our @protocols; # array of lowercase supported protocol servers |
| + | |
| + | 1; |
| @@ -58,20 +58,16 @@ use Cwd 'abs_path'; | |
| BEGIN { | |
| use base qw(Exporter); | |
| - | our @EXPORT = qw( |
| - | sys_native_abs_path |
| - | sys_native_path |
| - | exe_ext |
| - | ); |
| - | |
| our @EXPORT_OK = qw( | |
| - | build_sys_abs_path |
| - | sys_native_current_path |
| - | normalize_path |
| - | os_is_win |
| - | $use_cygpath |
| - | should_use_cygpath |
| - | drives_mounted_on_cygdrive |
| + | os_is_win |
| + | exe_ext |
| + | sys_native_abs_path |
| + | sys_native_current_path |
| + | build_sys_abs_path |
| + | normalize_path |
| + | $use_cygpath |
| + | should_use_cygpath |
| + | drives_mounted_on_cygdrive |
| ); | |
| } | |
| @@ -83,84 +83,42 @@ use Digest::MD5 qw(md5); | |
| use MIME::Base64; | |
| use List::Util 'sum'; | |
| - | # Subs imported from serverhelp module |
| - | use serverhelp qw( |
| - | serverfactors |
| - | servername_id |
| - | servername_str |
| - | servername_canon |
| - | server_pidfilename |
| - | server_portfilename |
| - | server_logfilename |
| + | use pathhelp qw( |
| + | exe_ext |
| + | sys_native_current_path |
| ); | |
| - | |
| - | # Variables and subs imported from sshhelp module |
| - | use sshhelp qw( |
| - | $hstpubmd5f |
| - | $hstpubsha256f |
| - | $sshexe |
| - | $sftpexe |
| - | $sftpconfig |
| - | $sshdlog |
| - | $sftplog |
| - | $sftpcmds |
| - | display_sshdconfig |
| - | display_sftpconfig |
| - | display_sshdlog |
| - | display_sftplog |
| - | find_sshd |
| - | find_ssh |
| - | find_sftp |
| - | find_httptlssrv |
| - | sshversioninfo |
| + | use processhelp qw( |
| + | portable_sleep |
| ); | |
| use appveyor; | |
| use azure; | |
| use getpart; # array functions | |
| - | use pathhelp; |
| - | use processhelp; |
| + | use servers; |
| use valgrind; # valgrind report parser | |
| + | use globalconfig; |
| - | my $HOSTIP="127.0.0.1"; # address on which the test server listens |
| - | my $HOST6IP="[::1]"; # address on which the test server listens |
| my $CLIENTIP="127.0.0.1"; # address which curl uses for incoming connections | |
| my $CLIENT6IP="[::1]"; # address which curl uses for incoming connections | |
| - | my %PORT = (nolisten => 47); # port we use for a local non-listening service |
| - | my $HTTPUNIXPATH; # HTTP server Unix domain socket path |
| - | my $SOCKSUNIXPATH; # socks server Unix domain socket path |
| - | |
| my $use_external_proxy = 0; | |
| - | my $proxy_address; |
| my %custom_skip_reasons; | |
| - | my $SSHSRVMD5 = "[uninitialized]"; # MD5 of ssh server public key |
| - | my $SSHSRVSHA256 = "[uninitialized]"; # SHA256 of ssh server public key |
| my $CURLVERSION=""; # curl's reported version number | |
| - | my $srcdir = $ENV{'srcdir'} || '.'; |
| - | my $CURL="../src/curl".exe_ext('TOOL'); # what curl binary to run on the tests |
| - | my $VCURL=$CURL; # what curl binary to use to verify the servers with |
| - | # VCURL is handy to set to the system one when the one you |
| - | # just built hangs or crashes and thus prevent verification |
| my $ACURL=$VCURL; # what curl binary to use to talk to APIs (relevant for CI) | |
| # ACURL is handy to set to the system one for reliability | |
| my $DBGCURL=$CURL; #"../src/.libs/curl"; # alternative for debugging | |
| my $TESTDIR="$srcdir/data"; | |
| my $LIBDIR="./libtest"; | |
| my $UNITDIR="./unit"; | |
| - | my $LOGDIR="log"; |
| # TODO: $LOGDIR could eventually change later on, so must regenerate all the | |
| # paths depending on it after $LOGDIR itself changes. | |
| - | my $PIDDIR = "$LOGDIR/server"; |
| # TODO: change this to use server_inputfilename() | |
| my $SERVERIN="$LOGDIR/server.input"; # what curl sent the server | |
| my $SERVER2IN="$LOGDIR/server2.input"; # what curl sent the second server | |
| my $PROXYIN="$LOGDIR/proxy.input"; # what curl sent the proxy | |
| - | my $SOCKSIN="$LOGDIR/socksd-request.log"; # what curl sent to the SOCKS proxy |
| my $CURLLOG="$LOGDIR/commands.log"; # all command lines run | |
| - | my $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy server instructions here |
| my $SERVERLOGS_LOCK="$LOGDIR/serverlogs.lock"; # server logs advisor read lock | |
| my $CURLCONFIG="../curl-config"; # curl-config from current build | |
| @@ -175,10 +133,6 @@ my $TESTCASES="all"; | |
| # No variables below this point should need to be modified | |
| # | |
| - | # invoke perl like this: |
| - | my $perl="perl -I$srcdir"; |
| - | my $server_response_maxtime=13; |
| - | |
| my $libtool; | |
| my $repeat = 0; | |
| @@ -192,13 +146,10 @@ my $pwd = getcwd(); # current working directory | |
| my $posix_pwd = $pwd; | |
| my $start; # time at which testing started | |
| - | my $ftpchecktime=1; # time it took to verify our test FTP server |
| - | my $stunnel = checkcmd("stunnel4") || checkcmd("tstunnel") || checkcmd("stunnel"); |
| my $valgrind = checktestcmd("valgrind"); | |
| my $valgrind_logfile="--logfile"; # the option name for valgrind 2.X | |
| my $valgrind_tool; | |
| my $gdb = checktestcmd("gdb"); | |
| - | my $httptlssrv = find_httptlssrv(); |
| my $uname_release = `uname -r`; | |
| my $is_wsl = $uname_release =~ /Microsoft$/; | |
| @@ -216,7 +167,6 @@ my $resolver; # name of the resolver backend (for human presentation) | |
| my $has_textaware; # set if running on a system that has a text mode concept | |
| # on files. Windows for example | |
| - | my @protocols; # array of lowercase supported protocol servers |
| my %skipped; # skipped{reason}=counter, reasons for skip | |
| my @teststat; # teststat[testnum]=reason, reasons for skip | |
| @@ -225,10 +175,6 @@ my %ignored_keywords; # key words of tests to ignore results | |
| my %enabled_keywords; # key words of tests to run | |
| my %disabled; # disabled test cases | |
| my %ignored; # ignored results of test cases | |
| - | my $sshdid; # for socks server, ssh daemon version id |
| - | my $sshdvernum; # for socks server, ssh daemon version number |
| - | my $sshdverstr; # for socks server, ssh daemon version string |
| - | my $sshderror; # for socks server, ssh daemon version error |
| my $defserverlogslocktimeout = 2; # timeout to await server logs lock removal | |
| my $defpostcommanddelay = 0; # delay between command and postcheck sections | |
| @@ -243,7 +189,6 @@ my %timetoolend; # timestamp for each test command run stopping | |
| my %timesrvrlog; # timestamp for each test server logs lock removal | |
| my %timevrfyend; # timestamp for each test result verification end | |
| - | my $testnumcheck; # test number, set in singletest sub. |
| my %oldenv; # environment variables before test is started | |
| my %feature; # array of enabled features | |
| my %keywords; # array of keywords from the test spec | |
| @@ -254,8 +199,6 @@ my %keywords; # array of keywords from the test spec | |
| my $short; | |
| my $automakestyle; | |
| - | my $verbose; |
| - | my $debugprotocol; |
| my $no_debuginfod; | |
| my $anyway; | |
| my $gdbthis; # run test case with gdb debugger | |
| @@ -264,19 +207,11 @@ my $keepoutfiles; # keep stdout and stderr files after tests | |
| my $clearlocks; # force removal of files by killing locking processes | |
| my $listonly; # only list the tests | |
| my $postmortem; # display detailed info about failed tests | |
| - | my $err_unexpected; # error instead of warning on server unexpectedly alive |
| my $run_event_based; # run curl with --test-event to test the event API | |
| my $run_disabled; # run the specific tests even if listed in DISABLED | |
| my $scrambleorder; | |
| - | my %run; # running server |
| - | my %doesntrun; # servers that don't work, identified by pidfile |
| - | my %serverpidfile;# all server pid file names, identified by server id |
| - | my %serverportfile;# all server port file names, identified by server id |
| - | my %runcert; # cert file currently in use by an ssl running server |
| - | |
| # torture test variables | |
| - | my $torture; |
| my $tortalloc; | |
| my $shallow; | |
| my $randseed = 0; | |
| @@ -299,15 +234,6 @@ sub logmsg { | |
| } | |
| } | |
| - | # get the name of the current user |
| - | my $USER = $ENV{USER}; # Linux |
| - | if (!$USER) { |
| - | $USER = $ENV{USERNAME}; # Windows |
| - | if (!$USER) { |
| - | $USER = $ENV{LOGNAME}; # Some Unix (I think) |
| - | } |
| - | } |
| - | |
| # enable memory debugging if curl is compiled with it | |
| $ENV{'CURL_MEMDEBUG'} = $memdump; | |
| $ENV{'CURL_ENTROPY'}="12345678"; | |
| @@ -370,155 +296,6 @@ if ($ENV{"NGHTTPX"}) { | |
| } | |
| - | ####################################################################### |
| - | # Load serverpidfile and serverportfile hashes with file names for all |
| - | # possible servers. |
| - | # |
| - | sub init_serverpidfile_hash { |
| - | for my $proto (('ftp', 'gopher', 'http', 'imap', 'pop3', 'smtp', 'http/2', 'http/3')) { |
| - | for my $ssl (('', 's')) { |
| - | for my $ipvnum ((4, 6)) { |
| - | for my $idnum ((1, 2, 3)) { |
| - | my $serv = servername_id("$proto$ssl", $ipvnum, $idnum); |
| - | my $pidf = server_pidfilename($PIDDIR, "$proto$ssl", $ipvnum, $idnum); |
| - | $serverpidfile{$serv} = $pidf; |
| - | my $portf = server_portfilename($PIDDIR, "$proto$ssl", $ipvnum, $idnum); |
| - | $serverportfile{$serv} = $portf; |
| - | } |
| - | } |
| - | } |
| - | } |
| - | for my $proto (('tftp', 'sftp', 'socks', 'ssh', 'rtsp', 'httptls', |
| - | 'dict', 'smb', 'smbs', 'telnet', 'mqtt')) { |
| - | for my $ipvnum ((4, 6)) { |
| - | for my $idnum ((1, 2)) { |
| - | my $serv = servername_id($proto, $ipvnum, $idnum); |
| - | my $pidf = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum); |
| - | $serverpidfile{$serv} = $pidf; |
| - | my $portf = server_portfilename($PIDDIR, $proto, $ipvnum, $idnum); |
| - | $serverportfile{$serv} = $portf; |
| - | } |
| - | } |
| - | } |
| - | for my $proto (('http', 'imap', 'pop3', 'smtp', 'http/2', 'http/3')) { |
| - | for my $ssl (('', 's')) { |
| - | my $serv = servername_id("$proto$ssl", "unix", 1); |
| - | my $pidf = server_pidfilename($PIDDIR, "$proto$ssl", "unix", 1); |
| - | $serverpidfile{$serv} = $pidf; |
| - | my $portf = server_portfilename($PIDDIR, "$proto$ssl", "unix", 1); |
| - | $serverportfile{$serv} = $portf; |
| - | } |
| - | } |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Check if a given child process has just died. Reaps it if so. |
| - | # |
| - | sub checkdied { |
| - | my $pid = $_[0]; |
| - | if((not defined $pid) || $pid <= 0) { |
| - | return 0; |
| - | } |
| - | use POSIX ":sys_wait_h"; |
| - | my $rc = pidwait($pid, &WNOHANG); |
| - | return ($rc == $pid)?1:0; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Start a new thread/process and run the given command line in there. |
| - | # Return the pids (yes plural) of the new child process to the parent. |
| - | # |
| - | sub startnew { |
| - | my ($cmd, $pidfile, $timeout, $fakepidfile)=@_; |
| - | |
| - | logmsg "startnew: $cmd\n" if ($verbose); |
| - | |
| - | my $child = fork(); |
| - | |
| - | if(not defined $child) { |
| - | logmsg "startnew: fork() failure detected\n"; |
| - | return (-1,-1); |
| - | } |
| - | |
| - | if(0 == $child) { |
| - | # Here we are the child. Run the given command. |
| - | |
| - | # Flush output. |
| - | $| = 1; |
| - | |
| - | # Put an "exec" in front of the command so that the child process |
| - | # keeps this child's process ID. |
| - | exec("exec $cmd") || die "Can't exec() $cmd: $!"; |
| - | |
| - | # exec() should never return back here to this process. We protect |
| - | # ourselves by calling die() just in case something goes really bad. |
| - | die "error: exec() has returned"; |
| - | } |
| - | |
| - | # Ugly hack but ssh client and gnutls-serv don't support pid files |
| - | if ($fakepidfile) { |
| - | if(open(my $out, ">", "$pidfile")) { |
| - | print $out $child . "\n"; |
| - | close($out) || die "Failure writing pidfile"; |
| - | logmsg "startnew: $pidfile faked with pid=$child\n" if($verbose); |
| - | } |
| - | else { |
| - | logmsg "startnew: failed to write fake $pidfile with pid=$child\n"; |
| - | } |
| - | # could/should do a while connect fails sleep a bit and loop |
| - | portable_sleep($timeout); |
| - | if (checkdied($child)) { |
| - | logmsg "startnew: child process has failed to start\n" if($verbose); |
| - | return (-1,-1); |
| - | } |
| - | } |
| - | |
| - | my $pid2 = 0; |
| - | my $count = $timeout; |
| - | while($count--) { |
| - | $pid2 = pidfromfile($pidfile); |
| - | if(($pid2 > 0) && pidexists($pid2)) { |
| - | # if $pid2 is valid, then make sure this pid is alive, as |
| - | # otherwise it is just likely to be the _previous_ pidfile or |
| - | # similar! |
| - | last; |
| - | } |
| - | if (checkdied($child)) { |
| - | logmsg "startnew: child process has died, server might start up\n" |
| - | if($verbose); |
| - | # We can't just abort waiting for the server with a |
| - | # return (-1,-1); |
| - | # because the server might have forked and could still start |
| - | # up normally. Instead, just reduce the amount of time we remain |
| - | # waiting. |
| - | $count >>= 2; |
| - | } |
| - | sleep(1); |
| - | } |
| - | |
| - | # Return two PIDs, the one for the child process we spawned and the one |
| - | # reported by the server itself (in case it forked again on its own). |
| - | # Both (potentially) need to be killed at the end of the test. |
| - | return ($child, $pid2); |
| - | } |
| - | |
| - | |
| - | ####################################################################### |
| - | # Check for a command in the PATH of the test server. |
| - | # |
| - | sub checkcmd { |
| - | my ($cmd, @extrapaths)=@_; |
| - | my @paths=(split(m/[:]/, $ENV{'PATH'}), "/usr/sbin", "/usr/local/sbin", |
| - | "/sbin", "/usr/bin", "/usr/local/bin", @extrapaths); |
| - | for(@paths) { |
| - | if( -x "$_/$cmd" && ! -d "$_/$cmd") { |
| - | # executable bit but not a directory! |
| - | return "$_/$cmd"; |
| - | } |
| - | } |
| - | return ""; |
| - | } |
| - | |
| ####################################################################### | |
| # Get the list of tests that the tests/data/Makefile.am knows about! | |
| # | |
| @@ -694,2021 +471,44 @@ sub torture { | |
| } | |
| $fail = 1; | |
| } | |
| - | } |
| - | |
| - | # verify that it returns a proper error code, doesn't leak memory |
| - | # and doesn't core dump |
| - | if(($ret & 255) || ($ret >> 8) >= 128) { |
| - | logmsg " system() returned $ret\n"; |
| - | $fail=1; |
| - | } |
| - | else { |
| - | my @memdata=`$memanalyze $memdump`; |
| - | my $leak=0; |
| - | for(@memdata) { |
| - | if($_ ne "") { |
| - | # well it could be other memory problems as well, but |
| - | # we call it leak for short here |
| - | $leak=1; |
| - | } |
| - | } |
| - | if($leak) { |
| - | logmsg "** MEMORY FAILURE\n"; |
| - | logmsg @memdata; |
| - | logmsg `$memanalyze -l $memdump`; |
| - | $fail = 1; |
| - | } |
| - | } |
| - | if($fail) { |
| - | logmsg " Failed on function number $limit in test.\n", |
| - | " invoke with \"-t$limit\" to repeat this single case.\n"; |
| - | stopservers($verbose); |
| - | return 1; |
| - | } |
| - | } |
| - | |
| - | logmsg "torture OK\n"; |
| - | return 0; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Return the port to use for the given protocol. |
| - | # |
| - | sub protoport { |
| - | my ($proto) = @_; |
| - | return $PORT{$proto} || "[not running]"; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Stop a test server along with pids which aren't in the %run hash yet. |
| - | # This also stops all servers which are relative to the given one. |
| - | # |
| - | sub stopserver { |
| - | my ($server, $pidlist) = @_; |
| - | |
| - | # |
| - | # kill sockfilter processes for pingpong relative server |
| - | # |
| - | if($server =~ /^(ftp|imap|pop3|smtp)s?(\d*)(-ipv6|)$/) { |
| - | my $proto = $1; |
| - | my $idnum = ($2 && ($2 > 1)) ? $2 : 1; |
| - | my $ipvnum = ($3 && ($3 =~ /6$/)) ? 6 : 4; |
| - | killsockfilters($PIDDIR, $proto, $ipvnum, $idnum, $verbose); |
| - | } |
| - | # |
| - | # All servers relative to the given one must be stopped also |
| - | # |
| - | my @killservers; |
| - | if($server =~ /^(ftp|http|imap|pop3|smtp)s((\d*)(-ipv6|-unix|))$/) { |
| - | # given a stunnel based ssl server, also kill non-ssl underlying one |
| - | push @killservers, "${1}${2}"; |
| - | } |
| - | elsif($server =~ /^(ftp|http|imap|pop3|smtp)((\d*)(-ipv6|-unix|))$/) { |
| - | # given a non-ssl server, also kill stunnel based ssl piggybacking one |
| - | push @killservers, "${1}s${2}"; |
| - | } |
| - | elsif($server =~ /^(socks)((\d*)(-ipv6|))$/) { |
| - | # given a socks server, also kill ssh underlying one |
| - | push @killservers, "ssh${2}"; |
| - | } |
| - | elsif($server =~ /^(ssh)((\d*)(-ipv6|))$/) { |
| - | # given a ssh server, also kill socks piggybacking one |
| - | push @killservers, "socks${2}"; |
| - | } |
| - | if($server eq "http" or $server eq "https") { |
| - | # since the http2+3 server is a proxy that needs to know about the |
| - | # dynamic http port it too needs to get restarted when the http server |
| - | # is killed |
| - | push @killservers, "http/2"; |
| - | push @killservers, "http/3"; |
| - | } |
| - | push @killservers, $server; |
| - | # |
| - | # kill given pids and server relative ones clearing them in %run hash |
| - | # |
| - | foreach my $server (@killservers) { |
| - | if($run{$server}) { |
| - | # we must prepend a space since $pidlist may already contain a pid |
| - | $pidlist .= " $run{$server}"; |
| - | $run{$server} = 0; |
| - | } |
| - | $runcert{$server} = 0 if($runcert{$server}); |
| - | } |
| - | killpid($verbose, $pidlist); |
| - | # |
| - | # cleanup server pid files |
| - | # |
| - | my $result = 0; |
| - | foreach my $server (@killservers) { |
| - | my $pidfile = $serverpidfile{$server}; |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | if($err_unexpected) { |
| - | logmsg "ERROR: "; |
| - | $result = -1; |
| - | } |
| - | else { |
| - | logmsg "Warning: "; |
| - | } |
| - | logmsg "$server server unexpectedly alive\n"; |
| - | killpid($verbose, $pid); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | } |
| - | |
| - | return $result; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Return flags to let curl use an external HTTP proxy |
| - | # |
| - | sub getexternalproxyflags { |
| - | return " --proxy $proxy_address "; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Verify that the server that runs on $ip, $port is our server. This also |
| - | # implies that we can speak with it, as there might be occasions when the |
| - | # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't |
| - | # assign requested address") |
| - | # |
| - | sub verifyhttp { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port_or_path) = @_; |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | my $bonus=""; |
| - | # $port_or_path contains a path for Unix sockets, sws ignores the port |
| - | my $port = ($ipvnum eq "unix") ? 80 : $port_or_path; |
| - | |
| - | my $verifyout = "$LOGDIR/". |
| - | servername_canon($proto, $ipvnum, $idnum) .'_verify.out'; |
| - | unlink($verifyout) if(-f $verifyout); |
| - | |
| - | my $verifylog = "$LOGDIR/". |
| - | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| - | unlink($verifylog) if(-f $verifylog); |
| - | |
| - | if($proto eq "gopher") { |
| - | # gopher is funny |
| - | $bonus="1/"; |
| - | } |
| - | |
| - | my $flags = "--max-time $server_response_maxtime "; |
| - | $flags .= "--output $verifyout "; |
| - | $flags .= "--silent "; |
| - | $flags .= "--verbose "; |
| - | $flags .= "--globoff "; |
| - | $flags .= "--unix-socket '$port_or_path' " if $ipvnum eq "unix"; |
| - | $flags .= "--insecure " if($proto eq 'https'); |
| - | if($use_external_proxy) { |
| - | $flags .= getexternalproxyflags(); |
| - | } |
| - | $flags .= "\"$proto://$ip:$port/${bonus}verifiedserver\""; |
| - | |
| - | my $cmd = "$VCURL $flags 2>$verifylog"; |
| - | |
| - | # verify if our/any server is running on this port |
| - | logmsg "RUN: $cmd\n" if($verbose); |
| - | my $res = runclient($cmd); |
| - | |
| - | $res >>= 8; # rotate the result |
| - | if($res & 128) { |
| - | logmsg "RUN: curl command died with a coredump\n"; |
| - | return -1; |
| - | } |
| - | |
| - | if($res && $verbose) { |
| - | logmsg "RUN: curl command returned $res\n"; |
| - | if(open(my $file, "<", "$verifylog")) { |
| - | while(my $string = <$file>) { |
| - | logmsg "RUN: $string" if($string !~ /^([ \t]*)$/); |
| - | } |
| - | close($file); |
| - | } |
| - | } |
| - | |
| - | my $data; |
| - | if(open(my $file, "<", "$verifyout")) { |
| - | while(my $string = <$file>) { |
| - | $data = $string; |
| - | last; # only want first line |
| - | } |
| - | close($file); |
| - | } |
| - | |
| - | my $pid = 0; |
| - | if($data && ($data =~ /WE ROOLZ: (\d+)/)) { |
| - | $pid = 0+$1; |
| - | } |
| - | elsif($res == 6) { |
| - | # curl: (6) Couldn't resolve host '::1' |
| - | logmsg "RUN: failed to resolve host ($proto://$ip:$port/verifiedserver)\n"; |
| - | return -1; |
| - | } |
| - | elsif($data || ($res && ($res != 7))) { |
| - | logmsg "RUN: Unknown server on our $server port: $port ($res)\n"; |
| - | return -1; |
| - | } |
| - | return $pid; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Verify that the server that runs on $ip, $port is our server. This also |
| - | # implies that we can speak with it, as there might be occasions when the |
| - | # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't |
| - | # assign requested address") |
| - | # |
| - | sub verifyftp { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | my $time=time(); |
| - | my $extra=""; |
| - | |
| - | my $verifylog = "$LOGDIR/". |
| - | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| - | unlink($verifylog) if(-f $verifylog); |
| - | |
| - | if($proto eq "ftps") { |
| - | $extra .= "--insecure --ftp-ssl-control "; |
| - | } |
| - | |
| - | my $flags = "--max-time $server_response_maxtime "; |
| - | $flags .= "--silent "; |
| - | $flags .= "--verbose "; |
| - | $flags .= "--globoff "; |
| - | $flags .= $extra; |
| - | if($use_external_proxy) { |
| - | $flags .= getexternalproxyflags(); |
| - | } |
| - | $flags .= "\"$proto://$ip:$port/verifiedserver\""; |
| - | |
| - | my $cmd = "$VCURL $flags 2>$verifylog"; |
| - | |
| - | # check if this is our server running on this port: |
| - | logmsg "RUN: $cmd\n" if($verbose); |
| - | my @data = runclientoutput($cmd); |
| - | |
| - | my $res = $? >> 8; # rotate the result |
| - | if($res & 128) { |
| - | logmsg "RUN: curl command died with a coredump\n"; |
| - | return -1; |
| - | } |
| - | |
| - | my $pid = 0; |
| - | foreach my $line (@data) { |
| - | if($line =~ /WE ROOLZ: (\d+)/) { |
| - | # this is our test server with a known pid! |
| - | $pid = 0+$1; |
| - | last; |
| - | } |
| - | } |
| - | if($pid <= 0 && @data && $data[0]) { |
| - | # this is not a known server |
| - | logmsg "RUN: Unknown server on our $server port: $port\n"; |
| - | return 0; |
| - | } |
| - | # we can/should use the time it took to verify the FTP server as a measure |
| - | # on how fast/slow this host/FTP is. |
| - | my $took = int(0.5+time()-$time); |
| - | |
| - | if($verbose) { |
| - | logmsg "RUN: Verifying our test $server server took $took seconds\n"; |
| - | } |
| - | $ftpchecktime = $took>=1?$took:1; # make sure it never is below 1 |
| - | |
| - | return $pid; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Verify that the server that runs on $ip, $port is our server. This also |
| - | # implies that we can speak with it, as there might be occasions when the |
| - | # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't |
| - | # assign requested address") |
| - | # |
| - | sub verifyrtsp { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $verifyout = "$LOGDIR/". |
| - | servername_canon($proto, $ipvnum, $idnum) .'_verify.out'; |
| - | unlink($verifyout) if(-f $verifyout); |
| - | |
| - | my $verifylog = "$LOGDIR/". |
| - | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| - | unlink($verifylog) if(-f $verifylog); |
| - | |
| - | my $flags = "--max-time $server_response_maxtime "; |
| - | $flags .= "--output $verifyout "; |
| - | $flags .= "--silent "; |
| - | $flags .= "--verbose "; |
| - | $flags .= "--globoff "; |
| - | if($use_external_proxy) { |
| - | $flags .= getexternalproxyflags(); |
| - | } |
| - | # currently verification is done using http |
| - | $flags .= "\"http://$ip:$port/verifiedserver\""; |
| - | |
| - | my $cmd = "$VCURL $flags 2>$verifylog"; |
| - | |
| - | # verify if our/any server is running on this port |
| - | logmsg "RUN: $cmd\n" if($verbose); |
| - | my $res = runclient($cmd); |
| - | |
| - | $res >>= 8; # rotate the result |
| - | if($res & 128) { |
| - | logmsg "RUN: curl command died with a coredump\n"; |
| - | return -1; |
| - | } |
| - | |
| - | if($res && $verbose) { |
| - | logmsg "RUN: curl command returned $res\n"; |
| - | if(open(my $file, "<", "$verifylog")) { |
| - | while(my $string = <$file>) { |
| - | logmsg "RUN: $string" if($string !~ /^[ \t]*$/); |
| - | } |
| - | close($file); |
| - | } |
| - | } |
| - | |
| - | my $data; |
| - | if(open(my $file, "<", "$verifyout")) { |
| - | while(my $string = <$file>) { |
| - | $data = $string; |
| - | last; # only want first line |
| - | } |
| - | close($file); |
| - | } |
| - | |
| - | my $pid = 0; |
| - | if($data && ($data =~ /RTSP_SERVER WE ROOLZ: (\d+)/)) { |
| - | $pid = 0+$1; |
| - | } |
| - | elsif($res == 6) { |
| - | # curl: (6) Couldn't resolve host '::1' |
| - | logmsg "RUN: failed to resolve host ($proto://$ip:$port/verifiedserver)\n"; |
| - | return -1; |
| - | } |
| - | elsif($data || ($res != 7)) { |
| - | logmsg "RUN: Unknown server on our $server port: $port\n"; |
| - | return -1; |
| - | } |
| - | return $pid; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Verify that the ssh server has written out its pidfile, recovering |
| - | # the pid from the file and returning it if a process with that pid is |
| - | # actually alive, or a negative value if the process is dead. |
| - | # |
| - | sub verifyssh { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| - | my $pidfile = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum); |
| - | my $pid = processexists($pidfile); |
| - | if($pid < 0) { |
| - | logmsg "RUN: SSH server has died after starting up\n"; |
| - | } |
| - | return $pid; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Verify that we can connect to the sftp server, properly authenticate |
| - | # with generated config and key files and run a simple remote pwd. |
| - | # |
| - | sub verifysftp { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | my $verified = 0; |
| - | # Find out sftp client canonical file name |
| - | my $sftp = find_sftp(); |
| - | if(!$sftp) { |
| - | logmsg "RUN: SFTP server cannot find $sftpexe\n"; |
| - | return -1; |
| - | } |
| - | # Find out ssh client canonical file name |
| - | my $ssh = find_ssh(); |
| - | if(!$ssh) { |
| - | logmsg "RUN: SFTP server cannot find $sshexe\n"; |
| - | return -1; |
| - | } |
| - | # Connect to sftp server, authenticate and run a remote pwd |
| - | # command using our generated configuration and key files |
| - | my $cmd = "\"$sftp\" -b $PIDDIR/$sftpcmds -F $PIDDIR/$sftpconfig -S \"$ssh\" $ip > $sftplog 2>&1"; |
| - | my $res = runclient($cmd); |
| - | # Search for pwd command response in log file |
| - | if(open(my $sftplogfile, "<", "$sftplog")) { |
| - | while(<$sftplogfile>) { |
| - | if(/^Remote working directory: /) { |
| - | $verified = 1; |
| - | last; |
| - | } |
| - | } |
| - | close($sftplogfile); |
| - | } |
| - | return $verified; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Verify that the non-stunnel HTTP TLS extensions capable server that runs |
| - | # on $ip, $port is our server. This also implies that we can speak with it, |
| - | # as there might be occasions when the server runs fine but we cannot talk |
| - | # to it ("Failed to connect to ::1: Can't assign requested address") |
| - | # |
| - | sub verifyhttptls { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | my $pidfile = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $verifyout = "$LOGDIR/". |
| - | servername_canon($proto, $ipvnum, $idnum) .'_verify.out'; |
| - | unlink($verifyout) if(-f $verifyout); |
| - | |
| - | my $verifylog = "$LOGDIR/". |
| - | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| - | unlink($verifylog) if(-f $verifylog); |
| - | |
| - | my $flags = "--max-time $server_response_maxtime "; |
| - | $flags .= "--output $verifyout "; |
| - | $flags .= "--verbose "; |
| - | $flags .= "--globoff "; |
| - | $flags .= "--insecure "; |
| - | $flags .= "--tlsauthtype SRP "; |
| - | $flags .= "--tlsuser jsmith "; |
| - | $flags .= "--tlspassword abc "; |
| - | if($use_external_proxy) { |
| - | $flags .= getexternalproxyflags(); |
| - | } |
| - | $flags .= "\"https://$ip:$port/verifiedserver\""; |
| - | |
| - | my $cmd = "$VCURL $flags 2>$verifylog"; |
| - | |
| - | # verify if our/any server is running on this port |
| - | logmsg "RUN: $cmd\n" if($verbose); |
| - | my $res = runclient($cmd); |
| - | |
| - | $res >>= 8; # rotate the result |
| - | if($res & 128) { |
| - | logmsg "RUN: curl command died with a coredump\n"; |
| - | return -1; |
| - | } |
| - | |
| - | if($res && $verbose) { |
| - | logmsg "RUN: curl command returned $res\n"; |
| - | if(open(my $file, "<", "$verifylog")) { |
| - | while(my $string = <$file>) { |
| - | logmsg "RUN: $string" if($string !~ /^([ \t]*)$/); |
| - | } |
| - | close($file); |
| - | } |
| - | } |
| - | |
| - | my $data; |
| - | if(open(my $file, "<", "$verifyout")) { |
| - | while(my $string = <$file>) { |
| - | $data .= $string; |
| - | } |
| - | close($file); |
| - | } |
| - | |
| - | my $pid = 0; |
| - | if($data && ($data =~ /(GNUTLS|GnuTLS)/) && ($pid = processexists($pidfile))) { |
| - | if($pid < 0) { |
| - | logmsg "RUN: $server server has died after starting up\n"; |
| - | } |
| - | return $pid; |
| - | } |
| - | elsif($res == 6) { |
| - | # curl: (6) Couldn't resolve host '::1' |
| - | logmsg "RUN: failed to resolve host (https://$ip:$port/verifiedserver)\n"; |
| - | return -1; |
| - | } |
| - | elsif($data || ($res && ($res != 7))) { |
| - | logmsg "RUN: Unknown server on our $server port: $port ($res)\n"; |
| - | return -1; |
| - | } |
| - | return $pid; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # STUB for verifying socks |
| - | # |
| - | sub verifysocks { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| - | my $pidfile = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum); |
| - | my $pid = processexists($pidfile); |
| - | if($pid < 0) { |
| - | logmsg "RUN: SOCKS server has died after starting up\n"; |
| - | } |
| - | return $pid; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Verify that the server that runs on $ip, $port is our server. This also |
| - | # implies that we can speak with it, as there might be occasions when the |
| - | # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't |
| - | # assign requested address") |
| - | # |
| - | sub verifysmb { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | my $time=time(); |
| - | my $extra=""; |
| - | |
| - | my $verifylog = "$LOGDIR/". |
| - | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| - | unlink($verifylog) if(-f $verifylog); |
| - | |
| - | my $flags = "--max-time $server_response_maxtime "; |
| - | $flags .= "--silent "; |
| - | $flags .= "--verbose "; |
| - | $flags .= "--globoff "; |
| - | $flags .= "-u 'curltest:curltest' "; |
| - | $flags .= $extra; |
| - | $flags .= "\"$proto://$ip:$port/SERVER/verifiedserver\""; |
| - | |
| - | my $cmd = "$VCURL $flags 2>$verifylog"; |
| - | |
| - | # check if this is our server running on this port: |
| - | logmsg "RUN: $cmd\n" if($verbose); |
| - | my @data = runclientoutput($cmd); |
| - | |
| - | my $res = $? >> 8; # rotate the result |
| - | if($res & 128) { |
| - | logmsg "RUN: curl command died with a coredump\n"; |
| - | return -1; |
| - | } |
| - | |
| - | my $pid = 0; |
| - | foreach my $line (@data) { |
| - | if($line =~ /WE ROOLZ: (\d+)/) { |
| - | # this is our test server with a known pid! |
| - | $pid = 0+$1; |
| - | last; |
| - | } |
| - | } |
| - | if($pid <= 0 && @data && $data[0]) { |
| - | # this is not a known server |
| - | logmsg "RUN: Unknown server on our $server port: $port\n"; |
| - | return 0; |
| - | } |
| - | # we can/should use the time it took to verify the server as a measure |
| - | # on how fast/slow this host is. |
| - | my $took = int(0.5+time()-$time); |
| - | |
| - | if($verbose) { |
| - | logmsg "RUN: Verifying our test $server server took $took seconds\n"; |
| - | } |
| - | $ftpchecktime = $took>=1?$took:1; # make sure it never is below 1 |
| - | |
| - | return $pid; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Verify that the server that runs on $ip, $port is our server. This also |
| - | # implies that we can speak with it, as there might be occasions when the |
| - | # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't |
| - | # assign requested address") |
| - | # |
| - | sub verifytelnet { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | my $time=time(); |
| - | my $extra=""; |
| - | |
| - | my $verifylog = "$LOGDIR/". |
| - | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| - | unlink($verifylog) if(-f $verifylog); |
| - | |
| - | my $flags = "--max-time $server_response_maxtime "; |
| - | $flags .= "--silent "; |
| - | $flags .= "--verbose "; |
| - | $flags .= "--globoff "; |
| - | $flags .= "--upload-file - "; |
| - | $flags .= $extra; |
| - | $flags .= "\"$proto://$ip:$port\""; |
| - | |
| - | my $cmd = "echo 'verifiedserver' | $VCURL $flags 2>$verifylog"; |
| - | |
| - | # check if this is our server running on this port: |
| - | logmsg "RUN: $cmd\n" if($verbose); |
| - | my @data = runclientoutput($cmd); |
| - | |
| - | my $res = $? >> 8; # rotate the result |
| - | if($res & 128) { |
| - | logmsg "RUN: curl command died with a coredump\n"; |
| - | return -1; |
| - | } |
| - | |
| - | my $pid = 0; |
| - | foreach my $line (@data) { |
| - | if($line =~ /WE ROOLZ: (\d+)/) { |
| - | # this is our test server with a known pid! |
| - | $pid = 0+$1; |
| - | last; |
| - | } |
| - | } |
| - | if($pid <= 0 && @data && $data[0]) { |
| - | # this is not a known server |
| - | logmsg "RUN: Unknown server on our $server port: $port\n"; |
| - | return 0; |
| - | } |
| - | # we can/should use the time it took to verify the server as a measure |
| - | # on how fast/slow this host is. |
| - | my $took = int(0.5+time()-$time); |
| - | |
| - | if($verbose) { |
| - | logmsg "RUN: Verifying our test $server server took $took seconds\n"; |
| - | } |
| - | |
| - | return $pid; |
| - | } |
| - | |
| - | |
| - | ####################################################################### |
| - | # Verify that the server that runs on $ip, $port is our server. |
| - | # Retry over several seconds before giving up. The ssh server in |
| - | # particular can take a long time to start if it needs to generate |
| - | # keys on a slow or loaded host. |
| - | # |
| - | # Just for convenience, test harness uses 'https' and 'httptls' literals |
| - | # as values for 'proto' variable in order to differentiate different |
| - | # servers. 'https' literal is used for stunnel based https test servers, |
| - | # and 'httptls' is used for non-stunnel https test servers. |
| - | # |
| - | |
| - | my %protofunc = ('http' => \&verifyhttp, |
| - | 'https' => \&verifyhttp, |
| - | 'rtsp' => \&verifyrtsp, |
| - | 'ftp' => \&verifyftp, |
| - | 'pop3' => \&verifyftp, |
| - | 'imap' => \&verifyftp, |
| - | 'smtp' => \&verifyftp, |
| - | 'ftps' => \&verifyftp, |
| - | 'pop3s' => \&verifyftp, |
| - | 'imaps' => \&verifyftp, |
| - | 'smtps' => \&verifyftp, |
| - | 'tftp' => \&verifyftp, |
| - | 'ssh' => \&verifyssh, |
| - | 'socks' => \&verifysocks, |
| - | 'socks5unix' => \&verifysocks, |
| - | 'gopher' => \&verifyhttp, |
| - | 'httptls' => \&verifyhttptls, |
| - | 'dict' => \&verifyftp, |
| - | 'smb' => \&verifysmb, |
| - | 'telnet' => \&verifytelnet); |
| - | |
| - | sub verifyserver { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| - | |
| - | my $count = 30; # try for this many seconds |
| - | my $pid; |
| - | |
| - | while($count--) { |
| - | my $fun = $protofunc{$proto}; |
| - | |
| - | $pid = &$fun($proto, $ipvnum, $idnum, $ip, $port); |
| - | |
| - | if($pid > 0) { |
| - | last; |
| - | } |
| - | elsif($pid < 0) { |
| - | # a real failure, stop trying and bail out |
| - | return 0; |
| - | } |
| - | sleep(1); |
| - | } |
| - | return $pid; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Single shot server responsiveness test. This should only be used |
| - | # to verify that a server present in %run hash is still functional |
| - | # |
| - | sub responsiveserver { |
| - | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| - | my $prev_verbose = $verbose; |
| - | |
| - | $verbose = 0; |
| - | my $fun = $protofunc{$proto}; |
| - | my $pid = &$fun($proto, $ipvnum, $idnum, $ip, $port); |
| - | $verbose = $prev_verbose; |
| - | |
| - | if($pid > 0) { |
| - | return 1; # responsive |
| - | } |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | logmsg " server precheck FAILED (unresponsive $srvrname server)\n"; |
| - | return 0; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the http2 server |
| - | # |
| - | sub runhttp2server { |
| - | my ($verb) = @_; |
| - | my $proto="http/2"; |
| - | my $ipvnum = 4; |
| - | my $idnum = 0; |
| - | my $exe = "$perl $srcdir/http2-server.pl"; |
| - | my $verbose_flag = "--verbose "; |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--nghttpx \"$ENV{'NGHTTPX'}\" "; |
| - | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| - | $flags .= "--logdir \"$LOGDIR\" "; |
| - | $flags .= "--connect $HOSTIP:" . protoport("http") . " "; |
| - | $flags .= $verbose_flag if($debugprotocol); |
| - | |
| - | my ($http2pid, $pid2); |
| - | my $port = 23113; |
| - | my $port2 = 23114; |
| - | for(1 .. 10) { |
| - | $port += int(rand(900)); |
| - | $port2 += int(rand(900)); |
| - | my $aflags = "--port $port --port2 $port2 $flags"; |
| - | |
| - | my $cmd = "$exe $aflags"; |
| - | ($http2pid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($http2pid <= 0 || !pidexists($http2pid)) { |
| - | # it is NOT alive |
| - | stopserver($server, "$pid2"); |
| - | $doesntrun{$pidfile} = 1; |
| - | $http2pid = $pid2 = 0; |
| - | next; |
| - | } |
| - | $doesntrun{$pidfile} = 0; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server PID $http2pid ". |
| - | "http-port $port https-port $port2 ". |
| - | "backend $HOSTIP:" . protoport("http") . "\n"; |
| - | } |
| - | last; |
| - | } |
| - | |
| - | logmsg "RUN: failed to start the $srvrname server\n" if(!$http2pid); |
| - | |
| - | return ($http2pid, $pid2, $port, $port2); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the http3 server |
| - | # |
| - | sub runhttp3server { |
| - | my ($verb, $cert) = @_; |
| - | my $proto="http/3"; |
| - | my $ipvnum = 4; |
| - | my $idnum = 0; |
| - | my $exe = "$perl $srcdir/http3-server.pl"; |
| - | my $verbose_flag = "--verbose "; |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--nghttpx \"$ENV{'NGHTTPX'}\" "; |
| - | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| - | $flags .= "--logdir \"$LOGDIR\" "; |
| - | $flags .= "--connect $HOSTIP:" . protoport("http") . " "; |
| - | $flags .= "--cert \"$cert\" " if($cert); |
| - | $flags .= $verbose_flag if($debugprotocol); |
| - | |
| - | my ($http3pid, $pid3); |
| - | my $port = 24113; |
| - | for(1 .. 10) { |
| - | $port += int(rand(900)); |
| - | my $aflags = "--port $port $flags"; |
| - | |
| - | my $cmd = "$exe $aflags"; |
| - | ($http3pid, $pid3) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($http3pid <= 0 || !pidexists($http3pid)) { |
| - | # it is NOT alive |
| - | stopserver($server, "$pid3"); |
| - | $doesntrun{$pidfile} = 1; |
| - | $http3pid = $pid3 = 0; |
| - | next; |
| - | } |
| - | $doesntrun{$pidfile} = 0; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server PID $http3pid port $port\n"; |
| - | } |
| - | last; |
| - | } |
| - | |
| - | logmsg "RUN: failed to start the $srvrname server\n" if(!$http3pid); |
| - | |
| - | return ($http3pid, $pid3, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the http server |
| - | # |
| - | sub runhttpserver { |
| - | my ($proto, $verb, $alt, $port_or_path) = @_; |
| - | my $ip = $HOSTIP; |
| - | my $ipvnum = 4; |
| - | my $idnum = 1; |
| - | my $exe = "$perl $srcdir/http-server.pl"; |
| - | my $verbose_flag = "--verbose "; |
| - | my $keepalive_secs = 30; # forwarded to sws, was 5 by default which |
| - | # led to pukes in CI jobs |
| - | |
| - | if($alt eq "ipv6") { |
| - | # if IPv6, use a different setup |
| - | $ipvnum = 6; |
| - | $ip = $HOST6IP; |
| - | } |
| - | elsif($alt eq "proxy") { |
| - | # basically the same, but another ID |
| - | $idnum = 2; |
| - | } |
| - | elsif($alt eq "unix") { |
| - | # IP (protocol) is mutually exclusive with Unix sockets |
| - | $ipvnum = "unix"; |
| - | } |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $portfile = $serverportfile{$server}; |
| - | |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--gopher " if($proto eq "gopher"); |
| - | $flags .= "--connect $HOSTIP " if($alt eq "proxy"); |
| - | $flags .= "--keepalive $keepalive_secs "; |
| - | $flags .= $verbose_flag if($debugprotocol); |
| - | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| - | $flags .= "--logdir \"$LOGDIR\" "; |
| - | $flags .= "--portfile $portfile "; |
| - | $flags .= "--config $FTPDCMD "; |
| - | $flags .= "--id $idnum " if($idnum > 1); |
| - | if($ipvnum eq "unix") { |
| - | $flags .= "--unix-socket '$port_or_path' "; |
| - | } else { |
| - | $flags .= "--ipv$ipvnum --port 0 "; |
| - | } |
| - | $flags .= "--srcdir \"$TESTDIR/..\""; |
| - | |
| - | my $cmd = "$exe $flags"; |
| - | my ($httppid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($httppid <= 0 || !pidexists($httppid)) { |
| - | # it is NOT alive |
| - | logmsg "RUN: failed to start the $srvrname server\n"; |
| - | stopserver($server, "$pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | # where is it? |
| - | my $port = 0; |
| - | if(!$port_or_path) { |
| - | $port = $port_or_path = pidfromfile($portfile); |
| - | } |
| - | |
| - | # Server is up. Verify that we can speak to it. |
| - | my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port_or_path); |
| - | if(!$pid3) { |
| - | logmsg "RUN: $srvrname server failed verification\n"; |
| - | # failed to talk to it properly. Kill the server and return failure |
| - | stopserver($server, "$httppid $pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | return (0, 0, 0); |
| - | } |
| - | $pid2 = $pid3; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server is on PID $httppid port $port_or_path\n"; |
| - | } |
| - | |
| - | return ($httppid, $pid2, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the https stunnel based server |
| - | # |
| - | sub runhttpsserver { |
| - | my ($verb, $proto, $proxy, $certfile) = @_; |
| - | my $ip = $HOSTIP; |
| - | my $ipvnum = 4; |
| - | my $idnum = 1; |
| - | |
| - | if($proxy eq "proxy") { |
| - | # the https-proxy runs as https2 |
| - | $idnum = 2; |
| - | } |
| - | |
| - | if(!$stunnel) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | $certfile = 'stunnel.pem' unless($certfile); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--verbose " if($debugprotocol); |
| - | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| - | $flags .= "--logdir \"$LOGDIR\" "; |
| - | $flags .= "--id $idnum " if($idnum > 1); |
| - | $flags .= "--ipv$ipvnum --proto $proto "; |
| - | $flags .= "--certfile \"$certfile\" " if($certfile ne 'stunnel.pem'); |
| - | $flags .= "--stunnel \"$stunnel\" --srcdir \"$srcdir\" "; |
| - | if($proto eq "gophers") { |
| - | $flags .= "--connect " . protoport("gopher"); |
| - | } |
| - | elsif(!$proxy) { |
| - | $flags .= "--connect " . protoport("http"); |
| - | } |
| - | else { |
| - | # for HTTPS-proxy we connect to the HTTP proxy |
| - | $flags .= "--connect " . protoport("httpproxy"); |
| - | } |
| - | |
| - | my $pid2; |
| - | my $httpspid; |
| - | my $port = 24512; # start attempt |
| - | for (1 .. 10) { |
| - | $port += int(rand(600)); |
| - | my $options = "$flags --accept $port"; |
| - | |
| - | my $cmd = "$perl $srcdir/secureserver.pl $options"; |
| - | ($httpspid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($httpspid <= 0 || !pidexists($httpspid)) { |
| - | # it is NOT alive |
| - | stopserver($server, "$pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | $httpspid = $pid2 = 0; |
| - | next; |
| - | } |
| - | # we have a server! |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server is PID $httpspid port $port\n"; |
| - | } |
| - | last; |
| - | } |
| - | $runcert{$server} = $certfile; |
| - | logmsg "RUN: failed to start the $srvrname server\n" if(!$httpspid); |
| - | |
| - | return ($httpspid, $pid2, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the non-stunnel HTTP TLS extensions capable server |
| - | # |
| - | sub runhttptlsserver { |
| - | my ($verb, $ipv6) = @_; |
| - | my $proto = "httptls"; |
| - | my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP"; |
| - | my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4; |
| - | my $idnum = 1; |
| - | |
| - | if(!$httptlssrv) { |
| - | return (0,0); |
| - | } |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--http "; |
| - | $flags .= "--debug 1 " if($debugprotocol); |
| - | $flags .= "--priority NORMAL:+SRP "; |
| - | $flags .= "--srppasswd $srcdir/certs/srp-verifier-db "; |
| - | $flags .= "--srppasswdconf $srcdir/certs/srp-verifier-conf"; |
| - | |
| - | my $port = 24367; |
| - | my ($httptlspid, $pid2); |
| - | for (1 .. 10) { |
| - | $port += int(rand(800)); |
| - | my $allflags = "--port $port $flags"; |
| - | |
| - | my $cmd = "$httptlssrv $allflags > $logfile 2>&1"; |
| - | ($httptlspid, $pid2) = startnew($cmd, $pidfile, 10, 1); |
| - | |
| - | if($httptlspid <= 0 || !pidexists($httptlspid)) { |
| - | # it is NOT alive |
| - | stopserver($server, "$pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | $httptlspid = $pid2 = 0; |
| - | next; |
| - | } |
| - | $doesntrun{$pidfile} = 0; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server PID $httptlspid port $port\n"; |
| - | } |
| - | last; |
| - | } |
| - | logmsg "RUN: failed to start the $srvrname server\n" if(!$httptlspid); |
| - | return ($httptlspid, $pid2, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the pingpong server (FTP, POP3, IMAP, SMTP) |
| - | # |
| - | sub runpingpongserver { |
| - | my ($proto, $id, $verb, $ipv6) = @_; |
| - | my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP"; |
| - | my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4; |
| - | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | my $portfile = $serverportfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0,0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--verbose " if($debugprotocol); |
| - | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| - | $flags .= "--logdir \"$LOGDIR\" "; |
| - | $flags .= "--portfile \"$portfile\" "; |
| - | $flags .= "--srcdir \"$srcdir\" --proto $proto "; |
| - | $flags .= "--id $idnum " if($idnum > 1); |
| - | $flags .= "--ipv$ipvnum --port 0 --addr \"$ip\""; |
| - | |
| - | my $cmd = "$perl $srcdir/ftpserver.pl $flags"; |
| - | my ($ftppid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($ftppid <= 0 || !pidexists($ftppid)) { |
| - | # it is NOT alive |
| - | logmsg "RUN: failed to start the $srvrname server\n"; |
| - | stopserver($server, "$pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | return (0,0); |
| - | } |
| - | |
| - | # where is it? |
| - | my $port = pidfromfile($portfile); |
| - | |
| - | logmsg "PINGPONG runs on port $port ($portfile)\n" if($verb); |
| - | |
| - | # Server is up. Verify that we can speak to it. |
| - | my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port); |
| - | if(!$pid3) { |
| - | logmsg "RUN: $srvrname server failed verification\n"; |
| - | # failed to talk to it properly. Kill the server and return failure |
| - | stopserver($server, "$ftppid $pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | return (0,0); |
| - | } |
| - | $pid2 = $pid3; |
| - | |
| - | logmsg "RUN: $srvrname server is PID $ftppid port $port\n" if($verb); |
| - | |
| - | # Assign the correct port variable! |
| - | if($proto =~ /^(?:ftp|imap|pop3|smtp)$/) { |
| - | $PORT{$proto . ($ipvnum == 6? '6': '')} = $port; |
| - | } |
| - | else { |
| - | print STDERR "Unsupported protocol $proto!!\n"; |
| - | return (0,0); |
| - | } |
| - | |
| - | return ($pid2, $ftppid); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the ftps/imaps/pop3s/smtps server (or rather, tunnel) |
| - | # |
| - | sub runsecureserver { |
| - | my ($verb, $ipv6, $certfile, $proto, $clearport) = @_; |
| - | my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP"; |
| - | my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4; |
| - | my $idnum = 1; |
| - | |
| - | if(!$stunnel) { |
| - | return (0,0); |
| - | } |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | $certfile = 'stunnel.pem' unless($certfile); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--verbose " if($debugprotocol); |
| - | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| - | $flags .= "--logdir \"$LOGDIR\" "; |
| - | $flags .= "--id $idnum " if($idnum > 1); |
| - | $flags .= "--ipv$ipvnum --proto $proto "; |
| - | $flags .= "--certfile \"$certfile\" " if($certfile ne 'stunnel.pem'); |
| - | $flags .= "--stunnel \"$stunnel\" --srcdir \"$srcdir\" "; |
| - | $flags .= "--connect $clearport"; |
| - | |
| - | my $protospid; |
| - | my $pid2; |
| - | my $port = 26713 + ord $proto; |
| - | my %usedports = reverse %PORT; |
| - | for (1 .. 10) { |
| - | $port += int(rand(700)); |
| - | next if exists $usedports{$port}; |
| - | my $options = "$flags --accept $port"; |
| - | my $cmd = "$perl $srcdir/secureserver.pl $options"; |
| - | ($protospid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($protospid <= 0 || !pidexists($protospid)) { |
| - | # it is NOT alive |
| - | stopserver($server, "$pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | $protospid = $pid2 = 0; |
| - | next; |
| - | } |
| - | |
| - | $doesntrun{$pidfile} = 0; |
| - | $runcert{$server} = $certfile; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server is PID $protospid port $port\n"; |
| - | } |
| - | last; |
| - | } |
| - | |
| - | logmsg "RUN: failed to start the $srvrname server\n" if(!$protospid); |
| - | |
| - | return ($protospid, $pid2, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the tftp server |
| - | # |
| - | sub runtftpserver { |
| - | my ($id, $verb, $ipv6) = @_; |
| - | my $ip = $HOSTIP; |
| - | my $proto = 'tftp'; |
| - | my $ipvnum = 4; |
| - | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| - | |
| - | if($ipv6) { |
| - | # if IPv6, use a different setup |
| - | $ipvnum = 6; |
| - | $ip = $HOST6IP; |
| - | } |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $portfile = $serverportfile{$server}; |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--verbose " if($debugprotocol); |
| - | $flags .= "--pidfile \"$pidfile\" "; |
| - | $flags .= "--portfile \"$portfile\" "; |
| - | $flags .= "--logfile \"$logfile\" "; |
| - | $flags .= "--logdir \"$LOGDIR\" "; |
| - | $flags .= "--id $idnum " if($idnum > 1); |
| - | $flags .= "--ipv$ipvnum --port 0 --srcdir \"$srcdir\""; |
| - | |
| - | my $cmd = "$perl $srcdir/tftpserver.pl $flags"; |
| - | my ($tftppid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($tftppid <= 0 || !pidexists($tftppid)) { |
| - | # it is NOT alive |
| - | logmsg "RUN: failed to start the $srvrname server\n"; |
| - | stopserver($server, "$pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $port = pidfromfile($portfile); |
| - | |
| - | # Server is up. Verify that we can speak to it. |
| - | my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port); |
| - | if(!$pid3) { |
| - | logmsg "RUN: $srvrname server failed verification\n"; |
| - | # failed to talk to it properly. Kill the server and return failure |
| - | stopserver($server, "$tftppid $pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | return (0, 0, 0); |
| - | } |
| - | $pid2 = $pid3; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server on PID $tftppid port $port\n"; |
| - | } |
| - | |
| - | return ($pid2, $tftppid, $port); |
| - | } |
| - | |
| - | |
| - | ####################################################################### |
| - | # start the rtsp server |
| - | # |
| - | sub runrtspserver { |
| - | my ($verb, $ipv6) = @_; |
| - | my $ip = $HOSTIP; |
| - | my $proto = 'rtsp'; |
| - | my $ipvnum = 4; |
| - | my $idnum = 1; |
| - | |
| - | if($ipv6) { |
| - | # if IPv6, use a different setup |
| - | $ipvnum = 6; |
| - | $ip = $HOST6IP; |
| - | } |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | my $portfile = $serverportfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--verbose " if($debugprotocol); |
| - | $flags .= "--pidfile \"$pidfile\" "; |
| - | $flags .= "--portfile \"$portfile\" "; |
| - | $flags .= "--logfile \"$logfile\" "; |
| - | $flags .= "--logdir \"$LOGDIR\" "; |
| - | $flags .= "--id $idnum " if($idnum > 1); |
| - | $flags .= "--ipv$ipvnum --port 0 --srcdir \"$srcdir\""; |
| - | |
| - | my $cmd = "$perl $srcdir/rtspserver.pl $flags"; |
| - | my ($rtsppid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($rtsppid <= 0 || !pidexists($rtsppid)) { |
| - | # it is NOT alive |
| - | logmsg "RUN: failed to start the $srvrname server\n"; |
| - | stopserver($server, "$pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $port = pidfromfile($portfile); |
| - | |
| - | # Server is up. Verify that we can speak to it. |
| - | my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port); |
| - | if(!$pid3) { |
| - | logmsg "RUN: $srvrname server failed verification\n"; |
| - | # failed to talk to it properly. Kill the server and return failure |
| - | stopserver($server, "$rtsppid $pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | return (0, 0, 0); |
| - | } |
| - | $pid2 = $pid3; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server PID $rtsppid port $port\n"; |
| - | } |
| - | |
| - | return ($rtsppid, $pid2, $port); |
| - | } |
| - | |
| - | |
| - | ####################################################################### |
| - | # Start the ssh (scp/sftp) server |
| - | # |
| - | sub runsshserver { |
| - | my ($id, $verb, $ipv6) = @_; |
| - | my $ip=$HOSTIP; |
| - | my $proto = 'ssh'; |
| - | my $ipvnum = 4; |
| - | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| - | my $port = 20000; # no lower port |
| - | |
| - | if(!$USER) { |
| - | logmsg "Can't start ssh server due to lack of USER name"; |
| - | return (0,0,0); |
| - | } |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $sshd = find_sshd(); |
| - | if($sshd) { |
| - | ($sshdid,$sshdvernum,$sshdverstr,$sshderror) = sshversioninfo($sshd); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--verbose " if($verb); |
| - | $flags .= "--debugprotocol " if($debugprotocol); |
| - | $flags .= "--pidfile \"$pidfile\" "; |
| - | $flags .= "--logdir \"$LOGDIR\" "; |
| - | $flags .= "--id $idnum " if($idnum > 1); |
| - | $flags .= "--ipv$ipvnum --addr \"$ip\" "; |
| - | $flags .= "--user \"$USER\""; |
| - | |
| - | my $sshpid; |
| - | my $pid2; |
| - | |
| - | my $wport = 0, |
| - | my @tports; |
| - | for(1 .. 10) { |
| - | |
| - | # sshd doesn't have a way to pick an unused random port number, so |
| - | # instead we iterate over possible port numbers to use until we find |
| - | # one that works |
| - | $port += int(rand(500)); |
| - | push @tports, $port; |
| - | |
| - | my $options = "$flags --sshport $port"; |
| - | |
| - | my $cmd = "$perl $srcdir/sshserver.pl $options"; |
| - | ($sshpid, $pid2) = startnew($cmd, $pidfile, 60, 0); |
| - | |
| - | # on loaded systems sshserver start up can take longer than the |
| - | # timeout passed to startnew, when this happens startnew completes |
| - | # without being able to read the pidfile and consequently returns a |
| - | # zero pid2 above. |
| - | if($sshpid <= 0 || !pidexists($sshpid)) { |
| - | # it is NOT alive |
| - | stopserver($server, "$pid2"); |
| - | $doesntrun{$pidfile} = 1; |
| - | $sshpid = $pid2 = 0; |
| - | next; |
| - | } |
| - | |
| - | # once it is known that the ssh server is alive, sftp server |
| - | # verification is performed actually connecting to it, authenticating |
| - | # and performing a very simple remote command. This verification is |
| - | # tried only one time. |
| - | |
| - | $sshdlog = server_logfilename($LOGDIR, 'ssh', $ipvnum, $idnum); |
| - | $sftplog = server_logfilename($LOGDIR, 'sftp', $ipvnum, $idnum); |
| - | |
| - | if(verifysftp('sftp', $ipvnum, $idnum, $ip, $port) < 1) { |
| - | logmsg "RUN: SFTP server failed verification\n"; |
| - | # failed to talk to it properly. Kill the server and return failure |
| - | display_sftplog(); |
| - | display_sftpconfig(); |
| - | display_sshdlog(); |
| - | display_sshdconfig(); |
| - | stopserver($server, "$sshpid $pid2"); |
| - | $doesntrun{$pidfile} = 1; |
| - | $sshpid = $pid2 = 0; |
| - | next; |
| - | } |
| - | # we're happy, no need to loop anymore! |
| - | $doesntrun{$pidfile} = 0; |
| - | $wport = $port; |
| - | last; |
| - | } |
| - | logmsg "RUN: failed to start the $srvrname server on $port\n" if(!$sshpid); |
| - | |
| - | if(!$wport) { |
| - | logmsg "RUN: couldn't start $srvrname. Tried these ports:"; |
| - | logmsg "RUN: ".join(", ", @tports)."\n"; |
| - | return (0,0,0); |
| - | } |
| - | |
| - | my $hostfile; |
| - | if(!open($hostfile, "<", $PIDDIR . "/" . $hstpubmd5f) || |
| - | (read($hostfile, $SSHSRVMD5, 32) != 32) || |
| - | !close($hostfile) || |
| - | ($SSHSRVMD5 !~ /^[a-f0-9]{32}$/i)) |
| - | { |
| - | my $msg = "Fatal: $srvrname pubkey md5 missing : \"$hstpubmd5f\" : $!"; |
| - | logmsg "$msg\n"; |
| - | stopservers($verb); |
| - | die $msg; |
| - | } |
| - | |
| - | if(!open($hostfile, "<", $PIDDIR . "/" . $hstpubsha256f) || |
| - | (read($hostfile, $SSHSRVSHA256, 48) == 0) || |
| - | !close($hostfile)) |
| - | { |
| - | my $msg = "Fatal: $srvrname pubkey sha256 missing : \"$hstpubsha256f\" : $!"; |
| - | logmsg "$msg\n"; |
| - | stopservers($verb); |
| - | die $msg; |
| - | } |
| - | |
| - | logmsg "RUN: $srvrname on PID $pid2 port $wport\n" if($verb); |
| - | |
| - | return ($pid2, $sshpid, $wport); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Start the MQTT server |
| - | # |
| - | sub runmqttserver { |
| - | my ($id, $verb, $ipv6) = @_; |
| - | my $ip=$HOSTIP; |
| - | my $proto = 'mqtt'; |
| - | my $port = protoport($proto); |
| - | my $ipvnum = 4; |
| - | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | my $pidfile = $serverpidfile{$server}; |
| - | my $portfile = $serverportfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0,0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | # start our MQTT server - on a random port! |
| - | my $cmd="server/mqttd".exe_ext('SRV'). |
| - | " --port 0 ". |
| - | " --pidfile $pidfile". |
| - | " --portfile $portfile". |
| - | " --config $FTPDCMD". |
| - | " --logfile $logfile". |
| - | " --logdir $LOGDIR"; |
| - | my ($sockspid, $pid2) = startnew($cmd, $pidfile, 30, 0); |
| - | |
| - | if($sockspid <= 0 || !pidexists($sockspid)) { |
| - | # it is NOT alive |
| - | logmsg "RUN: failed to start the $srvrname server\n"; |
| - | stopserver($server, "$pid2"); |
| - | $doesntrun{$pidfile} = 1; |
| - | return (0,0); |
| - | } |
| - | |
| - | my $mqttport = pidfromfile($portfile); |
| - | $PORT{"mqtt"} = $mqttport; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server is now running PID $pid2 on PORT $mqttport\n"; |
| - | } |
| - | |
| - | return ($pid2, $sockspid); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Start the socks server |
| - | # |
| - | sub runsocksserver { |
| - | my ($id, $verb, $ipv6, $is_unix) = @_; |
| - | my $ip=$HOSTIP; |
| - | my $proto = 'socks'; |
| - | my $ipvnum = 4; |
| - | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $portfile = $serverportfile{$server}; |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | # start our socks server, get commands from the FTP cmd file |
| - | my $cmd=""; |
| - | if($is_unix) { |
| - | $cmd="server/socksd".exe_ext('SRV'). |
| - | " --pidfile $pidfile". |
| - | " --reqfile $SOCKSIN". |
| - | " --logfile $logfile". |
| - | " --unix-socket $SOCKSUNIXPATH". |
| - | " --backend $HOSTIP". |
| - | " --config $FTPDCMD"; |
| - | } else { |
| - | $cmd="server/socksd".exe_ext('SRV'). |
| - | " --port 0 ". |
| - | " --pidfile $pidfile". |
| - | " --portfile $portfile". |
| - | " --reqfile $SOCKSIN". |
| - | " --logfile $logfile". |
| - | " --backend $HOSTIP". |
| - | " --config $FTPDCMD"; |
| - | } |
| - | my ($sockspid, $pid2) = startnew($cmd, $pidfile, 30, 0); |
| - | |
| - | if($sockspid <= 0 || !pidexists($sockspid)) { |
| - | # it is NOT alive |
| - | logmsg "RUN: failed to start the $srvrname server\n"; |
| - | stopserver($server, "$pid2"); |
| - | $doesntrun{$pidfile} = 1; |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $port = pidfromfile($portfile); |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server is now running PID $pid2\n"; |
| - | } |
| - | |
| - | return ($pid2, $sockspid, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the dict server |
| - | # |
| - | sub rundictserver { |
| - | my ($verb, $alt) = @_; |
| - | my $proto = "dict"; |
| - | my $ip = $HOSTIP; |
| - | my $ipvnum = 4; |
| - | my $idnum = 1; |
| - | |
| - | if($alt eq "ipv6") { |
| - | # No IPv6 |
| - | } |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--verbose 1 " if($debugprotocol); |
| - | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| - | $flags .= "--id $idnum " if($idnum > 1); |
| - | $flags .= "--srcdir \"$srcdir\" "; |
| - | $flags .= "--host $HOSTIP"; |
| - | |
| - | my $port = 29000; |
| - | my ($dictpid, $pid2); |
| - | for(1 .. 10) { |
| - | $port += int(rand(900)); |
| - | my $aflags = "--port $port $flags"; |
| - | my $cmd = "$srcdir/dictserver.py $aflags"; |
| - | ($dictpid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($dictpid <= 0 || !pidexists($dictpid)) { |
| - | # it is NOT alive |
| - | stopserver($server, "$pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | $dictpid = $pid2 = 0; |
| - | next; |
| - | } |
| - | $doesntrun{$pidfile} = 0; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server PID $dictpid port $port\n"; |
| - | } |
| - | last; |
| - | } |
| - | logmsg "RUN: failed to start the $srvrname server\n" if(!$dictpid); |
| - | |
| - | return ($dictpid, $pid2, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the SMB server |
| - | # |
| - | sub runsmbserver { |
| - | my ($verb, $alt) = @_; |
| - | my $proto = "smb"; |
| - | my $ip = $HOSTIP; |
| - | my $ipvnum = 4; |
| - | my $idnum = 1; |
| - | |
| - | if($alt eq "ipv6") { |
| - | # No IPv6 |
| - | } |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--verbose 1 " if($debugprotocol); |
| - | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| - | $flags .= "--id $idnum " if($idnum > 1); |
| - | $flags .= "--srcdir \"$srcdir\" "; |
| - | $flags .= "--host $HOSTIP"; |
| - | |
| - | my ($smbpid, $pid2); |
| - | my $port = 31923; |
| - | for(1 .. 10) { |
| - | $port += int(rand(760)); |
| - | my $aflags = "--port $port $flags"; |
| - | my $cmd = "$srcdir/smbserver.py $aflags"; |
| - | ($smbpid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($smbpid <= 0 || !pidexists($smbpid)) { |
| - | # it is NOT alive |
| - | stopserver($server, "$pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | $smbpid = $pid2 = 0; |
| - | next; |
| - | } |
| - | $doesntrun{$pidfile} = 0; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server PID $smbpid port $port\n"; |
| - | } |
| - | last; |
| - | } |
| - | logmsg "RUN: failed to start the $srvrname server\n" if(!$smbpid); |
| - | |
| - | return ($smbpid, $pid2, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # start the telnet server |
| - | # |
| - | sub runnegtelnetserver { |
| - | my ($verb, $alt) = @_; |
| - | my $proto = "telnet"; |
| - | my $ip = $HOSTIP; |
| - | my $ipvnum = 4; |
| - | my $idnum = 1; |
| - | |
| - | if($alt eq "ipv6") { |
| - | # No IPv6 |
| - | } |
| - | |
| - | my $server = servername_id($proto, $ipvnum, $idnum); |
| - | |
| - | my $pidfile = $serverpidfile{$server}; |
| - | |
| - | # don't retry if the server doesn't work |
| - | if ($doesntrun{$pidfile}) { |
| - | return (0, 0, 0); |
| - | } |
| - | |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | stopserver($server, "$pid"); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | |
| - | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| - | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| - | |
| - | my $flags = ""; |
| - | $flags .= "--verbose 1 " if($debugprotocol); |
| - | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| - | $flags .= "--id $idnum " if($idnum > 1); |
| - | $flags .= "--srcdir \"$srcdir\""; |
| - | |
| - | my ($ntelpid, $pid2); |
| - | my $port = 32000; |
| - | for(1 .. 10) { |
| - | $port += int(rand(800)); |
| - | my $aflags = "--port $port $flags"; |
| - | my $cmd = "$srcdir/negtelnetserver.py $aflags"; |
| - | ($ntelpid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| - | |
| - | if($ntelpid <= 0 || !pidexists($ntelpid)) { |
| - | # it is NOT alive |
| - | stopserver($server, "$pid2"); |
| - | displaylogs($testnumcheck); |
| - | $doesntrun{$pidfile} = 1; |
| - | $ntelpid = $pid2 = 0; |
| - | next; |
| - | } |
| - | $doesntrun{$pidfile} = 0; |
| - | |
| - | if($verb) { |
| - | logmsg "RUN: $srvrname server PID $ntelpid port $port\n"; |
| - | } |
| - | last; |
| - | } |
| - | logmsg "RUN: failed to start the $srvrname server\n" if(!$ntelpid); |
| - | |
| - | return ($ntelpid, $pid2, $port); |
| - | } |
| - | |
| - | |
| - | ####################################################################### |
| - | # Single shot http and gopher server responsiveness test. This should only |
| - | # be used to verify that a server present in %run hash is still functional |
| - | # |
| - | sub responsive_http_server { |
| - | my ($proto, $verb, $alt, $port_or_path) = @_; |
| - | my $ip = $HOSTIP; |
| - | my $ipvnum = 4; |
| - | my $idnum = 1; |
| - | |
| - | if($alt eq "ipv6") { |
| - | # if IPv6, use a different setup |
| - | $ipvnum = 6; |
| - | $ip = $HOST6IP; |
| - | } |
| - | elsif($alt eq "proxy") { |
| - | $idnum = 2; |
| - | } |
| - | elsif($alt eq "unix") { |
| - | # IP (protocol) is mutually exclusive with Unix sockets |
| - | $ipvnum = "unix"; |
| - | } |
| - | |
| - | return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port_or_path); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Single shot pingpong server responsiveness test. This should only be |
| - | # used to verify that a server present in %run hash is still functional |
| - | # |
| - | sub responsive_pingpong_server { |
| - | my ($proto, $id, $verb, $ipv6) = @_; |
| - | my $port; |
| - | my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP"; |
| - | my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4; |
| - | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| - | my $protoip = $proto . ($ipvnum == 6? '6': ''); |
| - | |
| - | if($proto =~ /^(?:ftp|imap|pop3|smtp)$/) { |
| - | $port = protoport($protoip); |
| - | } |
| - | else { |
| - | print STDERR "Unsupported protocol $proto!!\n"; |
| - | return 0; |
| - | } |
| - | |
| - | return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Single shot rtsp server responsiveness test. This should only be |
| - | # used to verify that a server present in %run hash is still functional |
| - | # |
| - | sub responsive_rtsp_server { |
| - | my ($verb, $ipv6) = @_; |
| - | my $proto = 'rtsp'; |
| - | my $port = protoport($proto); |
| - | my $ip = $HOSTIP; |
| - | my $ipvnum = 4; |
| - | my $idnum = 1; |
| - | |
| - | if($ipv6) { |
| - | # if IPv6, use a different setup |
| - | $ipvnum = 6; |
| - | $port = protoport('rtsp6'); |
| - | $ip = $HOST6IP; |
| - | } |
| - | |
| - | return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Single shot tftp server responsiveness test. This should only be |
| - | # used to verify that a server present in %run hash is still functional |
| - | # |
| - | sub responsive_tftp_server { |
| - | my ($id, $verb, $ipv6) = @_; |
| - | my $proto = 'tftp'; |
| - | my $port = protoport($proto); |
| - | my $ip = $HOSTIP; |
| - | my $ipvnum = 4; |
| - | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| - | |
| - | if($ipv6) { |
| - | # if IPv6, use a different setup |
| - | $ipvnum = 6; |
| - | $port = protoport('tftp6'); |
| - | $ip = $HOST6IP; |
| - | } |
| - | |
| - | return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Single shot non-stunnel HTTP TLS extensions capable server |
| - | # responsiveness test. This should only be used to verify that a |
| - | # server present in %run hash is still functional |
| - | # |
| - | sub responsive_httptls_server { |
| - | my ($verb, $ipv6) = @_; |
| - | my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4; |
| - | my $proto = "httptls"; |
| - | my $port = protoport($proto); |
| - | my $ip = "$HOSTIP"; |
| - | my $idnum = 1; |
| - | |
| - | if ($ipvnum == 6) { |
| - | $port = protoport("httptls6"); |
| - | $ip = "$HOST6IP"; |
| - | } |
| - | |
| - | return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port); |
| - | } |
| - | |
| - | ####################################################################### |
| - | # Kill the processes that still lock files in a directory |
| - | # |
| - | sub clearlocks { |
| - | my $dir = $_[0]; |
| - | my $done = 0; |
| - | |
| - | if(pathhelp::os_is_win()) { |
| - | $dir = pathhelp::sys_native_abs_path($dir); |
| - | $dir =~ s/\//\\\\/g; |
| - | my $handle = "handle.exe"; |
| - | if($ENV{"PROCESSOR_ARCHITECTURE"} =~ /64$/) { |
| - | $handle = "handle64.exe"; |
| - | } |
| - | my @handles = `$handle $dir -accepteula -nobanner`; |
| - | for my $tryhandle (@handles) { |
| - | if($tryhandle =~ /^(\S+)\s+pid:\s+(\d+)\s+type:\s+(\w+)\s+([0-9A-F]+):\s+(.+)\r\r/) { |
| - | logmsg "Found $3 lock of '$5' ($4) by $1 ($2)\n"; |
| - | # Ignore stunnel since we cannot do anything about its locks |
| - | if("$3" eq "File" && "$1" ne "tstunnel.exe") { |
| - | logmsg "Killing IMAGENAME eq $1 and PID eq $2\n"; |
| - | system("taskkill.exe -f -fi \"IMAGENAME eq $1\" -fi \"PID eq $2\" >nul 2>&1"); |
| - | $done = 1; |
| + | } |
| + | |
| + | # verify that it returns a proper error code, doesn't leak memory |
| + | # and doesn't core dump |
| + | if(($ret & 255) || ($ret >> 8) >= 128) { |
| + | logmsg " system() returned $ret\n"; |
| + | $fail=1; |
| + | } |
| + | else { |
| + | my @memdata=`$memanalyze $memdump`; |
| + | my $leak=0; |
| + | for(@memdata) { |
| + | if($_ ne "") { |
| + | # well it could be other memory problems as well, but |
| + | # we call it leak for short here |
| + | $leak=1; |
| } | |
| } | |
| + | if($leak) { |
| + | logmsg "** MEMORY FAILURE\n"; |
| + | logmsg @memdata; |
| + | logmsg `$memanalyze -l $memdump`; |
| + | $fail = 1; |
| + | } |
| + | } |
| + | if($fail) { |
| + | logmsg " Failed on function number $limit in test.\n", |
| + | " invoke with \"-t$limit\" to repeat this single case.\n"; |
| + | stopservers($verbose); |
| + | return 1; |
| } | |
| } | |
| - | return $done; |
| + | |
| + | logmsg "torture OK\n"; |
| + | return 0; |
| } | |
| + | |
| ####################################################################### | |
| # Remove all files in the specified directory | |
| # | |
| @@ -2772,8 +572,9 @@ sub compare { | |
| } | |
| ####################################################################### | |
| - | # display information about curl and the host the test suite runs on |
| - | # |
| + | # Check & display information about curl and the host the test suite runs on. |
| + | # Information to do with servers is displayed in displayserverfeatures, after |
| + | # the server initialization is performed. |
| sub checksystemfeatures { | |
| my $feat; | |
| my $curl; | |
| @@ -2824,7 +625,7 @@ sub checksystemfeatures { | |
| if($curl =~ /win32|Windows|mingw(32|64)/) { | |
| # This is a Windows MinGW build or native build, we need to use | |
| # Win32-style path. | |
| - | $pwd = pathhelp::sys_native_current_path(); |
| + | $pwd = sys_native_current_path(); |
| $has_textaware = 1; | |
| $feature{"win32"} = 1; | |
| # set if built with MinGW (as opposed to MinGW-w64) | |
| @@ -3132,6 +933,7 @@ sub checksystemfeatures { | |
| my $hosttype=join(' ', runclientoutput("uname -a")); | |
| my $hostos=$^O; | |
| + | # display summary information about curl and the test host |
| logmsg ("********* System characteristics ******** \n", | |
| "* $curl\n", | |
| "* $libcurl\n", | |
| @@ -3142,23 +944,35 @@ sub checksystemfeatures { | |
| "* OS: $hostos\n"); | |
| if($feature{"TrackMemory"} && $feature{"threaded-resolver"}) { | |
| - | $feature{"TrackMemory"} = 0; |
| logmsg("*\n", | |
| "*** DISABLES memory tracking when using threaded resolver\n", | |
| "*\n"); | |
| } | |
| - | logmsg sprintf("* Servers: %s", $stunnel?"SSL ":""); |
| - | logmsg sprintf("%s", $http_ipv6?"HTTP-IPv6 ":""); |
| - | logmsg sprintf("%s", $http_unix?"HTTP-unix ":""); |
| - | logmsg sprintf("%s\n", $ftp_ipv6?"FTP-IPv6 ":""); |
| - | |
| logmsg sprintf("* Env: %s%s%s", $valgrind?"Valgrind ":"", | |
| $run_event_based?"event-based ":"", | |
| $nghttpx_h3); | |
| logmsg sprintf("%s\n", $libtool?"Libtool ":""); | |
| logmsg ("* Seed: $randseed\n"); | |
| + | # Disable memory tracking when using threaded resolver |
| + | $feature{"TrackMemory"} = $feature{"TrackMemory"} && !$feature{"threaded-resolver"}; |
| + | |
| + | # toggle off the features that were disabled in the build |
| + | for my $d(@disabled) { |
| + | $feature{$d} = 0; |
| + | } |
| + | } |
| + | |
| + | ####################################################################### |
| + | # display information about server features |
| + | # |
| + | sub displayserverfeatures { |
| + | logmsg sprintf("* Servers: %s", $stunnel?"SSL ":""); |
| + | logmsg sprintf("%s", $http_ipv6?"HTTP-IPv6 ":""); |
| + | logmsg sprintf("%s", $http_unix?"HTTP-unix ":""); |
| + | logmsg sprintf("%s\n", $ftp_ipv6?"FTP-IPv6 ":""); |
| + | |
| if($verbose) { | |
| if($feature{"unix-sockets"}) { | |
| logmsg "* Unix socket paths:\n"; | |
| @@ -3170,11 +984,6 @@ sub checksystemfeatures { | |
| } | |
| logmsg "***************************************** \n"; | |
| - | |
| - | # toggle off the features that were disabled in the build |
| - | for my $d(@disabled) { |
| - | $feature{$d} = 0; |
| - | } |
| } | |
| ####################################################################### | |
| @@ -3241,6 +1050,9 @@ sub subVariables { | |
| $file_pwd = "/$file_pwd"; | |
| } | |
| my $ssh_pwd = $posix_pwd; | |
| + | # this only works after the SSH server has been started |
| + | # TODO: call sshversioninfo early and store $sshdid so this substitution |
| + | # always works |
| if ($sshdid && $sshdid =~ /OpenSSH-Windows/) { | |
| $ssh_pwd = $file_pwd; | |
| } | |
| @@ -3685,7 +1497,13 @@ sub singletest_startservers { | |
| $timesrvrini{$testnum} = Time::HiRes::time(); | |
| if (!$why && !$listonly) { | |
| - | $why = serverfortest($testnum); |
| + | my @what = getpart("client", "server"); |
| + | if(!$what[0]) { |
| + | warn "Test case $testnum has no server(s) specified"; |
| + | $why = "no server specified"; |
| + | } else { |
| + | $why = serverfortest(@what); |
| + | } |
| } | |
| # timestamp required servers verification end | |
| @@ -4850,647 +2668,6 @@ sub singletest { | |
| return 0; | |
| } | |
| - | ####################################################################### |
| - | # Stop all running test servers |
| - | # |
| - | sub stopservers { |
| - | my $verb = $_[0]; |
| - | # |
| - | # kill sockfilter processes for all pingpong servers |
| - | # |
| - | killallsockfilters($PIDDIR, $verb); |
| - | # |
| - | # kill all server pids from %run hash clearing them |
| - | # |
| - | my $pidlist; |
| - | foreach my $server (keys %run) { |
| - | if($run{$server}) { |
| - | if($verb) { |
| - | my $prev = 0; |
| - | my $pids = $run{$server}; |
| - | foreach my $pid (split(' ', $pids)) { |
| - | if($pid != $prev) { |
| - | logmsg sprintf("* kill pid for %s => %d\n", |
| - | $server, $pid); |
| - | $prev = $pid; |
| - | } |
| - | } |
| - | } |
| - | $pidlist .= "$run{$server} "; |
| - | $run{$server} = 0; |
| - | } |
| - | $runcert{$server} = 0 if($runcert{$server}); |
| - | } |
| - | killpid($verb, $pidlist); |
| - | # |
| - | # cleanup all server pid files |
| - | # |
| - | my $result = 0; |
| - | foreach my $server (keys %serverpidfile) { |
| - | my $pidfile = $serverpidfile{$server}; |
| - | my $pid = processexists($pidfile); |
| - | if($pid > 0) { |
| - | if($err_unexpected) { |
| - | logmsg "ERROR: "; |
| - | $result = -1; |
| - | } |
| - | else { |
| - | logmsg "Warning: "; |
| - | } |
| - | logmsg "$server server unexpectedly alive\n"; |
| - | killpid($verb, $pid); |
| - | } |
| - | unlink($pidfile) if(-f $pidfile); |
| - | } |
| - | |
| - | return $result; |
| - | } |
| - | |
| - | ####################################################################### |
| - | # startservers() starts all the named servers |
| - | # |
| - | # Returns: string with error reason or blank for success |
| - | # |
| - | sub startservers { |
| - | my @what = @_; |
| - | my ($pid, $pid2); |
| - | for(@what) { |
| - | my (@whatlist) = split(/\s+/,$_); |
| - | my $what = lc($whatlist[0]); |
| - | $what =~ s/[^a-z0-9\/-]//g; |
| - | |
| - | my $certfile; |
| - | if($what =~ /^(ftp|gopher|http|imap|pop3|smtp)s((\d*)(-ipv6|-unix|))$/) { |
| - | $certfile = ($whatlist[1]) ? $whatlist[1] : 'stunnel.pem'; |
| - | } |
| - | |
| - | if(($what eq "pop3") || |
| - | ($what eq "ftp") || |
| - | ($what eq "imap") || |
| - | ($what eq "smtp")) { |
| - | if($torture && $run{$what} && |
| - | !responsive_pingpong_server($what, "", $verbose)) { |
| - | if(stopserver($what)) { |
| - | return "failed stopping unresponsive ".uc($what)." server"; |
| - | } |
| - | } |
| - | if(!$run{$what}) { |
| - | ($pid, $pid2) = runpingpongserver($what, "", $verbose); |
| - | if($pid <= 0) { |
| - | return "failed starting ". uc($what) ." server"; |
| - | } |
| - | printf ("* pid $what => %d %d\n", $pid, $pid2) if($verbose); |
| - | $run{$what}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "ftp-ipv6") { |
| - | if($torture && $run{'ftp-ipv6'} && |
| - | !responsive_pingpong_server("ftp", "", $verbose, "ipv6")) { |
| - | if(stopserver('ftp-ipv6')) { |
| - | return "failed stopping unresponsive FTP-IPv6 server"; |
| - | } |
| - | } |
| - | if(!$run{'ftp-ipv6'}) { |
| - | ($pid, $pid2) = runpingpongserver("ftp", "", $verbose, "ipv6"); |
| - | if($pid <= 0) { |
| - | return "failed starting FTP-IPv6 server"; |
| - | } |
| - | logmsg sprintf("* pid ftp-ipv6 => %d %d\n", $pid, |
| - | $pid2) if($verbose); |
| - | $run{'ftp-ipv6'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "gopher") { |
| - | if($torture && $run{'gopher'} && |
| - | !responsive_http_server("gopher", $verbose, 0, |
| - | protoport("gopher"))) { |
| - | if(stopserver('gopher')) { |
| - | return "failed stopping unresponsive GOPHER server"; |
| - | } |
| - | } |
| - | if(!$run{'gopher'}) { |
| - | ($pid, $pid2, $PORT{'gopher'}) = |
| - | runhttpserver("gopher", $verbose, 0); |
| - | if($pid <= 0) { |
| - | return "failed starting GOPHER server"; |
| - | } |
| - | logmsg sprintf ("* pid gopher => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'gopher'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "gopher-ipv6") { |
| - | if($torture && $run{'gopher-ipv6'} && |
| - | !responsive_http_server("gopher", $verbose, "ipv6", |
| - | protoport("gopher"))) { |
| - | if(stopserver('gopher-ipv6')) { |
| - | return "failed stopping unresponsive GOPHER-IPv6 server"; |
| - | } |
| - | } |
| - | if(!$run{'gopher-ipv6'}) { |
| - | ($pid, $pid2, $PORT{"gopher6"}) = |
| - | runhttpserver("gopher", $verbose, "ipv6"); |
| - | if($pid <= 0) { |
| - | return "failed starting GOPHER-IPv6 server"; |
| - | } |
| - | logmsg sprintf("* pid gopher-ipv6 => %d %d\n", $pid, |
| - | $pid2) if($verbose); |
| - | $run{'gopher-ipv6'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "http/3") { |
| - | if(!$run{'http/3'}) { |
| - | ($pid, $pid2, $PORT{"http3"}) = runhttp3server($verbose); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTP/3 server"; |
| - | } |
| - | logmsg sprintf ("* pid http/3 => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'http/3'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "http/2") { |
| - | if(!$run{'http/2'}) { |
| - | ($pid, $pid2, $PORT{"http2"}, $PORT{"http2tls"}) = |
| - | runhttp2server($verbose); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTP/2 server"; |
| - | } |
| - | logmsg sprintf ("* pid http/2 => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'http/2'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "http") { |
| - | if($torture && $run{'http'} && |
| - | !responsive_http_server("http", $verbose, 0, protoport('http'))) { |
| - | if(stopserver('http')) { |
| - | return "failed stopping unresponsive HTTP server"; |
| - | } |
| - | } |
| - | if(!$run{'http'}) { |
| - | ($pid, $pid2, $PORT{'http'}) = |
| - | runhttpserver("http", $verbose, 0); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTP server"; |
| - | } |
| - | logmsg sprintf ("* pid http => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'http'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "http-proxy") { |
| - | if($torture && $run{'http-proxy'} && |
| - | !responsive_http_server("http", $verbose, "proxy", |
| - | protoport("httpproxy"))) { |
| - | if(stopserver('http-proxy')) { |
| - | return "failed stopping unresponsive HTTP-proxy server"; |
| - | } |
| - | } |
| - | if(!$run{'http-proxy'}) { |
| - | ($pid, $pid2, $PORT{"httpproxy"}) = |
| - | runhttpserver("http", $verbose, "proxy"); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTP-proxy server"; |
| - | } |
| - | logmsg sprintf ("* pid http-proxy => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'http-proxy'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "http-ipv6") { |
| - | if($torture && $run{'http-ipv6'} && |
| - | !responsive_http_server("http", $verbose, "ipv6", |
| - | protoport("http6"))) { |
| - | if(stopserver('http-ipv6')) { |
| - | return "failed stopping unresponsive HTTP-IPv6 server"; |
| - | } |
| - | } |
| - | if(!$run{'http-ipv6'}) { |
| - | ($pid, $pid2, $PORT{"http6"}) = |
| - | runhttpserver("http", $verbose, "ipv6"); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTP-IPv6 server"; |
| - | } |
| - | logmsg sprintf("* pid http-ipv6 => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'http-ipv6'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "rtsp") { |
| - | if($torture && $run{'rtsp'} && |
| - | !responsive_rtsp_server($verbose)) { |
| - | if(stopserver('rtsp')) { |
| - | return "failed stopping unresponsive RTSP server"; |
| - | } |
| - | } |
| - | if(!$run{'rtsp'}) { |
| - | ($pid, $pid2, $PORT{'rtsp'}) = runrtspserver($verbose); |
| - | if($pid <= 0) { |
| - | return "failed starting RTSP server"; |
| - | } |
| - | printf ("* pid rtsp => %d %d\n", $pid, $pid2) if($verbose); |
| - | $run{'rtsp'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "rtsp-ipv6") { |
| - | if($torture && $run{'rtsp-ipv6'} && |
| - | !responsive_rtsp_server($verbose, "ipv6")) { |
| - | if(stopserver('rtsp-ipv6')) { |
| - | return "failed stopping unresponsive RTSP-IPv6 server"; |
| - | } |
| - | } |
| - | if(!$run{'rtsp-ipv6'}) { |
| - | ($pid, $pid2, $PORT{'rtsp6'}) = runrtspserver($verbose, "ipv6"); |
| - | if($pid <= 0) { |
| - | return "failed starting RTSP-IPv6 server"; |
| - | } |
| - | logmsg sprintf("* pid rtsp-ipv6 => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'rtsp-ipv6'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what =~ /^(ftp|imap|pop3|smtp)s$/) { |
| - | my $cproto = $1; |
| - | if(!$stunnel) { |
| - | # we can't run ftps tests without stunnel |
| - | return "no stunnel"; |
| - | } |
| - | if($runcert{$what} && ($runcert{$what} ne $certfile)) { |
| - | # stop server when running and using a different cert |
| - | if(stopserver($what)) { |
| - | return "failed stopping $what server with different cert"; |
| - | } |
| - | } |
| - | if($torture && $run{$cproto} && |
| - | !responsive_pingpong_server($cproto, "", $verbose)) { |
| - | if(stopserver($cproto)) { |
| - | return "failed stopping unresponsive $cproto server"; |
| - | } |
| - | } |
| - | if(!$run{$cproto}) { |
| - | ($pid, $pid2) = runpingpongserver($cproto, "", $verbose); |
| - | if($pid <= 0) { |
| - | return "failed starting $cproto server"; |
| - | } |
| - | printf ("* pid $cproto => %d %d\n", $pid, $pid2) if($verbose); |
| - | $run{$cproto}="$pid $pid2"; |
| - | } |
| - | if(!$run{$what}) { |
| - | ($pid, $pid2, $PORT{$what}) = |
| - | runsecureserver($verbose, "", $certfile, $what, |
| - | protoport($cproto)); |
| - | if($pid <= 0) { |
| - | return "failed starting $what server (stunnel)"; |
| - | } |
| - | logmsg sprintf("* pid $what => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{$what}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "file") { |
| - | # we support it but have no server! |
| - | } |
| - | elsif($what eq "https") { |
| - | if(!$stunnel) { |
| - | # we can't run https tests without stunnel |
| - | return "no stunnel"; |
| - | } |
| - | if($runcert{'https'} && ($runcert{'https'} ne $certfile)) { |
| - | # stop server when running and using a different cert |
| - | if(stopserver('https')) { |
| - | return "failed stopping HTTPS server with different cert"; |
| - | } |
| - | } |
| - | if($torture && $run{'http'} && |
| - | !responsive_http_server("http", $verbose, 0, |
| - | protoport('http'))) { |
| - | if(stopserver('http')) { |
| - | return "failed stopping unresponsive HTTP server"; |
| - | } |
| - | } |
| - | if(!$run{'http'}) { |
| - | ($pid, $pid2, $PORT{'http'}) = |
| - | runhttpserver("http", $verbose, 0); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTP server"; |
| - | } |
| - | printf ("* pid http => %d %d\n", $pid, $pid2) if($verbose); |
| - | $run{'http'}="$pid $pid2"; |
| - | } |
| - | if(!$run{'https'}) { |
| - | ($pid, $pid2, $PORT{'https'}) = |
| - | runhttpsserver($verbose, "https", "", $certfile); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTPS server (stunnel)"; |
| - | } |
| - | logmsg sprintf("* pid https => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'https'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "gophers") { |
| - | if(!$stunnel) { |
| - | # we can't run TLS tests without stunnel |
| - | return "no stunnel"; |
| - | } |
| - | if($runcert{'gophers'} && ($runcert{'gophers'} ne $certfile)) { |
| - | # stop server when running and using a different cert |
| - | if(stopserver('gophers')) { |
| - | return "failed stopping GOPHERS server with different crt"; |
| - | } |
| - | } |
| - | if($torture && $run{'gopher'} && |
| - | !responsive_http_server("gopher", $verbose, 0, |
| - | protoport('gopher'))) { |
| - | if(stopserver('gopher')) { |
| - | return "failed stopping unresponsive GOPHER server"; |
| - | } |
| - | } |
| - | if(!$run{'gopher'}) { |
| - | my $port; |
| - | ($pid, $pid2, $port) = |
| - | runhttpserver("gopher", $verbose, 0); |
| - | $PORT{'gopher'} = $port; |
| - | if($pid <= 0) { |
| - | return "failed starting GOPHER server"; |
| - | } |
| - | printf ("* pid gopher => %d %d\n", $pid, $pid2) if($verbose); |
| - | print "GOPHERPORT => $port\n" if($verbose); |
| - | $run{'gopher'}="$pid $pid2"; |
| - | } |
| - | if(!$run{'gophers'}) { |
| - | my $port; |
| - | ($pid, $pid2, $port) = |
| - | runhttpsserver($verbose, "gophers", "", $certfile); |
| - | $PORT{'gophers'} = $port; |
| - | if($pid <= 0) { |
| - | return "failed starting GOPHERS server (stunnel)"; |
| - | } |
| - | logmsg sprintf("* pid gophers => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | print "GOPHERSPORT => $port\n" if($verbose); |
| - | $run{'gophers'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "https-proxy") { |
| - | if(!$stunnel) { |
| - | # we can't run https-proxy tests without stunnel |
| - | return "no stunnel"; |
| - | } |
| - | if($runcert{'https-proxy'} && |
| - | ($runcert{'https-proxy'} ne $certfile)) { |
| - | # stop server when running and using a different cert |
| - | if(stopserver('https-proxy')) { |
| - | return "failed stopping HTTPS-proxy with different cert"; |
| - | } |
| - | } |
| - | |
| - | # we front the http-proxy with stunnel so we need to make sure the |
| - | # proxy runs as well |
| - | my $f = startservers("http-proxy"); |
| - | if($f) { |
| - | return $f; |
| - | } |
| - | |
| - | if(!$run{'https-proxy'}) { |
| - | ($pid, $pid2, $PORT{"httpsproxy"}) = |
| - | runhttpsserver($verbose, "https", "proxy", $certfile); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTPS-proxy (stunnel)"; |
| - | } |
| - | logmsg sprintf("* pid https-proxy => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'https-proxy'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "httptls") { |
| - | if(!$httptlssrv) { |
| - | # for now, we can't run http TLS-EXT tests without gnutls-serv |
| - | return "no gnutls-serv (with SRP support)"; |
| - | } |
| - | if($torture && $run{'httptls'} && |
| - | !responsive_httptls_server($verbose, "IPv4")) { |
| - | if(stopserver('httptls')) { |
| - | return "failed stopping unresponsive HTTPTLS server"; |
| - | } |
| - | } |
| - | if(!$run{'httptls'}) { |
| - | ($pid, $pid2, $PORT{'httptls'}) = |
| - | runhttptlsserver($verbose, "IPv4"); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTPTLS server (gnutls-serv)"; |
| - | } |
| - | logmsg sprintf("* pid httptls => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'httptls'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "httptls-ipv6") { |
| - | if(!$httptlssrv) { |
| - | # for now, we can't run http TLS-EXT tests without gnutls-serv |
| - | return "no gnutls-serv"; |
| - | } |
| - | if($torture && $run{'httptls-ipv6'} && |
| - | !responsive_httptls_server($verbose, "ipv6")) { |
| - | if(stopserver('httptls-ipv6')) { |
| - | return "failed stopping unresponsive HTTPTLS-IPv6 server"; |
| - | } |
| - | } |
| - | if(!$run{'httptls-ipv6'}) { |
| - | ($pid, $pid2, $PORT{"httptls6"}) = |
| - | runhttptlsserver($verbose, "ipv6"); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTPTLS-IPv6 server (gnutls-serv)"; |
| - | } |
| - | logmsg sprintf("* pid httptls-ipv6 => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'httptls-ipv6'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "tftp") { |
| - | if($torture && $run{'tftp'} && |
| - | !responsive_tftp_server("", $verbose)) { |
| - | if(stopserver('tftp')) { |
| - | return "failed stopping unresponsive TFTP server"; |
| - | } |
| - | } |
| - | if(!$run{'tftp'}) { |
| - | ($pid, $pid2, $PORT{'tftp'}) = |
| - | runtftpserver("", $verbose); |
| - | if($pid <= 0) { |
| - | return "failed starting TFTP server"; |
| - | } |
| - | printf ("* pid tftp => %d %d\n", $pid, $pid2) if($verbose); |
| - | $run{'tftp'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "tftp-ipv6") { |
| - | if($torture && $run{'tftp-ipv6'} && |
| - | !responsive_tftp_server("", $verbose, "ipv6")) { |
| - | if(stopserver('tftp-ipv6')) { |
| - | return "failed stopping unresponsive TFTP-IPv6 server"; |
| - | } |
| - | } |
| - | if(!$run{'tftp-ipv6'}) { |
| - | ($pid, $pid2, $PORT{'tftp6'}) = |
| - | runtftpserver("", $verbose, "ipv6"); |
| - | if($pid <= 0) { |
| - | return "failed starting TFTP-IPv6 server"; |
| - | } |
| - | printf("* pid tftp-ipv6 => %d %d\n", $pid, $pid2) if($verbose); |
| - | $run{'tftp-ipv6'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "sftp" || $what eq "scp") { |
| - | if(!$run{'ssh'}) { |
| - | ($pid, $pid2, $PORT{'ssh'}) = runsshserver("", $verbose); |
| - | if($pid <= 0) { |
| - | return "failed starting SSH server"; |
| - | } |
| - | printf ("* pid ssh => %d %d\n", $pid, $pid2) if($verbose); |
| - | $run{'ssh'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "socks4" || $what eq "socks5" ) { |
| - | if(!$run{'socks'}) { |
| - | ($pid, $pid2, $PORT{"socks"}) = runsocksserver("", $verbose); |
| - | if($pid <= 0) { |
| - | return "failed starting socks server"; |
| - | } |
| - | printf ("* pid socks => %d %d\n", $pid, $pid2) if($verbose); |
| - | $run{'socks'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "socks5unix") { |
| - | if(!$run{'socks5unix'}) { |
| - | ($pid, $pid2) = runsocksserver("2", $verbose, "", "unix"); |
| - | if($pid <= 0) { |
| - | return "failed starting socks5unix server"; |
| - | } |
| - | printf ("* pid socks5unix => %d %d\n", $pid, $pid2) if($verbose); |
| - | $run{'socks5unix'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "mqtt" ) { |
| - | if(!$run{'mqtt'}) { |
| - | ($pid, $pid2) = runmqttserver("", $verbose); |
| - | if($pid <= 0) { |
| - | return "failed starting mqtt server"; |
| - | } |
| - | printf ("* pid mqtt => %d %d\n", $pid, $pid2) if($verbose); |
| - | $run{'mqtt'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "http-unix") { |
| - | if($torture && $run{'http-unix'} && |
| - | !responsive_http_server("http", $verbose, "unix", $HTTPUNIXPATH)) { |
| - | if(stopserver('http-unix')) { |
| - | return "failed stopping unresponsive HTTP-unix server"; |
| - | } |
| - | } |
| - | if(!$run{'http-unix'}) { |
| - | my $unused; |
| - | ($pid, $pid2, $unused) = |
| - | runhttpserver("http", $verbose, "unix", $HTTPUNIXPATH); |
| - | if($pid <= 0) { |
| - | return "failed starting HTTP-unix server"; |
| - | } |
| - | logmsg sprintf("* pid http-unix => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'http-unix'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "dict") { |
| - | if(!$run{'dict'}) { |
| - | ($pid, $pid2, $PORT{"dict"}) = rundictserver($verbose, ""); |
| - | if($pid <= 0) { |
| - | return "failed starting DICT server"; |
| - | } |
| - | logmsg sprintf ("* pid DICT => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'dict'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "smb") { |
| - | if(!$run{'smb'}) { |
| - | ($pid, $pid2, $PORT{"smb"}) = runsmbserver($verbose, ""); |
| - | if($pid <= 0) { |
| - | return "failed starting SMB server"; |
| - | } |
| - | logmsg sprintf ("* pid SMB => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'smb'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "telnet") { |
| - | if(!$run{'telnet'}) { |
| - | ($pid, $pid2, $PORT{"telnet"}) = |
| - | runnegtelnetserver($verbose, ""); |
| - | if($pid <= 0) { |
| - | return "failed starting neg TELNET server"; |
| - | } |
| - | logmsg sprintf ("* pid neg TELNET => %d %d\n", $pid, $pid2) |
| - | if($verbose); |
| - | $run{'telnet'}="$pid $pid2"; |
| - | } |
| - | } |
| - | elsif($what eq "none") { |
| - | logmsg "* starts no server\n" if ($verbose); |
| - | } |
| - | else { |
| - | warn "we don't support a server for $what"; |
| - | return "no server for $what"; |
| - | } |
| - | } |
| - | return 0; |
| - | } |
| - | |
| - | ############################################################################## |
| - | # This function makes sure the right set of server is running for the |
| - | # specified test case. This is a useful design when we run single tests as not |
| - | # all servers need to run then! |
| - | # |
| - | # Returns: a string, blank if everything is fine or a reason why it failed |
| - | # |
| - | sub serverfortest { |
| - | my ($testnum)=@_; |
| - | |
| - | my @what = getpart("client", "server"); |
| - | |
| - | if(!$what[0]) { |
| - | warn "Test case $testnum has no server(s) specified"; |
| - | return "no server specified"; |
| - | } |
| - | |
| - | for(my $i = scalar(@what) - 1; $i >= 0; $i--) { |
| - | my $srvrline = $what[$i]; |
| - | chomp $srvrline if($srvrline); |
| - | if($srvrline =~ /^(\S+)((\s*)(.*))/) { |
| - | my $server = "${1}"; |
| - | my $lnrest = "${2}"; |
| - | my $tlsext; |
| - | if($server =~ /^(httptls)(\+)(ext|srp)(\d*)(-ipv6|)$/) { |
| - | $server = "${1}${4}${5}"; |
| - | $tlsext = uc("TLS-${3}"); |
| - | } |
| - | if(! grep /^\Q$server\E$/, @protocols) { |
| - | if(substr($server,0,5) ne "socks") { |
| - | if($tlsext) { |
| - | return "curl lacks $tlsext support"; |
| - | } |
| - | else { |
| - | return "curl lacks $server server support"; |
| - | } |
| - | } |
| - | } |
| - | $what[$i] = "$server$lnrest" if($tlsext); |
| - | } |
| - | } |
| - | |
| - | return &startservers(@what); |
| - | } |
| - | |
| ####################################################################### | |
| # runtimestats displays test-suite run time statistics | |
| # | |
| @@ -5980,9 +3157,6 @@ if ($gdbthis) { | |
| } | |
| } | |
| - | $HTTPUNIXPATH = "$PIDDIR/http.sock"; # HTTP server Unix domain socket path |
| - | $SOCKSUNIXPATH = "$PIDDIR/socks.sock"; # SOCKS server Unix domain socket path |
| - | |
| ####################################################################### | |
| # clear and create logging directory: | |
| # | |
| @@ -5996,7 +3170,6 @@ mkdir($PIDDIR, 0777); | |
| # | |
| get_disttests(); | |
| - | init_serverpidfile_hash(); |
| ####################################################################### | |
| # Output curl version and host info being tested | |
| @@ -6005,6 +3178,16 @@ init_serverpidfile_hash(); | |
| if(!$listonly) { | |
| unlink($memdump); # remove this if there was one left | |
| checksystemfeatures(); | |
| + | } |
| + | |
| + | ####################################################################### |
| + | # initialize configuration needed to set up servers |
| + | # |
| + | initserverconfig(); |
| + | |
| + | if(!$listonly) { |
| + | # these can only be displayed after initserverconfig() has been called |
| + | displayserverfeatures(); |
| # globally disabled tests | |
| disabledtests("$TESTDIR/DISABLED"); | |
| @@ -0,0 +1,2956 @@ | |
| + | #*************************************************************************** |
| + | # _ _ ____ _ |
| + | # Project ___| | | | _ \| | |
| + | # / __| | | | |_) | | |
| + | # | (__| |_| | _ <| |___ |
| + | # \___|\___/|_| \_\_____| |
| + | # |
| + | # Copyright (C) Daniel Stenberg, <[email protected]>, 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 |
| + | # |
| + | ########################################################################### |
| + | |
| + | # This module contains functions that are useful for managing the lifecycle of |
| + | # test servers required when running tests. It is not intended for use within |
| + | # those servers, but rather for starting and stopping them. |
| + | |
| + | package servers; |
| + | |
| + | use strict; |
| + | use warnings; |
| + | |
| + | BEGIN { |
| + | use base qw(Exporter); |
| + | |
| + | our @EXPORT = ( |
| + | # variables |
| + | qw( |
| + | $HOSTIP |
| + | $HOST6IP |
| + | $HTTPUNIXPATH |
| + | $testnumcheck |
| + | $sshdid |
| + | $SSHSRVMD5 |
| + | $SSHSRVSHA256 |
| + | $SOCKSUNIXPATH |
| + | $SOCKSIN |
| + | $USER |
| + | $ftpchecktime |
| + | $err_unexpected |
| + | $debugprotocol |
| + | $stunnel |
| + | ), |
| + | |
| + | # functions |
| + | qw( |
| + | initserverconfig |
| + | checkcmd |
| + | clearlocks |
| + | protoport |
| + | serverfortest |
| + | stopserver |
| + | stopservers |
| + | ) |
| + | ); |
| + | } |
| + | |
| + | use serverhelp qw( |
| + | serverfactors |
| + | servername_id |
| + | servername_str |
| + | servername_canon |
| + | server_pidfilename |
| + | server_portfilename |
| + | server_logfilename |
| + | ); |
| + | |
| + | use sshhelp qw( |
| + | $hstpubmd5f |
| + | $hstpubsha256f |
| + | $sshexe |
| + | $sftpexe |
| + | $sftpconfig |
| + | $sshdlog |
| + | $sftplog |
| + | $sftpcmds |
| + | display_sshdconfig |
| + | display_sftpconfig |
| + | display_sshdlog |
| + | display_sftplog |
| + | find_sshd |
| + | find_ssh |
| + | find_sftp |
| + | find_httptlssrv |
| + | sshversioninfo |
| + | ); |
| + | |
| + | use pathhelp qw( |
| + | exe_ext |
| + | os_is_win |
| + | sys_native_abs_path |
| + | ); |
| + | |
| + | use processhelp; |
| + | use globalconfig; |
| + | |
| + | |
| + | my %serverpidfile; # all server pid file names, identified by server id |
| + | my %serverportfile;# all server port file names, identified by server id |
| + | my $sshdvernum; # for socks server, ssh daemon version number |
| + | my $sshdverstr; # for socks server, ssh daemon version string |
| + | my $sshderror; # for socks server, ssh daemon version error |
| + | my %doesntrun; # servers that don't work, identified by pidfile |
| + | my %PORT = (nolisten => 47); # port we use for a local non-listening service |
| + | my $server_response_maxtime=13; |
| + | my $httptlssrv = find_httptlssrv(); |
| + | my %run; # running server |
| + | my %runcert; # cert file currently in use by an ssl running server |
| + | |
| + | # Variables shared with runtests.pl |
| + | our $HOSTIP="127.0.0.1"; # address on which the test server listens |
| + | our $HOST6IP="[::1]"; # address on which the test server listens |
| + | our $HTTPUNIXPATH; # HTTP server Unix domain socket path |
| + | our $testnumcheck; # test number, set in singletest sub. |
| + | our $sshdid; # for socks server, ssh daemon version id |
| + | our $SSHSRVMD5 = "[uninitialized]"; # MD5 of ssh server public key |
| + | our $SSHSRVSHA256 = "[uninitialized]"; # SHA256 of ssh server public key |
| + | our $SOCKSUNIXPATH; # socks server Unix domain socket path |
| + | our $SOCKSIN; # what curl sent to the SOCKS proxy |
| + | our $USER; # name of the current user |
| + | our $ftpchecktime=1; # time it took to verify our test FTP server |
| + | our $err_unexpected; # error instead of warning on server unexpectedly alive |
| + | our $debugprotocol; # nonzero for verbose server logs |
| + | our $stunnel; # path to stunnel command |
| + | |
| + | ####################################################################### |
| + | # Log an informational message |
| + | # This just calls main's logmsg for now. |
| + | |
| + | sub logmsg { |
| + | return main::logmsg(@_); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Call main's runclient |
| + | # TODO: move this into a helper package |
| + | sub runclient { |
| + | return main::runclient(@_); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Call main's runclientoutput |
| + | # TODO: move this into a helper package |
| + | sub runclientoutput { |
| + | return main::runclientoutput(@_); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Check for a command in the PATH of the test server. |
| + | # |
| + | sub checkcmd { |
| + | my ($cmd, @extrapaths)=@_; |
| + | my @paths=(split(m/[:]/, $ENV{'PATH'}), "/usr/sbin", "/usr/local/sbin", |
| + | "/sbin", "/usr/bin", "/usr/local/bin", @extrapaths); |
| + | for(@paths) { |
| + | if( -x "$_/$cmd" && ! -d "$_/$cmd") { |
| + | # executable bit but not a directory! |
| + | return "$_/$cmd"; |
| + | } |
| + | } |
| + | return ""; |
| + | } |
| + | |
| + | |
| + | ####################################################################### |
| + | # Initialize configuration variables |
| + | sub initserverconfig { |
| + | $SOCKSIN="$LOGDIR/socksd-request.log"; # what curl sent to the SOCKS proxy |
| + | $SOCKSUNIXPATH = "$PIDDIR/socks.sock"; # SOCKS server Unix domain socket path |
| + | $HTTPUNIXPATH = "$PIDDIR/http.sock"; # HTTP server Unix domain socket path |
| + | $stunnel = checkcmd("stunnel4") || checkcmd("tstunnel") || checkcmd("stunnel"); |
| + | |
| + | # get the name of the current user |
| + | $USER = $ENV{USER}; # Linux |
| + | if (!$USER) { |
| + | $USER = $ENV{USERNAME}; # Windows |
| + | if (!$USER) { |
| + | $USER = $ENV{LOGNAME}; # Some Unix (I think) |
| + | } |
| + | } |
| + | init_serverpidfile_hash(); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Call main's displaylogs |
| + | # TODO: instead, make the caller call displaylogs() in case of error |
| + | sub displaylogs { |
| + | return main::displaylogs(@_); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Load serverpidfile and serverportfile hashes with file names for all |
| + | # possible servers. |
| + | # |
| + | sub init_serverpidfile_hash { |
| + | for my $proto (('ftp', 'gopher', 'http', 'imap', 'pop3', 'smtp', 'http/2', 'http/3')) { |
| + | for my $ssl (('', 's')) { |
| + | for my $ipvnum ((4, 6)) { |
| + | for my $idnum ((1, 2, 3)) { |
| + | my $serv = servername_id("$proto$ssl", $ipvnum, $idnum); |
| + | my $pidf = server_pidfilename($PIDDIR, "$proto$ssl", $ipvnum, $idnum); |
| + | $serverpidfile{$serv} = $pidf; |
| + | my $portf = server_portfilename($PIDDIR, "$proto$ssl", $ipvnum, $idnum); |
| + | $serverportfile{$serv} = $portf; |
| + | } |
| + | } |
| + | } |
| + | } |
| + | for my $proto (('tftp', 'sftp', 'socks', 'ssh', 'rtsp', 'httptls', |
| + | 'dict', 'smb', 'smbs', 'telnet', 'mqtt')) { |
| + | for my $ipvnum ((4, 6)) { |
| + | for my $idnum ((1, 2)) { |
| + | my $serv = servername_id($proto, $ipvnum, $idnum); |
| + | my $pidf = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum); |
| + | $serverpidfile{$serv} = $pidf; |
| + | my $portf = server_portfilename($PIDDIR, $proto, $ipvnum, $idnum); |
| + | $serverportfile{$serv} = $portf; |
| + | } |
| + | } |
| + | } |
| + | for my $proto (('http', 'imap', 'pop3', 'smtp', 'http/2', 'http/3')) { |
| + | for my $ssl (('', 's')) { |
| + | my $serv = servername_id("$proto$ssl", "unix", 1); |
| + | my $pidf = server_pidfilename($PIDDIR, "$proto$ssl", "unix", 1); |
| + | $serverpidfile{$serv} = $pidf; |
| + | my $portf = server_portfilename($PIDDIR, "$proto$ssl", "unix", 1); |
| + | $serverportfile{$serv} = $portf; |
| + | } |
| + | } |
| + | } |
| + | |
| + | |
| + | ####################################################################### |
| + | # Kill the processes that still have lock files in a directory |
| + | # |
| + | sub clearlocks { |
| + | my $dir = $_[0]; |
| + | my $done = 0; |
| + | |
| + | if(os_is_win()) { |
| + | $dir = sys_native_abs_path($dir); |
| + | $dir =~ s/\//\\\\/g; |
| + | my $handle = "handle.exe"; |
| + | if($ENV{"PROCESSOR_ARCHITECTURE"} =~ /64$/) { |
| + | $handle = "handle64.exe"; |
| + | } |
| + | my @handles = `$handle $dir -accepteula -nobanner`; |
| + | for my $tryhandle (@handles) { |
| + | if($tryhandle =~ /^(\S+)\s+pid:\s+(\d+)\s+type:\s+(\w+)\s+([0-9A-F]+):\s+(.+)\r\r/) { |
| + | logmsg "Found $3 lock of '$5' ($4) by $1 ($2)\n"; |
| + | # Ignore stunnel since we cannot do anything about its locks |
| + | if("$3" eq "File" && "$1" ne "tstunnel.exe") { |
| + | logmsg "Killing IMAGENAME eq $1 and PID eq $2\n"; |
| + | system("taskkill.exe -f -fi \"IMAGENAME eq $1\" -fi \"PID eq $2\" >nul 2>&1"); |
| + | $done = 1; |
| + | } |
| + | } |
| + | } |
| + | } |
| + | return $done; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Check if a given child process has just died. Reaps it if so. |
| + | # |
| + | sub checkdied { |
| + | my $pid = $_[0]; |
| + | if((not defined $pid) || $pid <= 0) { |
| + | return 0; |
| + | } |
| + | use POSIX ":sys_wait_h"; |
| + | my $rc = pidwait($pid, &WNOHANG); |
| + | return ($rc == $pid)?1:0; |
| + | } |
| + | |
| + | |
| + | ############################################################################## |
| + | # This function makes sure the right set of server is running for the |
| + | # specified test case. This is a useful design when we run single tests as not |
| + | # all servers need to run then! |
| + | # |
| + | # Returns: a string, blank if everything is fine or a reason why it failed |
| + | # |
| + | sub serverfortest { |
| + | my (@what)=@_; |
| + | |
| + | for(my $i = scalar(@what) - 1; $i >= 0; $i--) { |
| + | my $srvrline = $what[$i]; |
| + | chomp $srvrline if($srvrline); |
| + | if($srvrline =~ /^(\S+)((\s*)(.*))/) { |
| + | my $server = "${1}"; |
| + | my $lnrest = "${2}"; |
| + | my $tlsext; |
| + | if($server =~ /^(httptls)(\+)(ext|srp)(\d*)(-ipv6|)$/) { |
| + | $server = "${1}${4}${5}"; |
| + | $tlsext = uc("TLS-${3}"); |
| + | } |
| + | if(! grep /^\Q$server\E$/, @protocols) { |
| + | if(substr($server,0,5) ne "socks") { |
| + | if($tlsext) { |
| + | return "curl lacks $tlsext support"; |
| + | } |
| + | else { |
| + | return "curl lacks $server server support"; |
| + | } |
| + | } |
| + | } |
| + | $what[$i] = "$server$lnrest" if($tlsext); |
| + | } |
| + | } |
| + | |
| + | return &startservers(@what); |
| + | } |
| + | |
| + | |
| + | ####################################################################### |
| + | # Start a new thread/process and run the given command line in there. |
| + | # Return the pids (yes plural) of the new child process to the parent. |
| + | # |
| + | sub startnew { |
| + | my ($cmd, $pidfile, $timeout, $fakepidfile)=@_; |
| + | |
| + | logmsg "startnew: $cmd\n" if ($verbose); |
| + | |
| + | my $child = fork(); |
| + | |
| + | if(not defined $child) { |
| + | logmsg "startnew: fork() failure detected\n"; |
| + | return (-1,-1); |
| + | } |
| + | |
| + | if(0 == $child) { |
| + | # Here we are the child. Run the given command. |
| + | |
| + | # Flush output. |
| + | $| = 1; |
| + | |
| + | # Put an "exec" in front of the command so that the child process |
| + | # keeps this child's process ID. |
| + | exec("exec $cmd") || die "Can't exec() $cmd: $!"; |
| + | |
| + | # exec() should never return back here to this process. We protect |
| + | # ourselves by calling die() just in case something goes really bad. |
| + | die "error: exec() has returned"; |
| + | } |
| + | |
| + | # Ugly hack but ssh client and gnutls-serv don't support pid files |
| + | if ($fakepidfile) { |
| + | if(open(my $out, ">", "$pidfile")) { |
| + | print $out $child . "\n"; |
| + | close($out) || die "Failure writing pidfile"; |
| + | logmsg "startnew: $pidfile faked with pid=$child\n" if($verbose); |
| + | } |
| + | else { |
| + | logmsg "startnew: failed to write fake $pidfile with pid=$child\n"; |
| + | } |
| + | # could/should do a while connect fails sleep a bit and loop |
| + | portable_sleep($timeout); |
| + | if (checkdied($child)) { |
| + | logmsg "startnew: child process has failed to start\n" if($verbose); |
| + | return (-1,-1); |
| + | } |
| + | } |
| + | |
| + | my $pid2 = 0; |
| + | my $count = $timeout; |
| + | while($count--) { |
| + | $pid2 = pidfromfile($pidfile); |
| + | if(($pid2 > 0) && pidexists($pid2)) { |
| + | # if $pid2 is valid, then make sure this pid is alive, as |
| + | # otherwise it is just likely to be the _previous_ pidfile or |
| + | # similar! |
| + | last; |
| + | } |
| + | if (checkdied($child)) { |
| + | logmsg "startnew: child process has died, server might start up\n" |
| + | if($verbose); |
| + | # We can't just abort waiting for the server with a |
| + | # return (-1,-1); |
| + | # because the server might have forked and could still start |
| + | # up normally. Instead, just reduce the amount of time we remain |
| + | # waiting. |
| + | $count >>= 2; |
| + | } |
| + | sleep(1); |
| + | } |
| + | |
| + | # Return two PIDs, the one for the child process we spawned and the one |
| + | # reported by the server itself (in case it forked again on its own). |
| + | # Both (potentially) need to be killed at the end of the test. |
| + | return ($child, $pid2); |
| + | } |
| + | |
| + | |
| + | ####################################################################### |
| + | # Return the port to use for the given protocol. |
| + | # |
| + | sub protoport { |
| + | my ($proto) = @_; |
| + | return $PORT{$proto} || "[not running]"; |
| + | } |
| + | |
| + | |
| + | ####################################################################### |
| + | # Stop a test server along with pids which aren't in the %run hash yet. |
| + | # This also stops all servers which are relative to the given one. |
| + | # |
| + | sub stopserver { |
| + | my ($server, $pidlist) = @_; |
| + | |
| + | # |
| + | # kill sockfilter processes for pingpong relative server |
| + | # |
| + | if($server =~ /^(ftp|imap|pop3|smtp)s?(\d*)(-ipv6|)$/) { |
| + | my $proto = $1; |
| + | my $idnum = ($2 && ($2 > 1)) ? $2 : 1; |
| + | my $ipvnum = ($3 && ($3 =~ /6$/)) ? 6 : 4; |
| + | killsockfilters($PIDDIR, $proto, $ipvnum, $idnum, $verbose); |
| + | } |
| + | # |
| + | # All servers relative to the given one must be stopped also |
| + | # |
| + | my @killservers; |
| + | if($server =~ /^(ftp|http|imap|pop3|smtp)s((\d*)(-ipv6|-unix|))$/) { |
| + | # given a stunnel based ssl server, also kill non-ssl underlying one |
| + | push @killservers, "${1}${2}"; |
| + | } |
| + | elsif($server =~ /^(ftp|http|imap|pop3|smtp)((\d*)(-ipv6|-unix|))$/) { |
| + | # given a non-ssl server, also kill stunnel based ssl piggybacking one |
| + | push @killservers, "${1}s${2}"; |
| + | } |
| + | elsif($server =~ /^(socks)((\d*)(-ipv6|))$/) { |
| + | # given a socks server, also kill ssh underlying one |
| + | push @killservers, "ssh${2}"; |
| + | } |
| + | elsif($server =~ /^(ssh)((\d*)(-ipv6|))$/) { |
| + | # given a ssh server, also kill socks piggybacking one |
| + | push @killservers, "socks${2}"; |
| + | } |
| + | if($server eq "http" or $server eq "https") { |
| + | # since the http2+3 server is a proxy that needs to know about the |
| + | # dynamic http port it too needs to get restarted when the http server |
| + | # is killed |
| + | push @killservers, "http/2"; |
| + | push @killservers, "http/3"; |
| + | } |
| + | push @killservers, $server; |
| + | # |
| + | # kill given pids and server relative ones clearing them in %run hash |
| + | # |
| + | foreach my $server (@killservers) { |
| + | if($run{$server}) { |
| + | # we must prepend a space since $pidlist may already contain a pid |
| + | $pidlist .= " $run{$server}"; |
| + | $run{$server} = 0; |
| + | } |
| + | $runcert{$server} = 0 if($runcert{$server}); |
| + | } |
| + | killpid($verbose, $pidlist); |
| + | # |
| + | # cleanup server pid files |
| + | # |
| + | my $result = 0; |
| + | foreach my $server (@killservers) { |
| + | my $pidfile = $serverpidfile{$server}; |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | if($err_unexpected) { |
| + | logmsg "ERROR: "; |
| + | $result = -1; |
| + | } |
| + | else { |
| + | logmsg "Warning: "; |
| + | } |
| + | logmsg "$server server unexpectedly alive\n"; |
| + | killpid($verbose, $pid); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | } |
| + | |
| + | return $result; |
| + | } |
| + | |
| + | |
| + | ####################################################################### |
| + | # Return flags to let curl use an external HTTP proxy |
| + | # |
| + | sub getexternalproxyflags { |
| + | return " --proxy $proxy_address "; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Verify that the server that runs on $ip, $port is our server. This also |
| + | # implies that we can speak with it, as there might be occasions when the |
| + | # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't |
| + | # assign requested address") |
| + | # |
| + | sub verifyhttp { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port_or_path) = @_; |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | my $bonus=""; |
| + | # $port_or_path contains a path for Unix sockets, sws ignores the port |
| + | my $port = ($ipvnum eq "unix") ? 80 : $port_or_path; |
| + | |
| + | my $verifyout = "$LOGDIR/". |
| + | servername_canon($proto, $ipvnum, $idnum) .'_verify.out'; |
| + | unlink($verifyout) if(-f $verifyout); |
| + | |
| + | my $verifylog = "$LOGDIR/". |
| + | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| + | unlink($verifylog) if(-f $verifylog); |
| + | |
| + | if($proto eq "gopher") { |
| + | # gopher is funny |
| + | $bonus="1/"; |
| + | } |
| + | |
| + | my $flags = "--max-time $server_response_maxtime "; |
| + | $flags .= "--output $verifyout "; |
| + | $flags .= "--silent "; |
| + | $flags .= "--verbose "; |
| + | $flags .= "--globoff "; |
| + | $flags .= "--unix-socket '$port_or_path' " if $ipvnum eq "unix"; |
| + | $flags .= "--insecure " if($proto eq 'https'); |
| + | if($proxy_address) { |
| + | $flags .= getexternalproxyflags(); |
| + | } |
| + | $flags .= "\"$proto://$ip:$port/${bonus}verifiedserver\""; |
| + | |
| + | my $cmd = "$VCURL $flags 2>$verifylog"; |
| + | |
| + | # verify if our/any server is running on this port |
| + | logmsg "RUN: $cmd\n" if($verbose); |
| + | my $res = runclient($cmd); |
| + | |
| + | $res >>= 8; # rotate the result |
| + | if($res & 128) { |
| + | logmsg "RUN: curl command died with a coredump\n"; |
| + | return -1; |
| + | } |
| + | |
| + | if($res && $verbose) { |
| + | logmsg "RUN: curl command returned $res\n"; |
| + | if(open(my $file, "<", "$verifylog")) { |
| + | while(my $string = <$file>) { |
| + | logmsg "RUN: $string" if($string !~ /^([ \t]*)$/); |
| + | } |
| + | close($file); |
| + | } |
| + | } |
| + | |
| + | my $data; |
| + | if(open(my $file, "<", "$verifyout")) { |
| + | while(my $string = <$file>) { |
| + | $data = $string; |
| + | last; # only want first line |
| + | } |
| + | close($file); |
| + | } |
| + | |
| + | my $pid = 0; |
| + | if($data && ($data =~ /WE ROOLZ: (\d+)/)) { |
| + | $pid = 0+$1; |
| + | } |
| + | elsif($res == 6) { |
| + | # curl: (6) Couldn't resolve host '::1' |
| + | logmsg "RUN: failed to resolve host ($proto://$ip:$port/verifiedserver)\n"; |
| + | return -1; |
| + | } |
| + | elsif($data || ($res && ($res != 7))) { |
| + | logmsg "RUN: Unknown server on our $server port: $port ($res)\n"; |
| + | return -1; |
| + | } |
| + | return $pid; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Verify that the server that runs on $ip, $port is our server. This also |
| + | # implies that we can speak with it, as there might be occasions when the |
| + | # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't |
| + | # assign requested address") |
| + | # |
| + | sub verifyftp { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | my $time=time(); |
| + | my $extra=""; |
| + | |
| + | my $verifylog = "$LOGDIR/". |
| + | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| + | unlink($verifylog) if(-f $verifylog); |
| + | |
| + | if($proto eq "ftps") { |
| + | $extra .= "--insecure --ftp-ssl-control "; |
| + | } |
| + | |
| + | my $flags = "--max-time $server_response_maxtime "; |
| + | $flags .= "--silent "; |
| + | $flags .= "--verbose "; |
| + | $flags .= "--globoff "; |
| + | $flags .= $extra; |
| + | if($proxy_address) { |
| + | $flags .= getexternalproxyflags(); |
| + | } |
| + | $flags .= "\"$proto://$ip:$port/verifiedserver\""; |
| + | |
| + | my $cmd = "$VCURL $flags 2>$verifylog"; |
| + | |
| + | # check if this is our server running on this port: |
| + | logmsg "RUN: $cmd\n" if($verbose); |
| + | my @data = runclientoutput($cmd); |
| + | |
| + | my $res = $? >> 8; # rotate the result |
| + | if($res & 128) { |
| + | logmsg "RUN: curl command died with a coredump\n"; |
| + | return -1; |
| + | } |
| + | |
| + | my $pid = 0; |
| + | foreach my $line (@data) { |
| + | if($line =~ /WE ROOLZ: (\d+)/) { |
| + | # this is our test server with a known pid! |
| + | $pid = 0+$1; |
| + | last; |
| + | } |
| + | } |
| + | if($pid <= 0 && @data && $data[0]) { |
| + | # this is not a known server |
| + | logmsg "RUN: Unknown server on our $server port: $port\n"; |
| + | return 0; |
| + | } |
| + | # we can/should use the time it took to verify the FTP server as a measure |
| + | # on how fast/slow this host/FTP is. |
| + | my $took = int(0.5+time()-$time); |
| + | |
| + | if($verbose) { |
| + | logmsg "RUN: Verifying our test $server server took $took seconds\n"; |
| + | } |
| + | $ftpchecktime = $took>=1?$took:1; # make sure it never is below 1 |
| + | |
| + | return $pid; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Verify that the server that runs on $ip, $port is our server. This also |
| + | # implies that we can speak with it, as there might be occasions when the |
| + | # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't |
| + | # assign requested address") |
| + | # |
| + | sub verifyrtsp { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $verifyout = "$LOGDIR/". |
| + | servername_canon($proto, $ipvnum, $idnum) .'_verify.out'; |
| + | unlink($verifyout) if(-f $verifyout); |
| + | |
| + | my $verifylog = "$LOGDIR/". |
| + | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| + | unlink($verifylog) if(-f $verifylog); |
| + | |
| + | my $flags = "--max-time $server_response_maxtime "; |
| + | $flags .= "--output $verifyout "; |
| + | $flags .= "--silent "; |
| + | $flags .= "--verbose "; |
| + | $flags .= "--globoff "; |
| + | if($proxy_address) { |
| + | $flags .= getexternalproxyflags(); |
| + | } |
| + | # currently verification is done using http |
| + | $flags .= "\"http://$ip:$port/verifiedserver\""; |
| + | |
| + | my $cmd = "$VCURL $flags 2>$verifylog"; |
| + | |
| + | # verify if our/any server is running on this port |
| + | logmsg "RUN: $cmd\n" if($verbose); |
| + | my $res = runclient($cmd); |
| + | |
| + | $res >>= 8; # rotate the result |
| + | if($res & 128) { |
| + | logmsg "RUN: curl command died with a coredump\n"; |
| + | return -1; |
| + | } |
| + | |
| + | if($res && $verbose) { |
| + | logmsg "RUN: curl command returned $res\n"; |
| + | if(open(my $file, "<", "$verifylog")) { |
| + | while(my $string = <$file>) { |
| + | logmsg "RUN: $string" if($string !~ /^[ \t]*$/); |
| + | } |
| + | close($file); |
| + | } |
| + | } |
| + | |
| + | my $data; |
| + | if(open(my $file, "<", "$verifyout")) { |
| + | while(my $string = <$file>) { |
| + | $data = $string; |
| + | last; # only want first line |
| + | } |
| + | close($file); |
| + | } |
| + | |
| + | my $pid = 0; |
| + | if($data && ($data =~ /RTSP_SERVER WE ROOLZ: (\d+)/)) { |
| + | $pid = 0+$1; |
| + | } |
| + | elsif($res == 6) { |
| + | # curl: (6) Couldn't resolve host '::1' |
| + | logmsg "RUN: failed to resolve host ($proto://$ip:$port/verifiedserver)\n"; |
| + | return -1; |
| + | } |
| + | elsif($data || ($res != 7)) { |
| + | logmsg "RUN: Unknown server on our $server port: $port\n"; |
| + | return -1; |
| + | } |
| + | return $pid; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Verify that the ssh server has written out its pidfile, recovering |
| + | # the pid from the file and returning it if a process with that pid is |
| + | # actually alive, or a negative value if the process is dead. |
| + | # |
| + | sub verifyssh { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| + | my $pidfile = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum); |
| + | my $pid = processexists($pidfile); |
| + | if($pid < 0) { |
| + | logmsg "RUN: SSH server has died after starting up\n"; |
| + | } |
| + | return $pid; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Verify that we can connect to the sftp server, properly authenticate |
| + | # with generated config and key files and run a simple remote pwd. |
| + | # |
| + | sub verifysftp { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | my $verified = 0; |
| + | # Find out sftp client canonical file name |
| + | my $sftp = find_sftp(); |
| + | if(!$sftp) { |
| + | logmsg "RUN: SFTP server cannot find $sftpexe\n"; |
| + | return -1; |
| + | } |
| + | # Find out ssh client canonical file name |
| + | my $ssh = find_ssh(); |
| + | if(!$ssh) { |
| + | logmsg "RUN: SFTP server cannot find $sshexe\n"; |
| + | return -1; |
| + | } |
| + | # Connect to sftp server, authenticate and run a remote pwd |
| + | # command using our generated configuration and key files |
| + | my $cmd = "\"$sftp\" -b $PIDDIR/$sftpcmds -F $PIDDIR/$sftpconfig -S \"$ssh\" $ip > $sftplog 2>&1"; |
| + | my $res = runclient($cmd); |
| + | # Search for pwd command response in log file |
| + | if(open(my $sftplogfile, "<", "$sftplog")) { |
| + | while(<$sftplogfile>) { |
| + | if(/^Remote working directory: /) { |
| + | $verified = 1; |
| + | last; |
| + | } |
| + | } |
| + | close($sftplogfile); |
| + | } |
| + | return $verified; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Verify that the non-stunnel HTTP TLS extensions capable server that runs |
| + | # on $ip, $port is our server. This also implies that we can speak with it, |
| + | # as there might be occasions when the server runs fine but we cannot talk |
| + | # to it ("Failed to connect to ::1: Can't assign requested address") |
| + | # |
| + | sub verifyhttptls { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | my $pidfile = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $verifyout = "$LOGDIR/". |
| + | servername_canon($proto, $ipvnum, $idnum) .'_verify.out'; |
| + | unlink($verifyout) if(-f $verifyout); |
| + | |
| + | my $verifylog = "$LOGDIR/". |
| + | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| + | unlink($verifylog) if(-f $verifylog); |
| + | |
| + | my $flags = "--max-time $server_response_maxtime "; |
| + | $flags .= "--output $verifyout "; |
| + | $flags .= "--verbose "; |
| + | $flags .= "--globoff "; |
| + | $flags .= "--insecure "; |
| + | $flags .= "--tlsauthtype SRP "; |
| + | $flags .= "--tlsuser jsmith "; |
| + | $flags .= "--tlspassword abc "; |
| + | if($proxy_address) { |
| + | $flags .= getexternalproxyflags(); |
| + | } |
| + | $flags .= "\"https://$ip:$port/verifiedserver\""; |
| + | |
| + | my $cmd = "$VCURL $flags 2>$verifylog"; |
| + | |
| + | # verify if our/any server is running on this port |
| + | logmsg "RUN: $cmd\n" if($verbose); |
| + | my $res = runclient($cmd); |
| + | |
| + | $res >>= 8; # rotate the result |
| + | if($res & 128) { |
| + | logmsg "RUN: curl command died with a coredump\n"; |
| + | return -1; |
| + | } |
| + | |
| + | if($res && $verbose) { |
| + | logmsg "RUN: curl command returned $res\n"; |
| + | if(open(my $file, "<", "$verifylog")) { |
| + | while(my $string = <$file>) { |
| + | logmsg "RUN: $string" if($string !~ /^([ \t]*)$/); |
| + | } |
| + | close($file); |
| + | } |
| + | } |
| + | |
| + | my $data; |
| + | if(open(my $file, "<", "$verifyout")) { |
| + | while(my $string = <$file>) { |
| + | $data .= $string; |
| + | } |
| + | close($file); |
| + | } |
| + | |
| + | my $pid = 0; |
| + | if($data && ($data =~ /(GNUTLS|GnuTLS)/) && ($pid = processexists($pidfile))) { |
| + | if($pid < 0) { |
| + | logmsg "RUN: $server server has died after starting up\n"; |
| + | } |
| + | return $pid; |
| + | } |
| + | elsif($res == 6) { |
| + | # curl: (6) Couldn't resolve host '::1' |
| + | logmsg "RUN: failed to resolve host (https://$ip:$port/verifiedserver)\n"; |
| + | return -1; |
| + | } |
| + | elsif($data || ($res && ($res != 7))) { |
| + | logmsg "RUN: Unknown server on our $server port: $port ($res)\n"; |
| + | return -1; |
| + | } |
| + | return $pid; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # STUB for verifying socks |
| + | # |
| + | sub verifysocks { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| + | my $pidfile = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum); |
| + | my $pid = processexists($pidfile); |
| + | if($pid < 0) { |
| + | logmsg "RUN: SOCKS server has died after starting up\n"; |
| + | } |
| + | return $pid; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Verify that the server that runs on $ip, $port is our server. This also |
| + | # implies that we can speak with it, as there might be occasions when the |
| + | # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't |
| + | # assign requested address") |
| + | # |
| + | sub verifysmb { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | my $time=time(); |
| + | my $extra=""; |
| + | |
| + | my $verifylog = "$LOGDIR/". |
| + | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| + | unlink($verifylog) if(-f $verifylog); |
| + | |
| + | my $flags = "--max-time $server_response_maxtime "; |
| + | $flags .= "--silent "; |
| + | $flags .= "--verbose "; |
| + | $flags .= "--globoff "; |
| + | $flags .= "-u 'curltest:curltest' "; |
| + | $flags .= $extra; |
| + | $flags .= "\"$proto://$ip:$port/SERVER/verifiedserver\""; |
| + | |
| + | my $cmd = "$VCURL $flags 2>$verifylog"; |
| + | |
| + | # check if this is our server running on this port: |
| + | logmsg "RUN: $cmd\n" if($verbose); |
| + | my @data = runclientoutput($cmd); |
| + | |
| + | my $res = $? >> 8; # rotate the result |
| + | if($res & 128) { |
| + | logmsg "RUN: curl command died with a coredump\n"; |
| + | return -1; |
| + | } |
| + | |
| + | my $pid = 0; |
| + | foreach my $line (@data) { |
| + | if($line =~ /WE ROOLZ: (\d+)/) { |
| + | # this is our test server with a known pid! |
| + | $pid = 0+$1; |
| + | last; |
| + | } |
| + | } |
| + | if($pid <= 0 && @data && $data[0]) { |
| + | # this is not a known server |
| + | logmsg "RUN: Unknown server on our $server port: $port\n"; |
| + | return 0; |
| + | } |
| + | # we can/should use the time it took to verify the server as a measure |
| + | # on how fast/slow this host is. |
| + | my $took = int(0.5+time()-$time); |
| + | |
| + | if($verbose) { |
| + | logmsg "RUN: Verifying our test $server server took $took seconds\n"; |
| + | } |
| + | $ftpchecktime = $took>=1?$took:1; # make sure it never is below 1 |
| + | |
| + | return $pid; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Verify that the server that runs on $ip, $port is our server. This also |
| + | # implies that we can speak with it, as there might be occasions when the |
| + | # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't |
| + | # assign requested address") |
| + | # |
| + | sub verifytelnet { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | my $time=time(); |
| + | my $extra=""; |
| + | |
| + | my $verifylog = "$LOGDIR/". |
| + | servername_canon($proto, $ipvnum, $idnum) .'_verify.log'; |
| + | unlink($verifylog) if(-f $verifylog); |
| + | |
| + | my $flags = "--max-time $server_response_maxtime "; |
| + | $flags .= "--silent "; |
| + | $flags .= "--verbose "; |
| + | $flags .= "--globoff "; |
| + | $flags .= "--upload-file - "; |
| + | $flags .= $extra; |
| + | $flags .= "\"$proto://$ip:$port\""; |
| + | |
| + | my $cmd = "echo 'verifiedserver' | $VCURL $flags 2>$verifylog"; |
| + | |
| + | # check if this is our server running on this port: |
| + | logmsg "RUN: $cmd\n" if($verbose); |
| + | my @data = runclientoutput($cmd); |
| + | |
| + | my $res = $? >> 8; # rotate the result |
| + | if($res & 128) { |
| + | logmsg "RUN: curl command died with a coredump\n"; |
| + | return -1; |
| + | } |
| + | |
| + | my $pid = 0; |
| + | foreach my $line (@data) { |
| + | if($line =~ /WE ROOLZ: (\d+)/) { |
| + | # this is our test server with a known pid! |
| + | $pid = 0+$1; |
| + | last; |
| + | } |
| + | } |
| + | if($pid <= 0 && @data && $data[0]) { |
| + | # this is not a known server |
| + | logmsg "RUN: Unknown server on our $server port: $port\n"; |
| + | return 0; |
| + | } |
| + | # we can/should use the time it took to verify the server as a measure |
| + | # on how fast/slow this host is. |
| + | my $took = int(0.5+time()-$time); |
| + | |
| + | if($verbose) { |
| + | logmsg "RUN: Verifying our test $server server took $took seconds\n"; |
| + | } |
| + | |
| + | return $pid; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Verify that the server that runs on $ip, $port is our server. |
| + | # Retry over several seconds before giving up. The ssh server in |
| + | # particular can take a long time to start if it needs to generate |
| + | # keys on a slow or loaded host. |
| + | # |
| + | # Just for convenience, test harness uses 'https' and 'httptls' literals |
| + | # as values for 'proto' variable in order to differentiate different |
| + | # servers. 'https' literal is used for stunnel based https test servers, |
| + | # and 'httptls' is used for non-stunnel https test servers. |
| + | # |
| + | |
| + | my %protofunc = ('http' => \&verifyhttp, |
| + | 'https' => \&verifyhttp, |
| + | 'rtsp' => \&verifyrtsp, |
| + | 'ftp' => \&verifyftp, |
| + | 'pop3' => \&verifyftp, |
| + | 'imap' => \&verifyftp, |
| + | 'smtp' => \&verifyftp, |
| + | 'ftps' => \&verifyftp, |
| + | 'pop3s' => \&verifyftp, |
| + | 'imaps' => \&verifyftp, |
| + | 'smtps' => \&verifyftp, |
| + | 'tftp' => \&verifyftp, |
| + | 'ssh' => \&verifyssh, |
| + | 'socks' => \&verifysocks, |
| + | 'socks5unix' => \&verifysocks, |
| + | 'gopher' => \&verifyhttp, |
| + | 'httptls' => \&verifyhttptls, |
| + | 'dict' => \&verifyftp, |
| + | 'smb' => \&verifysmb, |
| + | 'telnet' => \&verifytelnet); |
| + | |
| + | sub verifyserver { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| + | |
| + | my $count = 30; # try for this many seconds |
| + | my $pid; |
| + | |
| + | while($count--) { |
| + | my $fun = $protofunc{$proto}; |
| + | |
| + | $pid = &$fun($proto, $ipvnum, $idnum, $ip, $port); |
| + | |
| + | if($pid > 0) { |
| + | last; |
| + | } |
| + | elsif($pid < 0) { |
| + | # a real failure, stop trying and bail out |
| + | return 0; |
| + | } |
| + | sleep(1); |
| + | } |
| + | return $pid; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Single shot server responsiveness test. This should only be used |
| + | # to verify that a server present in %run hash is still functional |
| + | # |
| + | sub responsiveserver { |
| + | my ($proto, $ipvnum, $idnum, $ip, $port) = @_; |
| + | my $prev_verbose = $verbose; |
| + | |
| + | $verbose = 0; |
| + | my $fun = $protofunc{$proto}; |
| + | my $pid = &$fun($proto, $ipvnum, $idnum, $ip, $port); |
| + | $verbose = $prev_verbose; |
| + | |
| + | if($pid > 0) { |
| + | return 1; # responsive |
| + | } |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | logmsg " server precheck FAILED (unresponsive $srvrname server)\n"; |
| + | return 0; |
| + | } |
| + | |
| + | |
| + | ####################################################################### |
| + | # start the http server |
| + | # |
| + | sub runhttpserver { |
| + | my ($proto, $verb, $alt, $port_or_path) = @_; |
| + | my $ip = $HOSTIP; |
| + | my $ipvnum = 4; |
| + | my $idnum = 1; |
| + | my $exe = "$perl $srcdir/http-server.pl"; |
| + | my $verbose_flag = "--verbose "; |
| + | my $keepalive_secs = 30; # forwarded to sws, was 5 by default which |
| + | # led to pukes in CI jobs |
| + | |
| + | if($alt eq "ipv6") { |
| + | # if IPv6, use a different setup |
| + | $ipvnum = 6; |
| + | $ip = $HOST6IP; |
| + | } |
| + | elsif($alt eq "proxy") { |
| + | # basically the same, but another ID |
| + | $idnum = 2; |
| + | } |
| + | elsif($alt eq "unix") { |
| + | # IP (protocol) is mutually exclusive with Unix sockets |
| + | $ipvnum = "unix"; |
| + | } |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $portfile = $serverportfile{$server}; |
| + | |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--gopher " if($proto eq "gopher"); |
| + | $flags .= "--connect $HOSTIP " if($alt eq "proxy"); |
| + | $flags .= "--keepalive $keepalive_secs "; |
| + | $flags .= $verbose_flag if($debugprotocol); |
| + | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| + | $flags .= "--logdir \"$LOGDIR\" "; |
| + | $flags .= "--portfile $portfile "; |
| + | $flags .= "--config $FTPDCMD "; |
| + | $flags .= "--id $idnum " if($idnum > 1); |
| + | if($ipvnum eq "unix") { |
| + | $flags .= "--unix-socket '$port_or_path' "; |
| + | } else { |
| + | $flags .= "--ipv$ipvnum --port 0 "; |
| + | } |
| + | $flags .= "--srcdir \"$srcdir\""; |
| + | |
| + | my $cmd = "$exe $flags"; |
| + | my ($httppid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($httppid <= 0 || !pidexists($httppid)) { |
| + | # it is NOT alive |
| + | logmsg "RUN: failed to start the $srvrname server\n"; |
| + | stopserver($server, "$pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | # where is it? |
| + | my $port = 0; |
| + | if(!$port_or_path) { |
| + | $port = $port_or_path = pidfromfile($portfile); |
| + | } |
| + | |
| + | # Server is up. Verify that we can speak to it. |
| + | my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port_or_path); |
| + | if(!$pid3) { |
| + | logmsg "RUN: $srvrname server failed verification\n"; |
| + | # failed to talk to it properly. Kill the server and return failure |
| + | stopserver($server, "$httppid $pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | return (0, 0, 0); |
| + | } |
| + | $pid2 = $pid3; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server is on PID $httppid port $port_or_path\n"; |
| + | } |
| + | |
| + | return ($httppid, $pid2, $port); |
| + | } |
| + | |
| + | |
| + | ####################################################################### |
| + | # start the http2 server |
| + | # |
| + | sub runhttp2server { |
| + | my ($verb) = @_; |
| + | my $proto="http/2"; |
| + | my $ipvnum = 4; |
| + | my $idnum = 0; |
| + | my $exe = "$perl $srcdir/http2-server.pl"; |
| + | my $verbose_flag = "--verbose "; |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--nghttpx \"$ENV{'NGHTTPX'}\" "; |
| + | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| + | $flags .= "--logdir \"$LOGDIR\" "; |
| + | $flags .= "--connect $HOSTIP:" . protoport("http") . " "; |
| + | $flags .= $verbose_flag if($debugprotocol); |
| + | |
| + | my ($http2pid, $pid2); |
| + | my $port = 23113; |
| + | my $port2 = 23114; |
| + | for(1 .. 10) { |
| + | $port += int(rand(900)); |
| + | $port2 += int(rand(900)); |
| + | my $aflags = "--port $port --port2 $port2 $flags"; |
| + | |
| + | my $cmd = "$exe $aflags"; |
| + | ($http2pid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($http2pid <= 0 || !pidexists($http2pid)) { |
| + | # it is NOT alive |
| + | stopserver($server, "$pid2"); |
| + | $doesntrun{$pidfile} = 1; |
| + | $http2pid = $pid2 = 0; |
| + | next; |
| + | } |
| + | $doesntrun{$pidfile} = 0; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server PID $http2pid ". |
| + | "http-port $port https-port $port2 ". |
| + | "backend $HOSTIP:" . protoport("http") . "\n"; |
| + | } |
| + | last; |
| + | } |
| + | |
| + | logmsg "RUN: failed to start the $srvrname server\n" if(!$http2pid); |
| + | |
| + | return ($http2pid, $pid2, $port, $port2); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # start the http3 server |
| + | # |
| + | sub runhttp3server { |
| + | my ($verb, $cert) = @_; |
| + | my $proto="http/3"; |
| + | my $ipvnum = 4; |
| + | my $idnum = 0; |
| + | my $exe = "$perl $srcdir/http3-server.pl"; |
| + | my $verbose_flag = "--verbose "; |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--nghttpx \"$ENV{'NGHTTPX'}\" "; |
| + | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| + | $flags .= "--logdir \"$LOGDIR\" "; |
| + | $flags .= "--connect $HOSTIP:" . protoport("http") . " "; |
| + | $flags .= "--cert \"$cert\" " if($cert); |
| + | $flags .= $verbose_flag if($debugprotocol); |
| + | |
| + | my ($http3pid, $pid3); |
| + | my $port = 24113; |
| + | for(1 .. 10) { |
| + | $port += int(rand(900)); |
| + | my $aflags = "--port $port $flags"; |
| + | |
| + | my $cmd = "$exe $aflags"; |
| + | ($http3pid, $pid3) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($http3pid <= 0 || !pidexists($http3pid)) { |
| + | # it is NOT alive |
| + | stopserver($server, "$pid3"); |
| + | $doesntrun{$pidfile} = 1; |
| + | $http3pid = $pid3 = 0; |
| + | next; |
| + | } |
| + | $doesntrun{$pidfile} = 0; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server PID $http3pid port $port\n"; |
| + | } |
| + | last; |
| + | } |
| + | |
| + | logmsg "RUN: failed to start the $srvrname server\n" if(!$http3pid); |
| + | |
| + | return ($http3pid, $pid3, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # start the https stunnel based server |
| + | # |
| + | sub runhttpsserver { |
| + | my ($verb, $proto, $proxy, $certfile) = @_; |
| + | my $ip = $HOSTIP; |
| + | my $ipvnum = 4; |
| + | my $idnum = 1; |
| + | |
| + | if($proxy eq "proxy") { |
| + | # the https-proxy runs as https2 |
| + | $idnum = 2; |
| + | } |
| + | |
| + | if(!$stunnel) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | $certfile = 'stunnel.pem' unless($certfile); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--verbose " if($debugprotocol); |
| + | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| + | $flags .= "--logdir \"$LOGDIR\" "; |
| + | $flags .= "--id $idnum " if($idnum > 1); |
| + | $flags .= "--ipv$ipvnum --proto $proto "; |
| + | $flags .= "--certfile \"$certfile\" " if($certfile ne 'stunnel.pem'); |
| + | $flags .= "--stunnel \"$stunnel\" --srcdir \"$srcdir\" "; |
| + | if($proto eq "gophers") { |
| + | $flags .= "--connect " . protoport("gopher"); |
| + | } |
| + | elsif(!$proxy) { |
| + | $flags .= "--connect " . protoport("http"); |
| + | } |
| + | else { |
| + | # for HTTPS-proxy we connect to the HTTP proxy |
| + | $flags .= "--connect " . protoport("httpproxy"); |
| + | } |
| + | |
| + | my $pid2; |
| + | my $httpspid; |
| + | my $port = 24512; # start attempt |
| + | for (1 .. 10) { |
| + | $port += int(rand(600)); |
| + | my $options = "$flags --accept $port"; |
| + | |
| + | my $cmd = "$perl $srcdir/secureserver.pl $options"; |
| + | ($httpspid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($httpspid <= 0 || !pidexists($httpspid)) { |
| + | # it is NOT alive |
| + | stopserver($server, "$pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | $httpspid = $pid2 = 0; |
| + | next; |
| + | } |
| + | # we have a server! |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server is PID $httpspid port $port\n"; |
| + | } |
| + | last; |
| + | } |
| + | $runcert{$server} = $certfile; |
| + | logmsg "RUN: failed to start the $srvrname server\n" if(!$httpspid); |
| + | |
| + | return ($httpspid, $pid2, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # start the non-stunnel HTTP TLS extensions capable server |
| + | # |
| + | sub runhttptlsserver { |
| + | my ($verb, $ipv6) = @_; |
| + | my $proto = "httptls"; |
| + | my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP"; |
| + | my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4; |
| + | my $idnum = 1; |
| + | |
| + | if(!$httptlssrv) { |
| + | return (0,0); |
| + | } |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--http "; |
| + | $flags .= "--debug 1 " if($debugprotocol); |
| + | $flags .= "--priority NORMAL:+SRP "; |
| + | $flags .= "--srppasswd $srcdir/certs/srp-verifier-db "; |
| + | $flags .= "--srppasswdconf $srcdir/certs/srp-verifier-conf"; |
| + | |
| + | my $port = 24367; |
| + | my ($httptlspid, $pid2); |
| + | for (1 .. 10) { |
| + | $port += int(rand(800)); |
| + | my $allflags = "--port $port $flags"; |
| + | |
| + | my $cmd = "$httptlssrv $allflags > $logfile 2>&1"; |
| + | ($httptlspid, $pid2) = startnew($cmd, $pidfile, 10, 1); |
| + | |
| + | if($httptlspid <= 0 || !pidexists($httptlspid)) { |
| + | # it is NOT alive |
| + | stopserver($server, "$pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | $httptlspid = $pid2 = 0; |
| + | next; |
| + | } |
| + | $doesntrun{$pidfile} = 0; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server PID $httptlspid port $port\n"; |
| + | } |
| + | last; |
| + | } |
| + | logmsg "RUN: failed to start the $srvrname server\n" if(!$httptlspid); |
| + | return ($httptlspid, $pid2, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # start the pingpong server (FTP, POP3, IMAP, SMTP) |
| + | # |
| + | sub runpingpongserver { |
| + | my ($proto, $id, $verb, $ipv6) = @_; |
| + | my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP"; |
| + | my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4; |
| + | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | my $portfile = $serverportfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0,0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--verbose " if($debugprotocol); |
| + | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| + | $flags .= "--logdir \"$LOGDIR\" "; |
| + | $flags .= "--portfile \"$portfile\" "; |
| + | $flags .= "--srcdir \"$srcdir\" --proto $proto "; |
| + | $flags .= "--id $idnum " if($idnum > 1); |
| + | $flags .= "--ipv$ipvnum --port 0 --addr \"$ip\""; |
| + | |
| + | my $cmd = "$perl $srcdir/ftpserver.pl $flags"; |
| + | my ($ftppid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($ftppid <= 0 || !pidexists($ftppid)) { |
| + | # it is NOT alive |
| + | logmsg "RUN: failed to start the $srvrname server\n"; |
| + | stopserver($server, "$pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | return (0,0); |
| + | } |
| + | |
| + | # where is it? |
| + | my $port = pidfromfile($portfile); |
| + | |
| + | logmsg "PINGPONG runs on port $port ($portfile)\n" if($verb); |
| + | |
| + | # Server is up. Verify that we can speak to it. |
| + | my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port); |
| + | if(!$pid3) { |
| + | logmsg "RUN: $srvrname server failed verification\n"; |
| + | # failed to talk to it properly. Kill the server and return failure |
| + | stopserver($server, "$ftppid $pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | return (0,0); |
| + | } |
| + | $pid2 = $pid3; |
| + | |
| + | logmsg "RUN: $srvrname server is PID $ftppid port $port\n" if($verb); |
| + | |
| + | # Assign the correct port variable! |
| + | if($proto =~ /^(?:ftp|imap|pop3|smtp)$/) { |
| + | $PORT{$proto . ($ipvnum == 6? '6': '')} = $port; |
| + | } |
| + | else { |
| + | print STDERR "Unsupported protocol $proto!!\n"; |
| + | return (0,0); |
| + | } |
| + | |
| + | return ($pid2, $ftppid); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # start the ftps/imaps/pop3s/smtps server (or rather, tunnel) |
| + | # |
| + | sub runsecureserver { |
| + | my ($verb, $ipv6, $certfile, $proto, $clearport) = @_; |
| + | my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP"; |
| + | my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4; |
| + | my $idnum = 1; |
| + | |
| + | if(!$stunnel) { |
| + | return (0,0); |
| + | } |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | $certfile = 'stunnel.pem' unless($certfile); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--verbose " if($debugprotocol); |
| + | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| + | $flags .= "--logdir \"$LOGDIR\" "; |
| + | $flags .= "--id $idnum " if($idnum > 1); |
| + | $flags .= "--ipv$ipvnum --proto $proto "; |
| + | $flags .= "--certfile \"$certfile\" " if($certfile ne 'stunnel.pem'); |
| + | $flags .= "--stunnel \"$stunnel\" --srcdir \"$srcdir\" "; |
| + | $flags .= "--connect $clearport"; |
| + | |
| + | my $protospid; |
| + | my $pid2; |
| + | my $port = 26713 + ord $proto; |
| + | my %usedports = reverse %PORT; |
| + | for (1 .. 10) { |
| + | $port += int(rand(700)); |
| + | next if exists $usedports{$port}; |
| + | my $options = "$flags --accept $port"; |
| + | my $cmd = "$perl $srcdir/secureserver.pl $options"; |
| + | ($protospid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($protospid <= 0 || !pidexists($protospid)) { |
| + | # it is NOT alive |
| + | stopserver($server, "$pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | $protospid = $pid2 = 0; |
| + | next; |
| + | } |
| + | |
| + | $doesntrun{$pidfile} = 0; |
| + | $runcert{$server} = $certfile; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server is PID $protospid port $port\n"; |
| + | } |
| + | last; |
| + | } |
| + | |
| + | logmsg "RUN: failed to start the $srvrname server\n" if(!$protospid); |
| + | |
| + | return ($protospid, $pid2, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # start the tftp server |
| + | # |
| + | sub runtftpserver { |
| + | my ($id, $verb, $ipv6) = @_; |
| + | my $ip = $HOSTIP; |
| + | my $proto = 'tftp'; |
| + | my $ipvnum = 4; |
| + | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| + | |
| + | if($ipv6) { |
| + | # if IPv6, use a different setup |
| + | $ipvnum = 6; |
| + | $ip = $HOST6IP; |
| + | } |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $portfile = $serverportfile{$server}; |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--verbose " if($debugprotocol); |
| + | $flags .= "--pidfile \"$pidfile\" "; |
| + | $flags .= "--portfile \"$portfile\" "; |
| + | $flags .= "--logfile \"$logfile\" "; |
| + | $flags .= "--logdir \"$LOGDIR\" "; |
| + | $flags .= "--id $idnum " if($idnum > 1); |
| + | $flags .= "--ipv$ipvnum --port 0 --srcdir \"$srcdir\""; |
| + | |
| + | my $cmd = "$perl $srcdir/tftpserver.pl $flags"; |
| + | my ($tftppid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($tftppid <= 0 || !pidexists($tftppid)) { |
| + | # it is NOT alive |
| + | logmsg "RUN: failed to start the $srvrname server\n"; |
| + | stopserver($server, "$pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $port = pidfromfile($portfile); |
| + | |
| + | # Server is up. Verify that we can speak to it. |
| + | my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port); |
| + | if(!$pid3) { |
| + | logmsg "RUN: $srvrname server failed verification\n"; |
| + | # failed to talk to it properly. Kill the server and return failure |
| + | stopserver($server, "$tftppid $pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | return (0, 0, 0); |
| + | } |
| + | $pid2 = $pid3; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server on PID $tftppid port $port\n"; |
| + | } |
| + | |
| + | return ($pid2, $tftppid, $port); |
| + | } |
| + | |
| + | |
| + | ####################################################################### |
| + | # start the rtsp server |
| + | # |
| + | sub runrtspserver { |
| + | my ($verb, $ipv6) = @_; |
| + | my $ip = $HOSTIP; |
| + | my $proto = 'rtsp'; |
| + | my $ipvnum = 4; |
| + | my $idnum = 1; |
| + | |
| + | if($ipv6) { |
| + | # if IPv6, use a different setup |
| + | $ipvnum = 6; |
| + | $ip = $HOST6IP; |
| + | } |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | my $portfile = $serverportfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--verbose " if($debugprotocol); |
| + | $flags .= "--pidfile \"$pidfile\" "; |
| + | $flags .= "--portfile \"$portfile\" "; |
| + | $flags .= "--logfile \"$logfile\" "; |
| + | $flags .= "--logdir \"$LOGDIR\" "; |
| + | $flags .= "--id $idnum " if($idnum > 1); |
| + | $flags .= "--ipv$ipvnum --port 0 --srcdir \"$srcdir\""; |
| + | |
| + | my $cmd = "$perl $srcdir/rtspserver.pl $flags"; |
| + | my ($rtsppid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($rtsppid <= 0 || !pidexists($rtsppid)) { |
| + | # it is NOT alive |
| + | logmsg "RUN: failed to start the $srvrname server\n"; |
| + | stopserver($server, "$pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $port = pidfromfile($portfile); |
| + | |
| + | # Server is up. Verify that we can speak to it. |
| + | my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port); |
| + | if(!$pid3) { |
| + | logmsg "RUN: $srvrname server failed verification\n"; |
| + | # failed to talk to it properly. Kill the server and return failure |
| + | stopserver($server, "$rtsppid $pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | return (0, 0, 0); |
| + | } |
| + | $pid2 = $pid3; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server PID $rtsppid port $port\n"; |
| + | } |
| + | |
| + | return ($rtsppid, $pid2, $port); |
| + | } |
| + | |
| + | |
| + | ####################################################################### |
| + | # Start the ssh (scp/sftp) server |
| + | # |
| + | sub runsshserver { |
| + | my ($id, $verb, $ipv6) = @_; |
| + | my $ip=$HOSTIP; |
| + | my $proto = 'ssh'; |
| + | my $ipvnum = 4; |
| + | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| + | my $port = 20000; # no lower port |
| + | |
| + | if(!$USER) { |
| + | logmsg "Can't start ssh server due to lack of USER name"; |
| + | return (0,0,0); |
| + | } |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $sshd = find_sshd(); |
| + | if($sshd) { |
| + | ($sshdid,$sshdvernum,$sshdverstr,$sshderror) = sshversioninfo($sshd); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--verbose " if($verb); |
| + | $flags .= "--debugprotocol " if($debugprotocol); |
| + | $flags .= "--pidfile \"$pidfile\" "; |
| + | $flags .= "--logdir \"$LOGDIR\" "; |
| + | $flags .= "--id $idnum " if($idnum > 1); |
| + | $flags .= "--ipv$ipvnum --addr \"$ip\" "; |
| + | $flags .= "--user \"$USER\""; |
| + | |
| + | my $sshpid; |
| + | my $pid2; |
| + | |
| + | my $wport = 0, |
| + | my @tports; |
| + | for(1 .. 10) { |
| + | |
| + | # sshd doesn't have a way to pick an unused random port number, so |
| + | # instead we iterate over possible port numbers to use until we find |
| + | # one that works |
| + | $port += int(rand(500)); |
| + | push @tports, $port; |
| + | |
| + | my $options = "$flags --sshport $port"; |
| + | |
| + | my $cmd = "$perl $srcdir/sshserver.pl $options"; |
| + | ($sshpid, $pid2) = startnew($cmd, $pidfile, 60, 0); |
| + | |
| + | # on loaded systems sshserver start up can take longer than the |
| + | # timeout passed to startnew, when this happens startnew completes |
| + | # without being able to read the pidfile and consequently returns a |
| + | # zero pid2 above. |
| + | if($sshpid <= 0 || !pidexists($sshpid)) { |
| + | # it is NOT alive |
| + | stopserver($server, "$pid2"); |
| + | $doesntrun{$pidfile} = 1; |
| + | $sshpid = $pid2 = 0; |
| + | next; |
| + | } |
| + | |
| + | # once it is known that the ssh server is alive, sftp server |
| + | # verification is performed actually connecting to it, authenticating |
| + | # and performing a very simple remote command. This verification is |
| + | # tried only one time. |
| + | |
| + | $sshdlog = server_logfilename($LOGDIR, 'ssh', $ipvnum, $idnum); |
| + | $sftplog = server_logfilename($LOGDIR, 'sftp', $ipvnum, $idnum); |
| + | |
| + | if(verifysftp('sftp', $ipvnum, $idnum, $ip, $port) < 1) { |
| + | logmsg "RUN: SFTP server failed verification\n"; |
| + | # failed to talk to it properly. Kill the server and return failure |
| + | display_sftplog(); |
| + | display_sftpconfig(); |
| + | display_sshdlog(); |
| + | display_sshdconfig(); |
| + | stopserver($server, "$sshpid $pid2"); |
| + | $doesntrun{$pidfile} = 1; |
| + | $sshpid = $pid2 = 0; |
| + | next; |
| + | } |
| + | # we're happy, no need to loop anymore! |
| + | $doesntrun{$pidfile} = 0; |
| + | $wport = $port; |
| + | last; |
| + | } |
| + | logmsg "RUN: failed to start the $srvrname server on $port\n" if(!$sshpid); |
| + | |
| + | if(!$wport) { |
| + | logmsg "RUN: couldn't start $srvrname. Tried these ports:"; |
| + | logmsg "RUN: ".join(", ", @tports)."\n"; |
| + | return (0,0,0); |
| + | } |
| + | |
| + | my $hostfile; |
| + | if(!open($hostfile, "<", $PIDDIR . "/" . $hstpubmd5f) || |
| + | (read($hostfile, $SSHSRVMD5, 32) != 32) || |
| + | !close($hostfile) || |
| + | ($SSHSRVMD5 !~ /^[a-f0-9]{32}$/i)) |
| + | { |
| + | my $msg = "Fatal: $srvrname pubkey md5 missing : \"$hstpubmd5f\" : $!"; |
| + | logmsg "$msg\n"; |
| + | stopservers($verb); |
| + | die $msg; |
| + | } |
| + | |
| + | if(!open($hostfile, "<", $PIDDIR . "/" . $hstpubsha256f) || |
| + | (read($hostfile, $SSHSRVSHA256, 48) == 0) || |
| + | !close($hostfile)) |
| + | { |
| + | my $msg = "Fatal: $srvrname pubkey sha256 missing : \"$hstpubsha256f\" : $!"; |
| + | logmsg "$msg\n"; |
| + | stopservers($verb); |
| + | die $msg; |
| + | } |
| + | |
| + | logmsg "RUN: $srvrname on PID $pid2 port $wport\n" if($verb); |
| + | |
| + | return ($pid2, $sshpid, $wport); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Start the MQTT server |
| + | # |
| + | sub runmqttserver { |
| + | my ($id, $verb, $ipv6) = @_; |
| + | my $ip=$HOSTIP; |
| + | my $proto = 'mqtt'; |
| + | my $port = protoport($proto); |
| + | my $ipvnum = 4; |
| + | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | my $pidfile = $serverpidfile{$server}; |
| + | my $portfile = $serverportfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0,0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | # start our MQTT server - on a random port! |
| + | my $cmd="server/mqttd".exe_ext('SRV'). |
| + | " --port 0 ". |
| + | " --pidfile $pidfile". |
| + | " --portfile $portfile". |
| + | " --config $FTPDCMD". |
| + | " --logfile $logfile". |
| + | " --logdir $LOGDIR"; |
| + | my ($sockspid, $pid2) = startnew($cmd, $pidfile, 30, 0); |
| + | |
| + | if($sockspid <= 0 || !pidexists($sockspid)) { |
| + | # it is NOT alive |
| + | logmsg "RUN: failed to start the $srvrname server\n"; |
| + | stopserver($server, "$pid2"); |
| + | $doesntrun{$pidfile} = 1; |
| + | return (0,0); |
| + | } |
| + | |
| + | my $mqttport = pidfromfile($portfile); |
| + | $PORT{"mqtt"} = $mqttport; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server is now running PID $pid2 on PORT $mqttport\n"; |
| + | } |
| + | |
| + | return ($pid2, $sockspid); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Start the socks server |
| + | # |
| + | sub runsocksserver { |
| + | my ($id, $verb, $ipv6, $is_unix) = @_; |
| + | my $ip=$HOSTIP; |
| + | my $proto = 'socks'; |
| + | my $ipvnum = 4; |
| + | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $portfile = $serverportfile{$server}; |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | # start our socks server, get commands from the FTP cmd file |
| + | my $cmd=""; |
| + | if($is_unix) { |
| + | $cmd="server/socksd".exe_ext('SRV'). |
| + | " --pidfile $pidfile". |
| + | " --reqfile $SOCKSIN". |
| + | " --logfile $logfile". |
| + | " --unix-socket $SOCKSUNIXPATH". |
| + | " --backend $HOSTIP". |
| + | " --config $FTPDCMD"; |
| + | } else { |
| + | $cmd="server/socksd".exe_ext('SRV'). |
| + | " --port 0 ". |
| + | " --pidfile $pidfile". |
| + | " --portfile $portfile". |
| + | " --reqfile $SOCKSIN". |
| + | " --logfile $logfile". |
| + | " --backend $HOSTIP". |
| + | " --config $FTPDCMD"; |
| + | } |
| + | my ($sockspid, $pid2) = startnew($cmd, $pidfile, 30, 0); |
| + | |
| + | if($sockspid <= 0 || !pidexists($sockspid)) { |
| + | # it is NOT alive |
| + | logmsg "RUN: failed to start the $srvrname server\n"; |
| + | stopserver($server, "$pid2"); |
| + | $doesntrun{$pidfile} = 1; |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $port = pidfromfile($portfile); |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server is now running PID $pid2\n"; |
| + | } |
| + | |
| + | return ($pid2, $sockspid, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # start the dict server |
| + | # |
| + | sub rundictserver { |
| + | my ($verb, $alt) = @_; |
| + | my $proto = "dict"; |
| + | my $ip = $HOSTIP; |
| + | my $ipvnum = 4; |
| + | my $idnum = 1; |
| + | |
| + | if($alt eq "ipv6") { |
| + | # No IPv6 |
| + | } |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--verbose 1 " if($debugprotocol); |
| + | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| + | $flags .= "--id $idnum " if($idnum > 1); |
| + | $flags .= "--srcdir \"$srcdir\" "; |
| + | $flags .= "--host $HOSTIP"; |
| + | |
| + | my $port = 29000; |
| + | my ($dictpid, $pid2); |
| + | for(1 .. 10) { |
| + | $port += int(rand(900)); |
| + | my $aflags = "--port $port $flags"; |
| + | my $cmd = "$srcdir/dictserver.py $aflags"; |
| + | ($dictpid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($dictpid <= 0 || !pidexists($dictpid)) { |
| + | # it is NOT alive |
| + | stopserver($server, "$pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | $dictpid = $pid2 = 0; |
| + | next; |
| + | } |
| + | $doesntrun{$pidfile} = 0; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server PID $dictpid port $port\n"; |
| + | } |
| + | last; |
| + | } |
| + | logmsg "RUN: failed to start the $srvrname server\n" if(!$dictpid); |
| + | |
| + | return ($dictpid, $pid2, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # start the SMB server |
| + | # |
| + | sub runsmbserver { |
| + | my ($verb, $alt) = @_; |
| + | my $proto = "smb"; |
| + | my $ip = $HOSTIP; |
| + | my $ipvnum = 4; |
| + | my $idnum = 1; |
| + | |
| + | if($alt eq "ipv6") { |
| + | # No IPv6 |
| + | } |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--verbose 1 " if($debugprotocol); |
| + | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| + | $flags .= "--id $idnum " if($idnum > 1); |
| + | $flags .= "--srcdir \"$srcdir\" "; |
| + | $flags .= "--host $HOSTIP"; |
| + | |
| + | my ($smbpid, $pid2); |
| + | my $port = 31923; |
| + | for(1 .. 10) { |
| + | $port += int(rand(760)); |
| + | my $aflags = "--port $port $flags"; |
| + | my $cmd = "$srcdir/smbserver.py $aflags"; |
| + | ($smbpid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($smbpid <= 0 || !pidexists($smbpid)) { |
| + | # it is NOT alive |
| + | stopserver($server, "$pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | $smbpid = $pid2 = 0; |
| + | next; |
| + | } |
| + | $doesntrun{$pidfile} = 0; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server PID $smbpid port $port\n"; |
| + | } |
| + | last; |
| + | } |
| + | logmsg "RUN: failed to start the $srvrname server\n" if(!$smbpid); |
| + | |
| + | return ($smbpid, $pid2, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # start the telnet server |
| + | # |
| + | sub runnegtelnetserver { |
| + | my ($verb, $alt) = @_; |
| + | my $proto = "telnet"; |
| + | my $ip = $HOSTIP; |
| + | my $ipvnum = 4; |
| + | my $idnum = 1; |
| + | |
| + | if($alt eq "ipv6") { |
| + | # No IPv6 |
| + | } |
| + | |
| + | my $server = servername_id($proto, $ipvnum, $idnum); |
| + | |
| + | my $pidfile = $serverpidfile{$server}; |
| + | |
| + | # don't retry if the server doesn't work |
| + | if ($doesntrun{$pidfile}) { |
| + | return (0, 0, 0); |
| + | } |
| + | |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | stopserver($server, "$pid"); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | |
| + | my $srvrname = servername_str($proto, $ipvnum, $idnum); |
| + | my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); |
| + | |
| + | my $flags = ""; |
| + | $flags .= "--verbose 1 " if($debugprotocol); |
| + | $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| + | $flags .= "--id $idnum " if($idnum > 1); |
| + | $flags .= "--srcdir \"$srcdir\""; |
| + | |
| + | my ($ntelpid, $pid2); |
| + | my $port = 32000; |
| + | for(1 .. 10) { |
| + | $port += int(rand(800)); |
| + | my $aflags = "--port $port $flags"; |
| + | my $cmd = "$srcdir/negtelnetserver.py $aflags"; |
| + | ($ntelpid, $pid2) = startnew($cmd, $pidfile, 15, 0); |
| + | |
| + | if($ntelpid <= 0 || !pidexists($ntelpid)) { |
| + | # it is NOT alive |
| + | stopserver($server, "$pid2"); |
| + | displaylogs($testnumcheck); |
| + | $doesntrun{$pidfile} = 1; |
| + | $ntelpid = $pid2 = 0; |
| + | next; |
| + | } |
| + | $doesntrun{$pidfile} = 0; |
| + | |
| + | if($verb) { |
| + | logmsg "RUN: $srvrname server PID $ntelpid port $port\n"; |
| + | } |
| + | last; |
| + | } |
| + | logmsg "RUN: failed to start the $srvrname server\n" if(!$ntelpid); |
| + | |
| + | return ($ntelpid, $pid2, $port); |
| + | } |
| + | |
| + | |
| + | |
| + | |
| + | ####################################################################### |
| + | # Single shot http and gopher server responsiveness test. This should only |
| + | # be used to verify that a server present in %run hash is still functional |
| + | # |
| + | sub responsive_http_server { |
| + | my ($proto, $verb, $alt, $port_or_path) = @_; |
| + | my $ip = $HOSTIP; |
| + | my $ipvnum = 4; |
| + | my $idnum = 1; |
| + | |
| + | if($alt eq "ipv6") { |
| + | # if IPv6, use a different setup |
| + | $ipvnum = 6; |
| + | $ip = $HOST6IP; |
| + | } |
| + | elsif($alt eq "proxy") { |
| + | $idnum = 2; |
| + | } |
| + | elsif($alt eq "unix") { |
| + | # IP (protocol) is mutually exclusive with Unix sockets |
| + | $ipvnum = "unix"; |
| + | } |
| + | |
| + | return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port_or_path); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Single shot pingpong server responsiveness test. This should only be |
| + | # used to verify that a server present in %run hash is still functional |
| + | # |
| + | sub responsive_pingpong_server { |
| + | my ($proto, $id, $verb, $ipv6) = @_; |
| + | my $port; |
| + | my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP"; |
| + | my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4; |
| + | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| + | my $protoip = $proto . ($ipvnum == 6? '6': ''); |
| + | |
| + | if($proto =~ /^(?:ftp|imap|pop3|smtp)$/) { |
| + | $port = protoport($protoip); |
| + | } |
| + | else { |
| + | print STDERR "Unsupported protocol $proto!!\n"; |
| + | return 0; |
| + | } |
| + | |
| + | return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Single shot rtsp server responsiveness test. This should only be |
| + | # used to verify that a server present in %run hash is still functional |
| + | # |
| + | sub responsive_rtsp_server { |
| + | my ($verb, $ipv6) = @_; |
| + | my $proto = 'rtsp'; |
| + | my $port = protoport($proto); |
| + | my $ip = $HOSTIP; |
| + | my $ipvnum = 4; |
| + | my $idnum = 1; |
| + | |
| + | if($ipv6) { |
| + | # if IPv6, use a different setup |
| + | $ipvnum = 6; |
| + | $port = protoport('rtsp6'); |
| + | $ip = $HOST6IP; |
| + | } |
| + | |
| + | return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Single shot tftp server responsiveness test. This should only be |
| + | # used to verify that a server present in %run hash is still functional |
| + | # |
| + | sub responsive_tftp_server { |
| + | my ($id, $verb, $ipv6) = @_; |
| + | my $proto = 'tftp'; |
| + | my $port = protoport($proto); |
| + | my $ip = $HOSTIP; |
| + | my $ipvnum = 4; |
| + | my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; |
| + | |
| + | if($ipv6) { |
| + | # if IPv6, use a different setup |
| + | $ipvnum = 6; |
| + | $port = protoport('tftp6'); |
| + | $ip = $HOST6IP; |
| + | } |
| + | |
| + | return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Single shot non-stunnel HTTP TLS extensions capable server |
| + | # responsiveness test. This should only be used to verify that a |
| + | # server present in %run hash is still functional |
| + | # |
| + | sub responsive_httptls_server { |
| + | my ($verb, $ipv6) = @_; |
| + | my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4; |
| + | my $proto = "httptls"; |
| + | my $port = protoport($proto); |
| + | my $ip = "$HOSTIP"; |
| + | my $idnum = 1; |
| + | |
| + | if ($ipvnum == 6) { |
| + | $port = protoport("httptls6"); |
| + | $ip = "$HOST6IP"; |
| + | } |
| + | |
| + | return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port); |
| + | } |
| + | |
| + | ####################################################################### |
| + | # startservers() starts all the named servers |
| + | # |
| + | # Returns: string with error reason or blank for success |
| + | # |
| + | sub startservers { |
| + | my @what = @_; |
| + | my ($pid, $pid2); |
| + | for(@what) { |
| + | my (@whatlist) = split(/\s+/,$_); |
| + | my $what = lc($whatlist[0]); |
| + | $what =~ s/[^a-z0-9\/-]//g; |
| + | |
| + | my $certfile; |
| + | if($what =~ /^(ftp|gopher|http|imap|pop3|smtp)s((\d*)(-ipv6|-unix|))$/) { |
| + | $certfile = ($whatlist[1]) ? $whatlist[1] : 'stunnel.pem'; |
| + | } |
| + | |
| + | if(($what eq "pop3") || |
| + | ($what eq "ftp") || |
| + | ($what eq "imap") || |
| + | ($what eq "smtp")) { |
| + | if($torture && $run{$what} && |
| + | !responsive_pingpong_server($what, "", $verbose)) { |
| + | if(stopserver($what)) { |
| + | return "failed stopping unresponsive ".uc($what)." server"; |
| + | } |
| + | } |
| + | if(!$run{$what}) { |
| + | ($pid, $pid2) = runpingpongserver($what, "", $verbose); |
| + | if($pid <= 0) { |
| + | return "failed starting ". uc($what) ." server"; |
| + | } |
| + | printf ("* pid $what => %d %d\n", $pid, $pid2) if($verbose); |
| + | $run{$what}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "ftp-ipv6") { |
| + | if($torture && $run{'ftp-ipv6'} && |
| + | !responsive_pingpong_server("ftp", "", $verbose, "ipv6")) { |
| + | if(stopserver('ftp-ipv6')) { |
| + | return "failed stopping unresponsive FTP-IPv6 server"; |
| + | } |
| + | } |
| + | if(!$run{'ftp-ipv6'}) { |
| + | ($pid, $pid2) = runpingpongserver("ftp", "", $verbose, "ipv6"); |
| + | if($pid <= 0) { |
| + | return "failed starting FTP-IPv6 server"; |
| + | } |
| + | logmsg sprintf("* pid ftp-ipv6 => %d %d\n", $pid, |
| + | $pid2) if($verbose); |
| + | $run{'ftp-ipv6'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "gopher") { |
| + | if($torture && $run{'gopher'} && |
| + | !responsive_http_server("gopher", $verbose, 0, |
| + | protoport("gopher"))) { |
| + | if(stopserver('gopher')) { |
| + | return "failed stopping unresponsive GOPHER server"; |
| + | } |
| + | } |
| + | if(!$run{'gopher'}) { |
| + | ($pid, $pid2, $PORT{'gopher'}) = |
| + | runhttpserver("gopher", $verbose, 0); |
| + | if($pid <= 0) { |
| + | return "failed starting GOPHER server"; |
| + | } |
| + | logmsg sprintf ("* pid gopher => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'gopher'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "gopher-ipv6") { |
| + | if($torture && $run{'gopher-ipv6'} && |
| + | !responsive_http_server("gopher", $verbose, "ipv6", |
| + | protoport("gopher"))) { |
| + | if(stopserver('gopher-ipv6')) { |
| + | return "failed stopping unresponsive GOPHER-IPv6 server"; |
| + | } |
| + | } |
| + | if(!$run{'gopher-ipv6'}) { |
| + | ($pid, $pid2, $PORT{"gopher6"}) = |
| + | runhttpserver("gopher", $verbose, "ipv6"); |
| + | if($pid <= 0) { |
| + | return "failed starting GOPHER-IPv6 server"; |
| + | } |
| + | logmsg sprintf("* pid gopher-ipv6 => %d %d\n", $pid, |
| + | $pid2) if($verbose); |
| + | $run{'gopher-ipv6'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "http/3") { |
| + | if(!$run{'http/3'}) { |
| + | ($pid, $pid2, $PORT{"http3"}) = runhttp3server($verbose); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTP/3 server"; |
| + | } |
| + | logmsg sprintf ("* pid http/3 => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'http/3'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "http/2") { |
| + | if(!$run{'http/2'}) { |
| + | ($pid, $pid2, $PORT{"http2"}, $PORT{"http2tls"}) = |
| + | runhttp2server($verbose); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTP/2 server"; |
| + | } |
| + | logmsg sprintf ("* pid http/2 => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'http/2'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "http") { |
| + | if($torture && $run{'http'} && |
| + | !responsive_http_server("http", $verbose, 0, protoport('http'))) { |
| + | if(stopserver('http')) { |
| + | return "failed stopping unresponsive HTTP server"; |
| + | } |
| + | } |
| + | if(!$run{'http'}) { |
| + | ($pid, $pid2, $PORT{'http'}) = |
| + | runhttpserver("http", $verbose, 0); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTP server"; |
| + | } |
| + | logmsg sprintf ("* pid http => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'http'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "http-proxy") { |
| + | if($torture && $run{'http-proxy'} && |
| + | !responsive_http_server("http", $verbose, "proxy", |
| + | protoport("httpproxy"))) { |
| + | if(stopserver('http-proxy')) { |
| + | return "failed stopping unresponsive HTTP-proxy server"; |
| + | } |
| + | } |
| + | if(!$run{'http-proxy'}) { |
| + | ($pid, $pid2, $PORT{"httpproxy"}) = |
| + | runhttpserver("http", $verbose, "proxy"); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTP-proxy server"; |
| + | } |
| + | logmsg sprintf ("* pid http-proxy => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'http-proxy'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "http-ipv6") { |
| + | if($torture && $run{'http-ipv6'} && |
| + | !responsive_http_server("http", $verbose, "ipv6", |
| + | protoport("http6"))) { |
| + | if(stopserver('http-ipv6')) { |
| + | return "failed stopping unresponsive HTTP-IPv6 server"; |
| + | } |
| + | } |
| + | if(!$run{'http-ipv6'}) { |
| + | ($pid, $pid2, $PORT{"http6"}) = |
| + | runhttpserver("http", $verbose, "ipv6"); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTP-IPv6 server"; |
| + | } |
| + | logmsg sprintf("* pid http-ipv6 => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'http-ipv6'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "rtsp") { |
| + | if($torture && $run{'rtsp'} && |
| + | !responsive_rtsp_server($verbose)) { |
| + | if(stopserver('rtsp')) { |
| + | return "failed stopping unresponsive RTSP server"; |
| + | } |
| + | } |
| + | if(!$run{'rtsp'}) { |
| + | ($pid, $pid2, $PORT{'rtsp'}) = runrtspserver($verbose); |
| + | if($pid <= 0) { |
| + | return "failed starting RTSP server"; |
| + | } |
| + | printf ("* pid rtsp => %d %d\n", $pid, $pid2) if($verbose); |
| + | $run{'rtsp'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "rtsp-ipv6") { |
| + | if($torture && $run{'rtsp-ipv6'} && |
| + | !responsive_rtsp_server($verbose, "ipv6")) { |
| + | if(stopserver('rtsp-ipv6')) { |
| + | return "failed stopping unresponsive RTSP-IPv6 server"; |
| + | } |
| + | } |
| + | if(!$run{'rtsp-ipv6'}) { |
| + | ($pid, $pid2, $PORT{'rtsp6'}) = runrtspserver($verbose, "ipv6"); |
| + | if($pid <= 0) { |
| + | return "failed starting RTSP-IPv6 server"; |
| + | } |
| + | logmsg sprintf("* pid rtsp-ipv6 => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'rtsp-ipv6'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what =~ /^(ftp|imap|pop3|smtp)s$/) { |
| + | my $cproto = $1; |
| + | if(!$stunnel) { |
| + | # we can't run ftps tests without stunnel |
| + | return "no stunnel"; |
| + | } |
| + | if($runcert{$what} && ($runcert{$what} ne $certfile)) { |
| + | # stop server when running and using a different cert |
| + | if(stopserver($what)) { |
| + | return "failed stopping $what server with different cert"; |
| + | } |
| + | } |
| + | if($torture && $run{$cproto} && |
| + | !responsive_pingpong_server($cproto, "", $verbose)) { |
| + | if(stopserver($cproto)) { |
| + | return "failed stopping unresponsive $cproto server"; |
| + | } |
| + | } |
| + | if(!$run{$cproto}) { |
| + | ($pid, $pid2) = runpingpongserver($cproto, "", $verbose); |
| + | if($pid <= 0) { |
| + | return "failed starting $cproto server"; |
| + | } |
| + | printf ("* pid $cproto => %d %d\n", $pid, $pid2) if($verbose); |
| + | $run{$cproto}="$pid $pid2"; |
| + | } |
| + | if(!$run{$what}) { |
| + | ($pid, $pid2, $PORT{$what}) = |
| + | runsecureserver($verbose, "", $certfile, $what, |
| + | protoport($cproto)); |
| + | if($pid <= 0) { |
| + | return "failed starting $what server (stunnel)"; |
| + | } |
| + | logmsg sprintf("* pid $what => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{$what}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "file") { |
| + | # we support it but have no server! |
| + | } |
| + | elsif($what eq "https") { |
| + | if(!$stunnel) { |
| + | # we can't run https tests without stunnel |
| + | return "no stunnel"; |
| + | } |
| + | if($runcert{'https'} && ($runcert{'https'} ne $certfile)) { |
| + | # stop server when running and using a different cert |
| + | if(stopserver('https')) { |
| + | return "failed stopping HTTPS server with different cert"; |
| + | } |
| + | } |
| + | if($torture && $run{'http'} && |
| + | !responsive_http_server("http", $verbose, 0, |
| + | protoport('http'))) { |
| + | if(stopserver('http')) { |
| + | return "failed stopping unresponsive HTTP server"; |
| + | } |
| + | } |
| + | if(!$run{'http'}) { |
| + | ($pid, $pid2, $PORT{'http'}) = |
| + | runhttpserver("http", $verbose, 0); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTP server"; |
| + | } |
| + | printf ("* pid http => %d %d\n", $pid, $pid2) if($verbose); |
| + | $run{'http'}="$pid $pid2"; |
| + | } |
| + | if(!$run{'https'}) { |
| + | ($pid, $pid2, $PORT{'https'}) = |
| + | runhttpsserver($verbose, "https", "", $certfile); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTPS server (stunnel)"; |
| + | } |
| + | logmsg sprintf("* pid https => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'https'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "gophers") { |
| + | if(!$stunnel) { |
| + | # we can't run TLS tests without stunnel |
| + | return "no stunnel"; |
| + | } |
| + | if($runcert{'gophers'} && ($runcert{'gophers'} ne $certfile)) { |
| + | # stop server when running and using a different cert |
| + | if(stopserver('gophers')) { |
| + | return "failed stopping GOPHERS server with different crt"; |
| + | } |
| + | } |
| + | if($torture && $run{'gopher'} && |
| + | !responsive_http_server("gopher", $verbose, 0, |
| + | protoport('gopher'))) { |
| + | if(stopserver('gopher')) { |
| + | return "failed stopping unresponsive GOPHER server"; |
| + | } |
| + | } |
| + | if(!$run{'gopher'}) { |
| + | my $port; |
| + | ($pid, $pid2, $port) = |
| + | runhttpserver("gopher", $verbose, 0); |
| + | $PORT{'gopher'} = $port; |
| + | if($pid <= 0) { |
| + | return "failed starting GOPHER server"; |
| + | } |
| + | printf ("* pid gopher => %d %d\n", $pid, $pid2) if($verbose); |
| + | print "GOPHERPORT => $port\n" if($verbose); |
| + | $run{'gopher'}="$pid $pid2"; |
| + | } |
| + | if(!$run{'gophers'}) { |
| + | my $port; |
| + | ($pid, $pid2, $port) = |
| + | runhttpsserver($verbose, "gophers", "", $certfile); |
| + | $PORT{'gophers'} = $port; |
| + | if($pid <= 0) { |
| + | return "failed starting GOPHERS server (stunnel)"; |
| + | } |
| + | logmsg sprintf("* pid gophers => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | print "GOPHERSPORT => $port\n" if($verbose); |
| + | $run{'gophers'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "https-proxy") { |
| + | if(!$stunnel) { |
| + | # we can't run https-proxy tests without stunnel |
| + | return "no stunnel"; |
| + | } |
| + | if($runcert{'https-proxy'} && |
| + | ($runcert{'https-proxy'} ne $certfile)) { |
| + | # stop server when running and using a different cert |
| + | if(stopserver('https-proxy')) { |
| + | return "failed stopping HTTPS-proxy with different cert"; |
| + | } |
| + | } |
| + | |
| + | # we front the http-proxy with stunnel so we need to make sure the |
| + | # proxy runs as well |
| + | my $f = startservers("http-proxy"); |
| + | if($f) { |
| + | return $f; |
| + | } |
| + | |
| + | if(!$run{'https-proxy'}) { |
| + | ($pid, $pid2, $PORT{"httpsproxy"}) = |
| + | runhttpsserver($verbose, "https", "proxy", $certfile); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTPS-proxy (stunnel)"; |
| + | } |
| + | logmsg sprintf("* pid https-proxy => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'https-proxy'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "httptls") { |
| + | if(!$httptlssrv) { |
| + | # for now, we can't run http TLS-EXT tests without gnutls-serv |
| + | return "no gnutls-serv (with SRP support)"; |
| + | } |
| + | if($torture && $run{'httptls'} && |
| + | !responsive_httptls_server($verbose, "IPv4")) { |
| + | if(stopserver('httptls')) { |
| + | return "failed stopping unresponsive HTTPTLS server"; |
| + | } |
| + | } |
| + | if(!$run{'httptls'}) { |
| + | ($pid, $pid2, $PORT{'httptls'}) = |
| + | runhttptlsserver($verbose, "IPv4"); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTPTLS server (gnutls-serv)"; |
| + | } |
| + | logmsg sprintf("* pid httptls => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'httptls'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "httptls-ipv6") { |
| + | if(!$httptlssrv) { |
| + | # for now, we can't run http TLS-EXT tests without gnutls-serv |
| + | return "no gnutls-serv"; |
| + | } |
| + | if($torture && $run{'httptls-ipv6'} && |
| + | !responsive_httptls_server($verbose, "ipv6")) { |
| + | if(stopserver('httptls-ipv6')) { |
| + | return "failed stopping unresponsive HTTPTLS-IPv6 server"; |
| + | } |
| + | } |
| + | if(!$run{'httptls-ipv6'}) { |
| + | ($pid, $pid2, $PORT{"httptls6"}) = |
| + | runhttptlsserver($verbose, "ipv6"); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTPTLS-IPv6 server (gnutls-serv)"; |
| + | } |
| + | logmsg sprintf("* pid httptls-ipv6 => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'httptls-ipv6'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "tftp") { |
| + | if($torture && $run{'tftp'} && |
| + | !responsive_tftp_server("", $verbose)) { |
| + | if(stopserver('tftp')) { |
| + | return "failed stopping unresponsive TFTP server"; |
| + | } |
| + | } |
| + | if(!$run{'tftp'}) { |
| + | ($pid, $pid2, $PORT{'tftp'}) = |
| + | runtftpserver("", $verbose); |
| + | if($pid <= 0) { |
| + | return "failed starting TFTP server"; |
| + | } |
| + | printf ("* pid tftp => %d %d\n", $pid, $pid2) if($verbose); |
| + | $run{'tftp'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "tftp-ipv6") { |
| + | if($torture && $run{'tftp-ipv6'} && |
| + | !responsive_tftp_server("", $verbose, "ipv6")) { |
| + | if(stopserver('tftp-ipv6')) { |
| + | return "failed stopping unresponsive TFTP-IPv6 server"; |
| + | } |
| + | } |
| + | if(!$run{'tftp-ipv6'}) { |
| + | ($pid, $pid2, $PORT{'tftp6'}) = |
| + | runtftpserver("", $verbose, "ipv6"); |
| + | if($pid <= 0) { |
| + | return "failed starting TFTP-IPv6 server"; |
| + | } |
| + | printf("* pid tftp-ipv6 => %d %d\n", $pid, $pid2) if($verbose); |
| + | $run{'tftp-ipv6'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "sftp" || $what eq "scp") { |
| + | if(!$run{'ssh'}) { |
| + | ($pid, $pid2, $PORT{'ssh'}) = runsshserver("", $verbose); |
| + | if($pid <= 0) { |
| + | return "failed starting SSH server"; |
| + | } |
| + | printf ("* pid ssh => %d %d\n", $pid, $pid2) if($verbose); |
| + | $run{'ssh'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "socks4" || $what eq "socks5" ) { |
| + | if(!$run{'socks'}) { |
| + | ($pid, $pid2, $PORT{"socks"}) = runsocksserver("", $verbose); |
| + | if($pid <= 0) { |
| + | return "failed starting socks server"; |
| + | } |
| + | printf ("* pid socks => %d %d\n", $pid, $pid2) if($verbose); |
| + | $run{'socks'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "socks5unix") { |
| + | if(!$run{'socks5unix'}) { |
| + | ($pid, $pid2) = runsocksserver("2", $verbose, "", "unix"); |
| + | if($pid <= 0) { |
| + | return "failed starting socks5unix server"; |
| + | } |
| + | printf ("* pid socks5unix => %d %d\n", $pid, $pid2) if($verbose); |
| + | $run{'socks5unix'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "mqtt" ) { |
| + | if(!$run{'mqtt'}) { |
| + | ($pid, $pid2) = runmqttserver("", $verbose); |
| + | if($pid <= 0) { |
| + | return "failed starting mqtt server"; |
| + | } |
| + | printf ("* pid mqtt => %d %d\n", $pid, $pid2) if($verbose); |
| + | $run{'mqtt'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "http-unix") { |
| + | if($torture && $run{'http-unix'} && |
| + | !responsive_http_server("http", $verbose, "unix", $HTTPUNIXPATH)) { |
| + | if(stopserver('http-unix')) { |
| + | return "failed stopping unresponsive HTTP-unix server"; |
| + | } |
| + | } |
| + | if(!$run{'http-unix'}) { |
| + | my $unused; |
| + | ($pid, $pid2, $unused) = |
| + | runhttpserver("http", $verbose, "unix", $HTTPUNIXPATH); |
| + | if($pid <= 0) { |
| + | return "failed starting HTTP-unix server"; |
| + | } |
| + | logmsg sprintf("* pid http-unix => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'http-unix'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "dict") { |
| + | if(!$run{'dict'}) { |
| + | ($pid, $pid2, $PORT{"dict"}) = rundictserver($verbose, ""); |
| + | if($pid <= 0) { |
| + | return "failed starting DICT server"; |
| + | } |
| + | logmsg sprintf ("* pid DICT => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'dict'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "smb") { |
| + | if(!$run{'smb'}) { |
| + | ($pid, $pid2, $PORT{"smb"}) = runsmbserver($verbose, ""); |
| + | if($pid <= 0) { |
| + | return "failed starting SMB server"; |
| + | } |
| + | logmsg sprintf ("* pid SMB => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'smb'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "telnet") { |
| + | if(!$run{'telnet'}) { |
| + | ($pid, $pid2, $PORT{"telnet"}) = |
| + | runnegtelnetserver($verbose, ""); |
| + | if($pid <= 0) { |
| + | return "failed starting neg TELNET server"; |
| + | } |
| + | logmsg sprintf ("* pid neg TELNET => %d %d\n", $pid, $pid2) |
| + | if($verbose); |
| + | $run{'telnet'}="$pid $pid2"; |
| + | } |
| + | } |
| + | elsif($what eq "none") { |
| + | logmsg "* starts no server\n" if ($verbose); |
| + | } |
| + | else { |
| + | warn "we don't support a server for $what"; |
| + | return "no server for $what"; |
| + | } |
| + | } |
| + | return 0; |
| + | } |
| + | |
| + | ####################################################################### |
| + | # Stop all running test servers |
| + | # |
| + | sub stopservers { |
| + | my $verb = $_[0]; |
| + | # |
| + | # kill sockfilter processes for all pingpong servers |
| + | # |
| + | killallsockfilters($PIDDIR, $verb); |
| + | # |
| + | # kill all server pids from %run hash clearing them |
| + | # |
| + | my $pidlist; |
| + | foreach my $server (keys %run) { |
| + | if($run{$server}) { |
| + | if($verb) { |
| + | my $prev = 0; |
| + | my $pids = $run{$server}; |
| + | foreach my $pid (split(' ', $pids)) { |
| + | if($pid != $prev) { |
| + | logmsg sprintf("* kill pid for %s => %d\n", |
| + | $server, $pid); |
| + | $prev = $pid; |
| + | } |
| + | } |
| + | } |
| + | $pidlist .= "$run{$server} "; |
| + | $run{$server} = 0; |
| + | } |
| + | $runcert{$server} = 0 if($runcert{$server}); |
| + | } |
| + | killpid($verb, $pidlist); |
| + | # |
| + | # cleanup all server pid files |
| + | # |
| + | my $result = 0; |
| + | foreach my $server (keys %serverpidfile) { |
| + | my $pidfile = $serverpidfile{$server}; |
| + | my $pid = processexists($pidfile); |
| + | if($pid > 0) { |
| + | if($err_unexpected) { |
| + | logmsg "ERROR: "; |
| + | $result = -1; |
| + | } |
| + | else { |
| + | logmsg "Warning: "; |
| + | } |
| + | logmsg "$server server unexpectedly alive\n"; |
| + | killpid($verb, $pid); |
| + | } |
| + | unlink($pidfile) if(-f $pidfile); |
| + | } |
| + | |
| + | return $result; |
| + | } |
| + | |
| + | |
| + | 1; |