From: Vinit Agnihotri Date: Tue, 30 Jan 2024 09:50:20 +0000 (-0800) Subject: ctdb-scripts: Add options to generate smb.conf interfaces include file X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=f42c5802fafa61fe29a0b78c0247eb5a5c386c15 ctdb-scripts: Add options to generate smb.conf interfaces include file Signed-off-by: Vinit Agnihotri Reviewed-by: Martin Schwenke Reviewed-by: Andrew Bartlett --- diff --git a/ctdb/config/events/legacy/50.samba.script b/ctdb/config/events/legacy/50.samba.script index 84600e25024..90de6a3f31b 100755 --- a/ctdb/config/events/legacy/50.samba.script +++ b/ctdb/config/events/legacy/50.samba.script @@ -27,6 +27,27 @@ load_script_options ctdb_setup_state_dir "service" "$service_name" +generate_smb_interfaces_config() +{ + get_public_ifaces + pub_iface_list=$public_ifaces + public_ifaces="" + for iface in $pub_iface_list; + do + public_ifaces="$public_ifaces \"$iface;options=dynamic\"" + done + + if [ -n "$CTDB_SAMBA_INTERFACES_EXTRA" ]; then + public_ifaces="$public_ifaces $CTDB_SAMBA_INTERFACES_EXTRA" + fi + public_ifaces=$(echo "$public_ifaces" | xargs -n 1 | sort -u) + +cat < "$CTDB_SAMBA_INTERFACES_FILE" + bind interfaces only = yes + interfaces = lo $public_ifaces +EOT +} + service_start() { # make sure samba is not already started @@ -36,6 +57,9 @@ service_start() # make absolutely sure samba is dead killall -q -9 smbd } + if [ -n "$CTDB_SAMBA_INTERFACES_FILE" ]; then + generate_smb_interfaces_config + fi # start Samba service. Start it reniced, as under very heavy load # the number of smbd processes will mean that it leaves few cycles # for anything else diff --git a/ctdb/doc/ctdb-script.options.5.xml b/ctdb/doc/ctdb-script.options.5.xml index ef3ad416d0d..ffe4c3abd62 100644 --- a/ctdb/doc/ctdb-script.options.5.xml +++ b/ctdb/doc/ctdb-script.options.5.xml @@ -691,6 +691,51 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000 + + + CTDB_SAMBA_INTERFACES_FILE=FILENAME + + + + Generates FILENAME, containing an smb.conf snippet with + an interfaces setting that includes interfaces for + configured CTDB public IP addresses. This file then + needs to be explicitly included in smb.conf. + + + For example, if public IP addresses are defined on + interfaces eth0 and eth1, and this is set to + /etc/samba/interfaces.conf, then + that file will contain the following before smbd is + started: + + + bind interfaces only = yes + interfaces = lo eth0 eth1 + + + This can be useful for limiting the interfaces used by + SMB multichannel. + + + Default is to not generate a file. + + + + + + + CTDB_SAMBA_INTERFACES_EXTRA=INTERFACE-LIST + + + + A space separated list to provide additional interfaces to bind. + + + Default is empty - no extra interfaces are added. + + +