Changeset: 1407bc4f0402 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1407bc4f0402
Modified Files:
        MonetDB.spec
Branch: default
Log Message:

Merge with Dec2023 branch.


diffs (truncated from 3531 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -143,13 +143,6 @@ BuildRequires: python3-numpy
 %endif
 %if %{with rintegration}
 BuildRequires: pkgconfig(libR)
-%if (0%{?fedora} == 32)
-# work around a packaging bug on Fedora 32 (18 Nov 2020)
-# problem is things like:
-# file /etc/texlive/web2c/updmap.cfg conflicts between attempted installs of 
texlive-tetex-7:20190410-12.fc32.noarch and 
texlive-texlive-scripts-7:20200327-16.fc32.noarch
-# texlive-tetex is obsoleted by texlive-obsolete
-BuildRequires: texlive-obsolete
-%endif
 %endif
 # optional packages:
 # BuildRequires: pkgconfig(cmocka)      # -DWITH_CMOCKA=ON
@@ -329,6 +322,7 @@ This package contains the files needed t
 %dir %{_includedir}/monetdb
 %{_libdir}/libmapi.so
 %{_includedir}/monetdb/mapi*.h
+%{_includedir}/monetdb/msettings.h
 %{_libdir}/pkgconfig/monetdb-mapi.pc
 
 %package client-odbc
diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py
--- a/NT/mksqlwxs.py
+++ b/NT/mksqlwxs.py
@@ -188,6 +188,8 @@ def main():
               sorted([r'include\monetdb\{}'.format(x) for x in filter(lambda 
x: (x.startswith('gdk') or x.startswith('monet') or x.startswith('mal') or 
x.startswith('sql') or x.startswith('rel') or x.startswith('store') or 
x.startswith('exception') or x.startswith('opt_backend')) and x.endswith('.h'), 
os.listdir(os.path.join(sys.argv[3], 'include', 'monetdb')))] +
                      [r'include\monetdb\copybinary.h',
                       r'include\monetdb\mapi.h',
+                      r'include\monetdb\mapi_querytype.h',
+                      r'include\monetdb\msettings.h',
                       r'include\monetdb\matomic.h',
                       r'include\monetdb\mel.h',
                       r'include\monetdb\mstring.h',
diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -48484,16 +48484,6 @@ pattern optimizer.inline(X_0:str, X_1:st
 OPTwrapper;
 Expand inline functions
 optimizer
-macro
-pattern optimizer.macro(X_0:str, X_1:str):void 
-OPTmacro;
-Inline the code of the target function.
-optimizer
-macro
-pattern optimizer.macro(X_0:str, X_1:str, X_2:str, X_3:str):void 
-OPTmacro;
-Inline a target function used in a specific function.
-optimizer
 matpack
 pattern optimizer.matpack():str 
 OPTwrapper;
@@ -48549,16 +48539,6 @@ pattern optimizer.optimize(X_0:str, X_1:
 QOToptimize;
 Optimize a specific operation
 optimizer
-orcam
-pattern optimizer.orcam(X_0:str, X_1:str):void 
-OPTorcam;
-Inverse macro processor for current function
-optimizer
-orcam
-pattern optimizer.orcam(X_0:str, X_1:str, X_2:str, X_3:str):void 
-OPTorcam;
-Inverse macro, find pattern and replace with a function call.
-optimizer
 postfix
 pattern optimizer.postfix():str 
 OPTwrapper;
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -36914,16 +36914,6 @@ pattern optimizer.inline(X_0:str, X_1:st
 OPTwrapper;
 Expand inline functions
 optimizer
-macro
-pattern optimizer.macro(X_0:str, X_1:str):void 
-OPTmacro;
-Inline the code of the target function.
-optimizer
-macro
-pattern optimizer.macro(X_0:str, X_1:str, X_2:str, X_3:str):void 
-OPTmacro;
-Inline a target function used in a specific function.
-optimizer
 matpack
 pattern optimizer.matpack():str 
 OPTwrapper;
@@ -36979,16 +36969,6 @@ pattern optimizer.optimize(X_0:str, X_1:
 QOToptimize;
 Optimize a specific operation
 optimizer
-orcam
-pattern optimizer.orcam(X_0:str, X_1:str):void 
-OPTorcam;
-Inverse macro processor for current function
-optimizer
-orcam
-pattern optimizer.orcam(X_0:str, X_1:str, X_2:str, X_3:str):void 
-OPTorcam;
-Inverse macro, find pattern and replace with a function call.
-optimizer
 postfix
 pattern optimizer.postfix():str 
 OPTwrapper;
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -653,6 +653,7 @@ int64_t mapi_get_querytime(MapiHdl hdl) 
 int mapi_get_querytype(MapiHdl hdl) __attribute__((__nonnull__(1)));
 int64_t mapi_get_row_count(MapiHdl hdl) __attribute__((__nonnull__(1)));
 int mapi_get_scale(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
+msettings *mapi_get_settings(Mapi mid) __attribute__((__nonnull__(1)));
 int64_t mapi_get_sqloptimizertime(MapiHdl hdl) __attribute__((__nonnull__(1)));
 char *mapi_get_table(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
 int mapi_get_tableid(MapiHdl hdl) __attribute__((__nonnull__(1)));
@@ -700,6 +701,7 @@ MapiMsg mapi_set_time_zone(Mapi mid, int
 MapiMsg mapi_set_timeout(Mapi mid, unsigned int timeout, bool (*callback)(void 
*), void *callback_data) __attribute__((__nonnull__(1)));
 void mapi_setfilecallback(Mapi mid, char *(*getfunc)(void *priv, const char 
*filename, bool binary, uint64_t offset, size_t *size), char *(*putfunc)(void 
*priv, const char *filename, const void *data, size_t size), void *priv) 
__attribute__((__nonnull__(1)));
 void mapi_setfilecallback2(Mapi mid, char *(*getfunc)(void *priv, const char 
*filename, bool binary, uint64_t offset, size_t *size), char *(*putfunc)(void 
*priv, const char *filename, bool binary, const void *data, size_t size), void 
*priv) __attribute__((__nonnull__(1)));
+Mapi mapi_settings(msettings *settings) __attribute__((__nonnull__(1)));
 int mapi_split_line(MapiHdl hdl) __attribute__((__nonnull__(1)));
 MapiMsg mapi_store_field(MapiHdl hdl, int fnr, int outtype, void *outparam) 
__attribute__((__nonnull__(1)));
 MapiMsg mapi_timeout(Mapi mid, unsigned int time) 
__attribute__((__nonnull__(1)));
diff --git a/clients/mapilib/CMakeLists.txt b/clients/mapilib/CMakeLists.txt
--- a/clients/mapilib/CMakeLists.txt
+++ b/clients/mapilib/CMakeLists.txt
@@ -32,7 +32,8 @@ target_sources(mapi
   
$<BUILD_INTERFACE:$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/mapi_querytype.h>
   $<BUILD_INTERFACE:$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/msettings.h>
   
$<INSTALL_INTERFACE:$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb>/mapi.h>
-  
$<INSTALL_INTERFACE:$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb>/mapi_querytype.h>)
+  
$<INSTALL_INTERFACE:$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb>/mapi_querytype.h>
+  
$<INSTALL_INTERFACE:$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb>/msettings.h>)
 
 target_include_directories(mapi
   PUBLIC
@@ -58,7 +59,7 @@ set_target_properties(mapi
   PROPERTIES
   VERSION ${MAPI_VERSION}
   SOVERSION ${MAPI_VERSION_MAJOR}
-  PUBLIC_HEADER "mapi.h;mapi_querytype.h")
+  PUBLIC_HEADER "mapi.h;mapi_querytype.h;msettings.h")
 
 if (NOT WIN32)
   configure_file(monetdb-mapi.pc.in
diff --git a/clients/mapilib/Tests/systemcertificates.py 
b/clients/mapilib/Tests/systemcertificates.py
--- a/clients/mapilib/Tests/systemcertificates.py
+++ b/clients/mapilib/Tests/systemcertificates.py
@@ -7,39 +7,134 @@
 # Copyright 1997 - July 2008 CWI, August 2008 - 2023 MonetDB B.V.
 
 
-import subprocess
-import sys
-
 # Test that certificates from the system trust store are used when no explicit
 # certificate is given.
 #
-# # If all goes well, this will give a protocol error (MAPI != HTTP),
-# not a TLS error
+# This test tries to connect to an existing TLS+MAPI server that has a publicly
+# trusted certificate. This needs to be configured externally through
+# the environment variables TLSTEST_URL and TLSTEST_ALTURL.
+#
+# These must point to the same server so they receive the same certificate.
+# However, the host name in TLSTEST_URL must match the certificate while the
+# hostname in TLSTEST_ALT doesn't match.
+
+
+import logging
+import os
+import shlex
+import socket
+import subprocess
+import ssl
+import sys
+import urllib
+from urllib.parse import urlparse
+
+level = logging.WARNING
+# if sys.platform == 'win32':
+#     level=logging.DEBUG
+if '-v' in sys.argv:
+    level = logging.DEBUG
+# level = logging.DEBUG
+logging.basicConfig(level=level)
+
+logger = logging.root
 
-# Ideally we'd use www.monetdb.org but, but at the time of writing 
www.monetdb.org
-# only returns an error after a 20 second time out.
-#
-# python.org on the other hand uses a CDN which kicks us out instantly.
-HOST = 'python.org'
+#####################################################################
+# Look for the URL configuration variables, exit if not present
+
+def getvar(name):
+    value = os.environ.get(name)
+    if value:
+        logger.debug(f"Environment variable {name}={value}")
+        return value
+    else:
+        logger.debug(f"Environment variable {name} is not set, exiting early")
+        exit(0)
+
+url = getvar('TLSTEST_URL')
+alturl = getvar('TLSTEST_ALTURL')
+
+
+#####################################################################
+# Before trying with mclient, connect directly to see if the server is
+# up and behaves the way we need for this test
+
+def try_connect(url, check_hostname, expected_error):
+    logger.info(f"Attempting to connect to {url}, 
check_hostname={check_hostname}")
+    parsed = urlparse(url)
+    assert parsed.scheme == 'monetdbs', f'Expected scheme monetdbs, not 
{parsed.scheme}'
+
+    host = parsed.hostname
+    port = parsed.port or 50000
+    logger.debug(f"Connecting to host {host!r} port {port!r}")
+
+    with socket.create_connection((host, port)) as sock:
+        logger.debug(f"Connection established")
 
-# Run mclient
-cmd = ['mclient', '-L-', '-d', f"monetdbs://{HOST}:443/demo"]
-proc = subprocess.run(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
-if proc.returncode != 2:
-    msg = str(proc.stderr, 'utf-8')
-    print(f"mclient is supposed to exit with status 2, not 
{proc.returncode}.\n--- stderr ---\n{msg}\n---end stderr ---", file=sys.stderr)
-    exit(1)
+        logger.debug(f"Verifying TLS")
+        ctx = ssl.create_default_context()
+        ctx.check_hostname = check_hostname
+        try:
+            ssl_connection = ctx.wrap_socket(sock, server_hostname=host)
+            # if we get here it succeeded
+            if expected_error:
+                raise Exception(f"Verification succeeded unexpectedly")
+            else:
+                logger.debug(f"Verification succeeded as expected")
+            logger.debug("Closing")
+            ssl_connection.close()
+        except ssl.SSLError as e:
+            if expected_error and expected_error in str(e):
+                logger.debug(f"Verification failed as expected: {e}")
+            elif expected_error:
+                logger.error(f"Verification failed but the error did not match 
{expected_error!r}: {e}")
+            else:
+                logger.error(f"Verification failed unexpectedly: {e}")
+                raise e
+
+
+# both urls should be reachable and present a TLS certificate
+try_connect(url, check_hostname=False, expected_error=None)
+try_connect(alturl, check_hostname=False, expected_error=None)
+
+# url should have the expected hostname so this should succeed
+try_connect(url, check_hostname=True, expected_error=None)
+
+# alturl should have a hostname that makes the verification fail
+try_connect(alturl, check_hostname=True, expected_error='Hostname mismatch')
+
 
-# After the TLS handshake succeeds we expect the server to send something like
-# 'HTTP/1.1 400 Bad Request' because we're sending \x00\x00 instead of an HTTP
-# request. libmapi will interpret the first two bytes 'H' and 'T' as an invalid
-# block header.
-#
-# In ASCII,  'H' + 256 * 'T'  ==  72 + 256 * 84  ==  21576.
-tls_works_but_mapi_fails = b'21576' in proc.stderr
+#####################################################################
+# The URLs and the server are configured correctly.
+# Check if mclient notices the wrong host name in alturl.
+
+def run_mclient(url, should_pass):
+    cmd = ['mclient', '-L-', '-s', 'SELECT 42', '-d', url]
+    display_cmd = ' '.join(shlex.quote(w) for w in cmd)
+    logger.info(f"Running {display_cmd}")
+    proc = subprocess.run(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+
+    status = proc.returncode
+    logger.debug(f"Mclient exited with status {status}")
 
-if not tls_works_but_mapi_fails:
-    msg = str(proc.stderr, 'utf-8')
-    print(f"Expected mclient to print an error message containing the number 
21576, got:\n--- stderr ---\n{msg}\n---end stderr ---", file=sys.stderr)
-    exit(1)
+    err = proc.stderr
+    logger.debug('--- stderr ---')
+    try:
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to