The branch, master has been updated
via 249e77e24d8 bootstrap: Update Fedora to version 43
via 3c6cc8e0485 third_party: Update socket_wrapper to version 1.5.2
via 6b4a372fdba python:tests: Fix ProcessPoolExecutor with Python 3.14
from f8892391526 libcli/auth: Zero out password in smbencrypt.c
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 249e77e24d88b3c8a9f0d9ef8e139594aa841fa6
Author: Andreas Schneider <[email protected]>
Date: Thu Oct 30 16:24:10 2025 +0100
bootstrap: Update Fedora to version 43
Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Alexander Bokovoy <[email protected]>
Autobuild-User(master): Andreas Schneider <[email protected]>
Autobuild-Date(master): Tue Dec 9 13:58:12 UTC 2025 on atb-devel-224
commit 3c6cc8e04858de56c69fad920ca738254031c57c
Author: Andreas Schneider <[email protected]>
Date: Mon Dec 8 15:14:47 2025 +0100
third_party: Update socket_wrapper to version 1.5.2
Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Alexander Bokovoy <[email protected]>
commit 6b4a372fdbae8e26fa3016ca301b9253828a1645
Author: Andreas Schneider <[email protected]>
Date: Tue Dec 9 10:35:25 2025 +0100
python:tests: Fix ProcessPoolExecutor with Python 3.14
REASON: Exception: Exception: Traceback (most recent call last):
File
"/home/asn/workspace/prj/oss/samba/asn-fix/bin/python/samba/tests/krb5/lockout_tests.py",
line 858, in test_lockout_transaction_bad_pwd_samr_aes
self.do_lockout_transaction(connect_samr_aes, correct_pw=False)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/home/asn/workspace/prj/oss/samba/asn-fix/bin/python/samba/tests/krb5/lockout_tests.py",
line 990, in do_lockout_transaction
connect_future = executor.submit(
connect_fn,
...<7 lines>...
workstation=user_creds.get_workstation(),
dn=str(user_dn))
File "/usr/lib64/python3.14/concurrent/futures/process.py", line 816, in
submit
self._adjust_process_count()
~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib64/python3.14/concurrent/futures/process.py", line 775, in
_adjust_process_count
self._spawn_process()
~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib64/python3.14/concurrent/futures/process.py", line 793, in
_spawn_process
p.start()
~~~~~~~^^
File "/usr/lib64/python3.14/multiprocessing/process.py", line 121, in
start
self._popen = self._Popen(self)
~~~~~~~~~~~^^^^^^
File "/usr/lib64/python3.14/multiprocessing/context.py", line 300, in
_Popen
return Popen(process_obj)
File "/usr/lib64/python3.14/multiprocessing/popen_forkserver.py", line
35, in __init__
super().__init__(process_obj)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/usr/lib64/python3.14/multiprocessing/popen_fork.py", line 20, in
__init__
self._launch(process_obj)
~~~~~~~~~~~~^^^^^^^^^^^^^
File "/usr/lib64/python3.14/multiprocessing/popen_forkserver.py", line
42, in _launch
prep_data = spawn.get_preparation_data(process_obj._name)
File "/usr/lib64/python3.14/multiprocessing/spawn.py", line 164, in
get_preparation_data
_check_not_importing_main()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib64/python3.14/multiprocessing/spawn.py", line 140, in
_check_not_importing_main
raise RuntimeError('''
...<16 lines>...
''')
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
To fix this issue, refer to the "Safe importing of main module"
section in https://docs.python.org/3/library/multiprocessing.html
In Python 3.14, the default multiprocessing start method changed from fork
to
forkserver/spawn. When using ProcessPoolExecutor, the code needs to
either:
1. Explicitly set the start method to fork (the simplest fix for this case)
2. Or ensure proper if __name__ == '__main__': guards (not practical for
test
code run by a test framework)
The fix is to explicitly use the fork start method when creating the
ProcessPoolExecutor. This can be done by passing a mp_context parameter:
Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Alexander Bokovoy <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
.gitlab-ci-main.yml | 16 +-
bootstrap/.gitlab-ci.yml | 2 +-
bootstrap/config.py | 6 +-
bootstrap/generated-dists/Vagrantfile | 10 +-
bootstrap/generated-dists/fedora42/Dockerfile | 29 --
.../{debian11 => fedora43}/Dockerfile | 2 +-
.../{fedora42 => fedora43}/bootstrap.sh | 0
.../{fedora42 => fedora43}/locale.sh | 0
.../{fedora42 => fedora43}/packages.yml | 0
bootstrap/sha1sum.txt | 2 +-
buildtools/wafsamba/samba_third_party.py | 2 +-
python/samba/tests/docs.py | 15 +-
python/samba/tests/krb5/lockout_tests.py | 17 +-
third_party/socket_wrapper/socket_wrapper.c | 428 +++++++++++++++++----
third_party/socket_wrapper/wscript | 2 +-
15 files changed, 394 insertions(+), 137 deletions(-)
delete mode 100644 bootstrap/generated-dists/fedora42/Dockerfile
copy bootstrap/generated-dists/{debian11 => fedora43}/Dockerfile (90%)
rename bootstrap/generated-dists/{fedora42 => fedora43}/bootstrap.sh (100%)
rename bootstrap/generated-dists/{fedora42 => fedora43}/locale.sh (100%)
rename bootstrap/generated-dists/{fedora42 => fedora43}/packages.yml (100%)
Changeset truncated at 500 lines:
diff --git a/.gitlab-ci-main.yml b/.gitlab-ci-main.yml
index 9934d005e81..c66b343fcad 100644
--- a/.gitlab-ci-main.yml
+++ b/.gitlab-ci-main.yml
@@ -47,7 +47,7 @@ variables:
# Set this to the contents of bootstrap/sha1sum.txt
# which is generated by bootstrap/template.py --render
#
- SAMBA_CI_CONTAINER_TAG: 10d513aa79bd89a7884621fe3db3f77fffcb6217
+ SAMBA_CI_CONTAINER_TAG: 336927a79f09b3eb729c64872bf4eca3e2f6761f
#
# We use the ubuntu2204 image as default as
# it matches what we have on atb-devel-224
@@ -67,7 +67,7 @@ variables:
SAMBA_CI_CONTAINER_IMAGE_opensuse155: opensuse155
SAMBA_CI_CONTAINER_IMAGE_rocky8: rocky8
SAMBA_CI_CONTAINER_IMAGE_centos9s: centos9s
- SAMBA_CI_CONTAINER_IMAGE_fedora42: fedora42
+ SAMBA_CI_CONTAINER_IMAGE_fedora43: fedora43
include:
# The image creation details are specified in a separate file
@@ -269,13 +269,13 @@ samba-def-build:
samba-mit-build:
extends: .shared_template_build_only
variables:
- SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora42}
+ SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora43}
stage: build_first
.needs_samba-mit-build:
extends: .shared_template_test_only
variables:
- SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora42}
+ SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora43}
needs:
- job: samba-mit-build
artifacts: true
@@ -323,7 +323,7 @@ samba:
samba-mitkrb5:
extends: .shared_template
variables:
- SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora42}
+ SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora43}
samba-minimal-smbd:
extends: .shared_template
@@ -395,7 +395,7 @@ samba-addc-mit-4b:
samba-fips:
extends: .shared_template
variables:
- SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora42}
+ SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora43}
samba-codecheck:
extends: .shared_template
@@ -681,10 +681,10 @@ centos9s-samba-o3:
variables:
SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_centos9s}
-fedora42-samba-o3:
+fedora43-samba-o3:
extends: .samba-o3-template
variables:
- SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora42}
+ SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora43}
#
# Keep the samba-o3 sections at the end ...
diff --git a/bootstrap/.gitlab-ci.yml b/bootstrap/.gitlab-ci.yml
index 11b973d9112..cc8ef99b140 100644
--- a/bootstrap/.gitlab-ci.yml
+++ b/bootstrap/.gitlab-ci.yml
@@ -102,7 +102,7 @@ debian11:
debian12:
extends: .build_image_template
-fedora42:
+fedora43:
extends: .build_image_template
debian11-32bit:
diff --git a/bootstrap/config.py b/bootstrap/config.py
index 29a3f322f59..08d60dcc45b 100644
--- a/bootstrap/config.py
+++ b/bootstrap/config.py
@@ -554,9 +554,9 @@ RPM_DISTS = {
'python3-varlink': '', # not available
}
},
- 'fedora42': {
- 'docker_image': 'quay.io/fedora/fedora-minimal:42',
- 'vagrant_box': 'fedora/42-cloud-base',
+ 'fedora43': {
+ 'docker_image': 'quay.io/fedora/fedora-minimal:43',
+ 'vagrant_box': 'fedora/43-cloud-base',
'bootstrap': DNF_BOOTSTRAP,
'replace': {
'lsb-release': 'redhat-lsb',
diff --git a/bootstrap/generated-dists/Vagrantfile
b/bootstrap/generated-dists/Vagrantfile
index 511c670a798..b107d6b2bd4 100644
--- a/bootstrap/generated-dists/Vagrantfile
+++ b/bootstrap/generated-dists/Vagrantfile
@@ -45,11 +45,11 @@ Vagrant.configure("2") do |config|
v.vm.provision :shell, path: "debian12-32bit/locale.sh"
end
- config.vm.define "fedora42" do |v|
- v.vm.box = "fedora/42-cloud-base"
- v.vm.hostname = "fedora42"
- v.vm.provision :shell, path: "fedora42/bootstrap.sh"
- v.vm.provision :shell, path: "fedora42/locale.sh"
+ config.vm.define "fedora43" do |v|
+ v.vm.box = "fedora/43-cloud-base"
+ v.vm.hostname = "fedora43"
+ v.vm.provision :shell, path: "fedora43/bootstrap.sh"
+ v.vm.provision :shell, path: "fedora43/locale.sh"
end
config.vm.define "opensuse155" do |v|
diff --git a/bootstrap/generated-dists/fedora42/Dockerfile
b/bootstrap/generated-dists/fedora42/Dockerfile
deleted file mode 100644
index 18a07776186..00000000000
--- a/bootstrap/generated-dists/fedora42/Dockerfile
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# This file is generated by 'bootstrap/template.py --render'
-# See also bootstrap/config.py
-#
-
-FROM quay.io/fedora/fedora-minimal:42
-
-# pass in with --build-arg while build
-ARG SHA1SUM
-RUN [ -n $SHA1SUM ] && echo $SHA1SUM > /sha1sum.txt
-
-ADD *.sh /tmp/
-# need root permission, do it before USER samba
-RUN /tmp/bootstrap.sh && /tmp/locale.sh
-
-# if ld.gold exists, force link it to ld
-RUN set -x; ! LD_GOLD=$(which ld.gold) || { LD=$(which ld) && ln -sf $LD_GOLD
$LD && test -x $LD && echo "$LD is now $LD_GOLD"; }
-# if ld.mold exists, force link it to ld (prefer mold over gold! ;-)
-RUN set -x; ! LD_MOLD=$(which ld.mold) || { LD=$(which ld) && ln -sf $LD_MOLD
$LD && test -x $LD && echo "$LD is now $LD_MOLD"; }
-
-# make test can not work with root, so we have to create a new user
-RUN useradd -m -U -s /bin/bash samba && \
- mkdir -p /etc/sudoers.d && \
- echo "samba ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/samba
-
-USER samba
-WORKDIR /home/samba
-# samba tests rely on this
-ENV USER=samba LC_ALL=en_US.utf8 LANG=en_US.utf8 LANGUAGE=en_US
\ No newline at end of file
diff --git a/bootstrap/generated-dists/debian11/Dockerfile
b/bootstrap/generated-dists/fedora43/Dockerfile
similarity index 90%
copy from bootstrap/generated-dists/debian11/Dockerfile
copy to bootstrap/generated-dists/fedora43/Dockerfile
index 09123a1ef86..43b146b6949 100644
--- a/bootstrap/generated-dists/debian11/Dockerfile
+++ b/bootstrap/generated-dists/fedora43/Dockerfile
@@ -3,7 +3,7 @@
# See also bootstrap/config.py
#
-FROM debian:11-slim
+FROM quay.io/fedora/fedora-minimal:43
# pass in with --build-arg while build
ARG SHA1SUM
diff --git a/bootstrap/generated-dists/fedora42/bootstrap.sh
b/bootstrap/generated-dists/fedora43/bootstrap.sh
similarity index 100%
rename from bootstrap/generated-dists/fedora42/bootstrap.sh
rename to bootstrap/generated-dists/fedora43/bootstrap.sh
diff --git a/bootstrap/generated-dists/fedora42/locale.sh
b/bootstrap/generated-dists/fedora43/locale.sh
similarity index 100%
rename from bootstrap/generated-dists/fedora42/locale.sh
rename to bootstrap/generated-dists/fedora43/locale.sh
diff --git a/bootstrap/generated-dists/fedora42/packages.yml
b/bootstrap/generated-dists/fedora43/packages.yml
similarity index 100%
rename from bootstrap/generated-dists/fedora42/packages.yml
rename to bootstrap/generated-dists/fedora43/packages.yml
diff --git a/bootstrap/sha1sum.txt b/bootstrap/sha1sum.txt
index fa35a9baedb..a69db3e7659 100644
--- a/bootstrap/sha1sum.txt
+++ b/bootstrap/sha1sum.txt
@@ -1 +1 @@
-10d513aa79bd89a7884621fe3db3f77fffcb6217
+336927a79f09b3eb729c64872bf4eca3e2f6761f
diff --git a/buildtools/wafsamba/samba_third_party.py
b/buildtools/wafsamba/samba_third_party.py
index 425c4545709..4d3b5fdc1f4 100644
--- a/buildtools/wafsamba/samba_third_party.py
+++ b/buildtools/wafsamba/samba_third_party.py
@@ -24,7 +24,7 @@ Build.BuildContext.CHECK_CMOCKA = CHECK_CMOCKA
@conf
def CHECK_SOCKET_WRAPPER(conf):
- return conf.CHECK_BUNDLED_SYSTEM_PKG('socket_wrapper', minversion='1.5.1')
+ return conf.CHECK_BUNDLED_SYSTEM_PKG('socket_wrapper', minversion='1.5.2')
Build.BuildContext.CHECK_SOCKET_WRAPPER = CHECK_SOCKET_WRAPPER
@conf
diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py
index 336299a4fac..e5e358e817a 100644
--- a/python/samba/tests/docs.py
+++ b/python/samba/tests/docs.py
@@ -291,7 +291,10 @@ class SmbDotConfTests(TestCase):
failset = set()
- with
concurrent.futures.ProcessPoolExecutor(max_workers=get_max_worker_count()) as
executor:
+ mp_context = multiprocessing.get_context('fork')
+ with concurrent.futures.ProcessPoolExecutor(
+ max_workers=get_max_worker_count(),
+ mp_context=mp_context) as executor:
result_futures = []
for tuples in self.defaults:
@@ -341,7 +344,10 @@ class SmbDotConfTests(TestCase):
failset = set()
- with
concurrent.futures.ProcessPoolExecutor(max_workers=get_max_worker_count()) as
executor:
+ mp_context = multiprocessing.get_context('fork')
+ with concurrent.futures.ProcessPoolExecutor(
+ max_workers=get_max_worker_count(),
+ mp_context=mp_context) as executor:
result_futures = []
for tuples in self.defaults:
@@ -410,7 +416,10 @@ class SmbDotConfTests(TestCase):
failset = set()
- with
concurrent.futures.ProcessPoolExecutor(max_workers=get_max_worker_count()) as
executor:
+ mp_context = multiprocessing.get_context('fork')
+ with concurrent.futures.ProcessPoolExecutor(
+ max_workers=get_max_worker_count(),
+ mp_context=mp_context) as executor:
result_futures1 = []
result_futures2 = []
diff --git a/python/samba/tests/krb5/lockout_tests.py
b/python/samba/tests/krb5/lockout_tests.py
index e33d9acb4a8..5e909640e0b 100755
--- a/python/samba/tests/krb5/lockout_tests.py
+++ b/python/samba/tests/krb5/lockout_tests.py
@@ -26,6 +26,7 @@ os.environ['PYTHONUNBUFFERED'] = '1'
from concurrent import futures
from enum import Enum
from functools import partial
+import multiprocessing
from multiprocessing import Pipe
import time
@@ -985,7 +986,9 @@ class LockoutTests(KdcTgsBaseTests):
password = password[:-1]
# Prepare to connect to the server.
- with futures.ProcessPoolExecutor(max_workers=1) as executor:
+ mp_context = multiprocessing.get_context('fork')
+ with futures.ProcessPoolExecutor(max_workers=1,
+ mp_context=mp_context) as executor:
our_pipe, their_pipe = Pipe(duplex=True)
connect_future = executor.submit(
connect_fn,
@@ -1099,7 +1102,9 @@ class LockoutTests(KdcTgsBaseTests):
user_dn = ldb.Dn(samdb, str(user_creds.get_dn()))
# Prepare to connect to the server with an invalid password.
- with futures.ProcessPoolExecutor(max_workers=1) as executor:
+ mp_context = multiprocessing.get_context('fork')
+ with futures.ProcessPoolExecutor(max_workers=1,
+ mp_context=mp_context) as executor:
our_pipe, their_pipe = Pipe(duplex=True)
connect_future = executor.submit(
connect_fn,
@@ -1200,7 +1205,9 @@ class LockoutTests(KdcTgsBaseTests):
# simultaneous requests. Only three of those attempts should get
# through before the account is locked out.
num_attempts = self.lockout_threshold + 1
- with futures.ProcessPoolExecutor(max_workers=num_attempts) as executor:
+ mp_context = multiprocessing.get_context('fork')
+ with futures.ProcessPoolExecutor(max_workers=num_attempts,
+ mp_context=mp_context) as executor:
connect_futures = []
our_pipes = []
for i in range(num_attempts):
@@ -1293,7 +1300,9 @@ class LockoutTests(KdcTgsBaseTests):
password = user_creds.get_password()
# Prepare to connect to the server with a valid password.
- with futures.ProcessPoolExecutor(max_workers=1) as executor:
+ mp_context = multiprocessing.get_context('fork')
+ with futures.ProcessPoolExecutor(max_workers=1,
+ mp_context=mp_context) as executor:
our_pipe, their_pipe = Pipe(duplex=True)
connect_future = executor.submit(
connect_fn,
diff --git a/third_party/socket_wrapper/socket_wrapper.c
b/third_party/socket_wrapper/socket_wrapper.c
index bc4000cb7ed..34918ac2144 100644
--- a/third_party/socket_wrapper/socket_wrapper.c
+++ b/third_party/socket_wrapper/socket_wrapper.c
@@ -314,6 +314,16 @@ struct swrap_address {
} sa;
};
+struct swrap_address_ip_only {
+ union {
+ struct sockaddr s;
+ struct sockaddr_in in;
+#ifdef HAVE_IPV6
+ struct sockaddr_in6 in6;
+#endif
+ } sa;
+};
+
static int first_free;
struct socket_info
@@ -323,28 +333,30 @@ struct socket_info
* on any change.
*/
- int family;
+ uint16_t family;
+ uint16_t pktinfo;
int type_flags; /* SOCK_CLOEXEC or SOCK_NONBLOCK */
int type;
int protocol;
int opt_type;
int opt_protocol;
- int bound;
- int bcast;
- int is_server;
- int connected;
- int defer_connect;
- int pktinfo;
- int tcp_nodelay;
- int listening;
int fd_passed;
+ /* Use bitfields for boolean types */
+ unsigned int bound:1;
+ unsigned int bcast:1;
+ unsigned int is_server:1;
+ unsigned int connected:1;
+ unsigned int defer_connect:1;
+ unsigned int tcp_nodelay:1;
+ unsigned int listening:1;
+
/* The unix path so we can unlink it on close() */
struct sockaddr_un un_addr;
- struct swrap_address bindname;
- struct swrap_address myname;
- struct swrap_address peername;
+ struct swrap_address_ip_only bindname;
+ struct swrap_address_ip_only myname;
+ struct swrap_address_ip_only peername;
struct {
unsigned long pck_snd;
@@ -436,6 +448,59 @@ static const char *getprogname(void)
}
#endif /* HAVE_GETPROGNAME */
+static int swrap_debug_level = SWRAP_LOG_ERROR;
+
+static void __socket_wrapper_debug_level_once(void)
+{
+ const char *env = NULL;
+ size_t env_len;
+
+ env = getenv("SOCKET_WRAPPER_DEBUGLEVEL");
+ if (env == NULL) {
+ swrap_debug_level = SWRAP_LOG_ERROR;
+ return;
+ }
+
+ env_len = strlen(env);
+ /* Sanity check: must not be empty and not longer than "warning" */
+ if (env_len == 0 || env_len > 7) {
+ swrap_debug_level = SWRAP_LOG_ERROR;
+ return;
+ }
+
+ /* Check for string values (case-insensitive) */
+ if (strcasecmp(env, "error") == 0) {
+ swrap_debug_level = SWRAP_LOG_ERROR;
+ } else if (strcasecmp(env, "warn") == 0 ||
+ strcasecmp(env, "warning") == 0)
+ {
+ swrap_debug_level = SWRAP_LOG_WARN;
+ } else if (strcasecmp(env, "debug") == 0) {
+ swrap_debug_level = SWRAP_LOG_DEBUG;
+ } else if (strcasecmp(env, "trace") == 0) {
+ swrap_debug_level = SWRAP_LOG_TRACE;
+ } else {
+ /* Numeric value */
+ swrap_debug_level = atoi(env);
+
+ /* Clamp to valid range */
+ if (swrap_debug_level < SWRAP_LOG_ERROR) {
+ swrap_debug_level = SWRAP_LOG_ERROR;
+ } else if (swrap_debug_level > SWRAP_LOG_TRACE) {
+ swrap_debug_level = SWRAP_LOG_TRACE;
+ }
+ }
+}
+
+static unsigned int socket_wrapper_debug_level(void)
+{
+ static pthread_once_t debug_level_once = PTHREAD_ONCE_INIT;
+
+ pthread_once(&debug_level_once, __socket_wrapper_debug_level_once);
+
+ return (unsigned int)swrap_debug_level;
+}
+
static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *func, const char
*format, ...) PRINTF_ATTRIBUTE(3, 4);
# define SWRAP_LOG(dbglvl, ...) swrap_log((dbglvl), __func__, __VA_ARGS__)
@@ -445,15 +510,11 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl,
{
char buffer[1024];
va_list va;
- const char *d;
- unsigned int lvl = 0;
+ unsigned int lvl;
const char *prefix = "SWRAP";
const char *progname = getprogname();
- d = getenv("SOCKET_WRAPPER_DEBUGLEVEL");
- if (d != NULL) {
- lvl = atoi(d);
- }
+ lvl = socket_wrapper_debug_level();
if (lvl < dbglvl) {
return;
@@ -491,6 +552,146 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl,
buffer);
}
+/*********************************************************
+ * HELPER FUNCTIONS
+ **********************************************************/
+
+/*
+ * Get the socklen for an address family
+ */
+static inline socklen_t swrap_address_ip_only_socklen(sa_family_t family)
+{
+ switch (family) {
+ case AF_UNSPEC: /* AF_UNSPEC indicates uninitialized/empty address */
+ return 0;
+ case AF_INET:
+ return sizeof(struct sockaddr_in);
+#ifdef HAVE_IPV6
+ case AF_INET6:
+ return sizeof(struct sockaddr_in6);
+#endif
+ default:
+ SWRAP_LOG(SWRAP_LOG_ERROR,
+ "BUG: unexpected address family %d",
+ family);
+ abort();
+ }
+
+ return 0; /* Never reached */
+}
+
+/*
+ * Get the socklen from a swrap_address_ip_only struct
+ */
+static inline socklen_t swrap_address_ip_only_len(
+ const struct swrap_address_ip_only *addr)
+{
+ return swrap_address_ip_only_socklen(addr->sa.s.sa_family);
+}
+
+/*
+ * Copy a sockaddr to swrap_address_ip_only, using the actual address size
+ * based on the address family.
+ */
+static inline void swrap_address_ip_only_from_sockaddr(
+ struct swrap_address_ip_only *dest,
+ const struct sockaddr *src,
+ socklen_t addrlen)
+{
+ socklen_t copy_len = swrap_address_ip_only_socklen(src->sa_family);
+
+ /* AF_UNSPEC means empty/unbind - zero the entire struct */
+ if (copy_len == 0) {
+ memset(&dest->sa, 0, sizeof(dest->sa));
+ return;
+ }
+
--
Samba Shared Repository