From 605217e96f9c4b99fe66ca8c610cdf58e7797947 Mon Sep 17 00:00:00 2001 From: Adolf Belka Date: Wed, 10 Jan 2024 14:30:20 +0100 Subject: [PATCH 01/11] wsdd: Install wsdd - fixes bug13445 - lfs and toorfile created for wsdd - wsdd added to make.sh script - created install/update/uninstall scripts for wsdd that create an unpriveleged user and group. - initscript created for wsdd. As wsdd is a python3 script, when it is run as a daemon the pidof command does not find any pid for wsdd. So a directory/file for a pid file was created. This is then passed to the loadproc and killproc commands. After the loadproc command has been created the pid is extracted from the ps aux command and put into the pid file. This then works when running the killproc command for it to know what to go and stop. The statusproc command does not have the ability to feed in the pid from a pid file and so it fails to find a running wsdd as it uses the pidof command. Code was added to the status section of the initscript to check if the pid file exists and if so to print the same command as used with the statusproc command, and also the same wording if the pid file does not exist because wsdd is not running. - info from the ethernet/settings file is used to identify if only green0 is available or if blue0 is also used and based on this the appropriate interface commands are added to the wsdd command. - wsdd is also set up to run in a chroot - Has been tested on my vm testbed, initially by editing the files on the vm clone. After everything confiremd to be working, the build was successfully carried out and the .ipfire package was copied to a new vm clone installed and shown to perform as expected. This test only confirms that wsdd is correctly installed and started. Shutsdown and restarts on reboot successfully. Confirmed from the ps aux info that wsdd has been started with the correct options. Thge testing can not evaluate if wsdd enables windows systems newer than version 7 top be able to detect the samba shares as I have no windows systems. Fixes: Bug13445 Tested-by: Adolf Belka Signed-off-by: Adolf Belka --- config/rootfiles/packages/wsdd | 2 + lfs/wsdd | 89 ++++++++++++++++++++++++++++++++++ make.sh | 1 + src/initscripts/packages/wsdd | 63 ++++++++++++++++++++++++ src/paks/wsdd/install.sh | 40 +++++++++++++++ src/paks/wsdd/uninstall.sh | 30 ++++++++++++ src/paks/wsdd/update.sh | 27 +++++++++++ 7 files changed, 252 insertions(+) create mode 100644 config/rootfiles/packages/wsdd create mode 100644 lfs/wsdd create mode 100644 src/initscripts/packages/wsdd create mode 100644 src/paks/wsdd/install.sh create mode 100644 src/paks/wsdd/uninstall.sh create mode 100644 src/paks/wsdd/update.sh diff --git a/config/rootfiles/packages/wsdd b/config/rootfiles/packages/wsdd new file mode 100644 index 000000000..ce225043a --- /dev/null +++ b/config/rootfiles/packages/wsdd @@ -0,0 +1,2 @@ +etc/rc.d/init.d/wsdd +usr/bin/wsdd diff --git a/lfs/wsdd b/lfs/wsdd new file mode 100644 index 000000000..aa65e47ef --- /dev/null +++ b/lfs/wsdd @@ -0,0 +1,89 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2024 IPFire Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 0.7.1 +SUMMARY = A Web Service Discovery host daemon. + +THISAPP = wsdd-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) +PROG = wsdd +PAK_VER = 1 + +DEPS = + +SERVICES = wsdd + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_BLAKE2 = ce43022c3bd9f7ff1fd7169ac0d5ab6b2ff78d35c221c05b2e20908a5772d563ab2aca571d4e6ae48a55d19d4adcb9cde60f720ae47af8ee950198224fcfdb26 + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +b2 : $(subst %,%_BLAKE2,$(objects)) + +dist: + @$(PAK) + +############################################################################### +# Downloading, checking, b2sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_BLAKE2,$(objects)) : + @$(B2SUM) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && cp src/wsdd.py /usr/bin/wsdd + + #install initscripts + $(call INSTALL_INITSCRIPTS,$(SERVICES)) + + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/make.sh b/make.sh index 06e09c9a3..5af3dedc3 100755 --- a/make.sh +++ b/make.sh @@ -1699,6 +1699,7 @@ buildipfire() { lfsmake2 perl-MIME-Base32 lfsmake2 perl-URI-Encode lfsmake2 rsnapshot + lfsmake2 wsdd # Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd new file mode 100644 index 000000000..c5207f872 --- /dev/null +++ b/src/initscripts/packages/wsdd @@ -0,0 +1,63 @@ +#!/bin/sh +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2024 IPFire Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +. /etc/sysconfig/rc +. $rc_functions + +eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) + +# Create chroot directory for wsdd +mkdir -p /var/run/wsdd + +INTERFACES="-i ${GREEN_DEV}" + if [ -n "${BLUE_DEV}" ]; then + INTERFACES="${INTERFACES} -i ${BLUE_DEV}" + fi +WSDD_WORKGROUP="-w $(/usr/bin/testparm -s --parameter-name workgroup 2>/dev/null)" +WSDD_USER="-u wsdd:wsdd" +WSDD_CHROOT="-c /var/run/wsdd" + +case "$1" in + start) + boot_mesg "Starting wsdd daemon..." + loadproc -b /usr/bin/wsdd -4 ${WSDD_USER} ${INTERFACES} ${WSDD_WORKGROUP} ${WSDD_CHROOT} + sleep 1 + echo $(ps aux | grep "/usr/bin/wsdd" | grep -v grep | awk '{print $2}') > /var/run/wsdd/pid + ;; + stop) + boot_mesg "Stopping wsdd daemon..." + killproc -p /var/run/wsdd/pid /usr/bin/wsdd + ;; + status) + WSDD_PID=$(ps aux | grep "/usr/bin/wsdd" | grep -v grep | awk '{print $2}') + if [ -n "${WSDD_PID}" ]; then + echo -e "\\033[1;36m /usr/bin/wsdd is running with Process"\ + "ID(s) $WSDD_PID.\\033[0;39m" + else + echo -e "\\033[1;36m /usr/bin/wsdd is not running.\\033[0;39m" + fi + ;; + *) + echo "Usage: $0 (start|stop|status)" + exit 1 + ;; +esac + diff --git a/src/paks/wsdd/install.sh b/src/paks/wsdd/install.sh new file mode 100644 index 000000000..181b84eb9 --- /dev/null +++ b/src/paks/wsdd/install.sh @@ -0,0 +1,40 @@ +#!/bin/bash +############################################################################ +# # +# This file is part of the IPFire Firewall. # +# # +# IPFire is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# IPFire is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPFire; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Copyright (C) 2007 IPFire-Team . # +# # +############################################################################ +# +. /opt/pakfire/lib/functions.sh + +# If the wsdd user does not exist yet, then create it and add to wsdd group. +if ! getent user wsdd >/dev/null; then + useradd -r -U -d / -s /bin/false -c "wsdd user" wsdd + usermod -a -G wsdd wsdd +fi + +extract_files +restore_backup ${NAME} + +# Create startlinks +ln -sf ../init.d/wsdd /etc/rc.d/rc0.d/K35wsdd +ln -sf ../init.d/wsdd /etc/rc.d/rc3.d/S65wsdd +ln -sf ../init.d/wsdd /etc/rc.d/rc6.d/K35wsdd +start_service ${NAME} +exit 0 diff --git a/src/paks/wsdd/uninstall.sh b/src/paks/wsdd/uninstall.sh new file mode 100644 index 000000000..4c52ee281 --- /dev/null +++ b/src/paks/wsdd/uninstall.sh @@ -0,0 +1,30 @@ +#!/bin/bash +############################################################################ +# # +# This file is part of the IPFire Firewall. # +# # +# IPFire is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# IPFire is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPFire; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Copyright (C) 2007 IPFire-Team . # +# # +############################################################################ +# +. /opt/pakfire/lib/functions.sh +stop_service ${NAME} +make_backup ${NAME} +remove_files +# Remove all start links. +rm -rf /etc/rc.d/rc*.d/*wsdd +exit 0 diff --git a/src/paks/wsdd/update.sh b/src/paks/wsdd/update.sh new file mode 100644 index 000000000..99776659c --- /dev/null +++ b/src/paks/wsdd/update.sh @@ -0,0 +1,27 @@ +#!/bin/bash +############################################################################ +# # +# This file is part of the IPFire Firewall. # +# # +# IPFire is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# IPFire is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPFire; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Copyright (C) 2007-2020 IPFire-Team . # +# # +############################################################################ +# +. /opt/pakfire/lib/functions.sh +extract_backup_includes +./uninstall.sh +./install.sh From 5cf3bc3507b841078d25852672931e8f49d59bb6 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 16:02:29 +0100 Subject: [PATCH 02/11] wsdd: Simplify starting/stopping and checking wsdd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weismüller --- src/initscripts/packages/wsdd | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd index c5207f872..274d7cd5a 100644 --- a/src/initscripts/packages/wsdd +++ b/src/initscripts/packages/wsdd @@ -27,6 +27,8 @@ eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) # Create chroot directory for wsdd mkdir -p /var/run/wsdd +PIDFILE="/var/run/wsdd.pid" + INTERFACES="-i ${GREEN_DEV}" if [ -n "${BLUE_DEV}" ]; then INTERFACES="${INTERFACES} -i ${BLUE_DEV}" @@ -38,22 +40,14 @@ WSDD_CHROOT="-c /var/run/wsdd" case "$1" in start) boot_mesg "Starting wsdd daemon..." - loadproc -b /usr/bin/wsdd -4 ${WSDD_USER} ${INTERFACES} ${WSDD_WORKGROUP} ${WSDD_CHROOT} - sleep 1 - echo $(ps aux | grep "/usr/bin/wsdd" | grep -v grep | awk '{print $2}') > /var/run/wsdd/pid + loadproc -b -p "${PIDFILE}" /usr/bin/wsdd -4 ${WSDD_USER} ${INTERFACES} ${WSDD_WORKGROUP} ${WSDD_CHROOT} ;; stop) boot_mesg "Stopping wsdd daemon..." - killproc -p /var/run/wsdd/pid /usr/bin/wsdd + killproc -p "${PIDFILE}" /usr/bin/wsdd ;; status) - WSDD_PID=$(ps aux | grep "/usr/bin/wsdd" | grep -v grep | awk '{print $2}') - if [ -n "${WSDD_PID}" ]; then - echo -e "\\033[1;36m /usr/bin/wsdd is running with Process"\ - "ID(s) $WSDD_PID.\\033[0;39m" - else - echo -e "\\033[1;36m /usr/bin/wsdd is not running.\\033[0;39m" - fi + statusproc /usr/bin/wsdd ;; *) echo "Usage: $0 (start|stop|status)" From b95afd6aca51723390d4cc14a9607e9333bca4b4 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 16:05:29 +0100 Subject: [PATCH 03/11] wsdd: Reindent initscript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No spaces. Just tabs. Signed-off-by: Daniel Weismüller --- src/initscripts/packages/wsdd | 37 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd index 274d7cd5a..77d0e59e5 100644 --- a/src/initscripts/packages/wsdd +++ b/src/initscripts/packages/wsdd @@ -30,28 +30,31 @@ mkdir -p /var/run/wsdd PIDFILE="/var/run/wsdd.pid" INTERFACES="-i ${GREEN_DEV}" - if [ -n "${BLUE_DEV}" ]; then - INTERFACES="${INTERFACES} -i ${BLUE_DEV}" - fi +if [ -n "${BLUE_DEV}" ]; then + INTERFACES="${INTERFACES} -i ${BLUE_DEV}" +fi WSDD_WORKGROUP="-w $(/usr/bin/testparm -s --parameter-name workgroup 2>/dev/null)" WSDD_USER="-u wsdd:wsdd" WSDD_CHROOT="-c /var/run/wsdd" case "$1" in - start) - boot_mesg "Starting wsdd daemon..." - loadproc -b -p "${PIDFILE}" /usr/bin/wsdd -4 ${WSDD_USER} ${INTERFACES} ${WSDD_WORKGROUP} ${WSDD_CHROOT} - ;; - stop) - boot_mesg "Stopping wsdd daemon..." - killproc -p "${PIDFILE}" /usr/bin/wsdd - ;; - status) + start) + boot_mesg "Starting wsdd daemon..." + loadproc -b -p "${PIDFILE}" /usr/bin/wsdd -4 ${WSDD_USER} ${INTERFACES} ${WSDD_WORKGROUP} ${WSDD_CHROOT} + ;; + + stop) + boot_mesg "Stopping wsdd daemon..." + killproc -p "${PIDFILE}" /usr/bin/wsdd + ;; + + status) statusproc /usr/bin/wsdd - ;; - *) - echo "Usage: $0 (start|stop|status)" - exit 1 - ;; + ;; + + *) + echo "Usage: $0 (start|stop|status)" + exit 1 + ;; esac From cf70bd231a1ad7ba9507514722ce7f10f92af388 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 16:07:04 +0100 Subject: [PATCH 04/11] wsdd: Use long options for clarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weismüller --- src/initscripts/packages/wsdd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd index 77d0e59e5..88fe85ae2 100644 --- a/src/initscripts/packages/wsdd +++ b/src/initscripts/packages/wsdd @@ -29,18 +29,18 @@ mkdir -p /var/run/wsdd PIDFILE="/var/run/wsdd.pid" -INTERFACES="-i ${GREEN_DEV}" +INTERFACES="--interface ${GREEN_DEV}" if [ -n "${BLUE_DEV}" ]; then - INTERFACES="${INTERFACES} -i ${BLUE_DEV}" + INTERFACES="${INTERFACES} --interface ${BLUE_DEV}" fi -WSDD_WORKGROUP="-w $(/usr/bin/testparm -s --parameter-name workgroup 2>/dev/null)" -WSDD_USER="-u wsdd:wsdd" -WSDD_CHROOT="-c /var/run/wsdd" +WSDD_WORKGROUP="--workgroup $(/usr/bin/testparm -s --parameter-name workgroup 2>/dev/null)" +WSDD_USER="--user wsdd:wsdd" +WSDD_CHROOT="--chroot /var/run/wsdd" case "$1" in start) boot_mesg "Starting wsdd daemon..." - loadproc -b -p "${PIDFILE}" /usr/bin/wsdd -4 ${WSDD_USER} ${INTERFACES} ${WSDD_WORKGROUP} ${WSDD_CHROOT} + loadproc -b -p "${PIDFILE}" /usr/bin/wsdd --ipv4only ${WSDD_USER} ${INTERFACES} ${WSDD_WORKGROUP} ${WSDD_CHROOT} ;; stop) From bb88fd1b69ae27e9c14b97d219879627a473a3d2 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 16:10:04 +0100 Subject: [PATCH 05/11] wsdd: Collect static command line arguments in an array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is easier to handle than a large number of variables. Signed-off-by: Daniel Weismüller --- src/initscripts/packages/wsdd | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd index 88fe85ae2..b07fe3ace 100644 --- a/src/initscripts/packages/wsdd +++ b/src/initscripts/packages/wsdd @@ -29,18 +29,27 @@ mkdir -p /var/run/wsdd PIDFILE="/var/run/wsdd.pid" +ARGS=( + # Launch as non-privileged user + "--user" "wsdd:wsdd" + + # Launch in chroot + "--chroot" "/var/run/wsdd" + + # Only use IPv4 + "--ipv4only" +) + INTERFACES="--interface ${GREEN_DEV}" if [ -n "${BLUE_DEV}" ]; then INTERFACES="${INTERFACES} --interface ${BLUE_DEV}" fi WSDD_WORKGROUP="--workgroup $(/usr/bin/testparm -s --parameter-name workgroup 2>/dev/null)" -WSDD_USER="--user wsdd:wsdd" -WSDD_CHROOT="--chroot /var/run/wsdd" case "$1" in start) boot_mesg "Starting wsdd daemon..." - loadproc -b -p "${PIDFILE}" /usr/bin/wsdd --ipv4only ${WSDD_USER} ${INTERFACES} ${WSDD_WORKGROUP} ${WSDD_CHROOT} + loadproc -b -p "${PIDFILE}" /usr/bin/wsdd "${ARGS[@]}" ${INTERFACES} ${WSDD_WORKGROUP} ;; stop) From 43c2dc9318f5733006388563468ba75e39e8d997 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 16:11:53 +0100 Subject: [PATCH 06/11] wsdd: Securely parse the workgroup name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because of a single variable being passwd with the workgroup, it would have been possible to inject shell commands here. Passing it in the array prevents that. Signed-off-by: Daniel Weismüller --- src/initscripts/packages/wsdd | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd index b07fe3ace..e4ae3d298 100644 --- a/src/initscripts/packages/wsdd +++ b/src/initscripts/packages/wsdd @@ -38,18 +38,20 @@ ARGS=( # Only use IPv4 "--ipv4only" + + # Configure the workgroup + "--workgroup" "$(testparm -s --parameter-name workgroup 2>/dev/null)" ) INTERFACES="--interface ${GREEN_DEV}" if [ -n "${BLUE_DEV}" ]; then INTERFACES="${INTERFACES} --interface ${BLUE_DEV}" fi -WSDD_WORKGROUP="--workgroup $(/usr/bin/testparm -s --parameter-name workgroup 2>/dev/null)" case "$1" in start) boot_mesg "Starting wsdd daemon..." - loadproc -b -p "${PIDFILE}" /usr/bin/wsdd "${ARGS[@]}" ${INTERFACES} ${WSDD_WORKGROUP} + loadproc -b -p "${PIDFILE}" /usr/bin/wsdd "${ARGS[@]}" ${INTERFACES} ;; stop) From 749b93c6e96d032a04a87ebaf3f4cbba7b34f5db Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 16:14:11 +0100 Subject: [PATCH 07/11] wsdd: Append --interface switches to the arguments array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weismüller --- src/initscripts/packages/wsdd | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd index e4ae3d298..22af03169 100644 --- a/src/initscripts/packages/wsdd +++ b/src/initscripts/packages/wsdd @@ -43,15 +43,17 @@ ARGS=( "--workgroup" "$(testparm -s --parameter-name workgroup 2>/dev/null)" ) -INTERFACES="--interface ${GREEN_DEV}" -if [ -n "${BLUE_DEV}" ]; then - INTERFACES="${INTERFACES} --interface ${BLUE_DEV}" -fi +# Conditionally add the GREEN/BLUE interface +for intf in GREEN_DEV BLUE_DEV; do + if [ -n "${!intf}" ]; then + ARGS+=( "--interface" "${!intf}" ) + fi +done case "$1" in start) boot_mesg "Starting wsdd daemon..." - loadproc -b -p "${PIDFILE}" /usr/bin/wsdd "${ARGS[@]}" ${INTERFACES} + loadproc -b -p "${PIDFILE}" /usr/bin/wsdd "${ARGS[@]}" ;; stop) From 06c2bfa3c4d54a6fc6c3edb834ccb65732850383 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 16:15:13 +0100 Subject: [PATCH 08/11] wsdd: Compose the ARGS array only when we need it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weismüller --- src/initscripts/packages/wsdd | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd index 22af03169..2a153107e 100644 --- a/src/initscripts/packages/wsdd +++ b/src/initscripts/packages/wsdd @@ -29,29 +29,29 @@ mkdir -p /var/run/wsdd PIDFILE="/var/run/wsdd.pid" -ARGS=( - # Launch as non-privileged user - "--user" "wsdd:wsdd" - - # Launch in chroot - "--chroot" "/var/run/wsdd" - - # Only use IPv4 - "--ipv4only" - - # Configure the workgroup - "--workgroup" "$(testparm -s --parameter-name workgroup 2>/dev/null)" -) - -# Conditionally add the GREEN/BLUE interface -for intf in GREEN_DEV BLUE_DEV; do - if [ -n "${!intf}" ]; then - ARGS+=( "--interface" "${!intf}" ) - fi -done - case "$1" in start) + ARGS=( + # Launch as non-privileged user + "--user" "wsdd:wsdd" + + # Launch in chroot + "--chroot" "/var/run/wsdd" + + # Only use IPv4 + "--ipv4only" + + # Configure the workgroup + "--workgroup" "$(testparm -s --parameter-name workgroup 2>/dev/null)" + ) + + # Conditionally add the GREEN/BLUE interface + for intf in GREEN_DEV BLUE_DEV; do + if [ -n "${!intf}" ]; then + ARGS+=( "--interface" "${!intf}" ) + fi + done + boot_mesg "Starting wsdd daemon..." loadproc -b -p "${PIDFILE}" /usr/bin/wsdd "${ARGS[@]}" ;; From bf3f602e05df35b7619c39243c88d571c9309e8a Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 16:15:43 +0100 Subject: [PATCH 09/11] wsdd: Create the chroot directory only on start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weismüller --- src/initscripts/packages/wsdd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd index 2a153107e..be98e170d 100644 --- a/src/initscripts/packages/wsdd +++ b/src/initscripts/packages/wsdd @@ -24,9 +24,6 @@ eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) -# Create chroot directory for wsdd -mkdir -p /var/run/wsdd - PIDFILE="/var/run/wsdd.pid" case "$1" in @@ -52,6 +49,9 @@ case "$1" in fi done + # Create chroot directory for wsdd + mkdir -p /var/run/wsdd + boot_mesg "Starting wsdd daemon..." loadproc -b -p "${PIDFILE}" /usr/bin/wsdd "${ARGS[@]}" ;; From c082a0cc9a8f9faf0f7db38cda1641a1f34d74c9 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 16:17:09 +0100 Subject: [PATCH 10/11] wsdd: Add a restart command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weismüller --- src/initscripts/packages/wsdd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd index be98e170d..ed0174224 100644 --- a/src/initscripts/packages/wsdd +++ b/src/initscripts/packages/wsdd @@ -65,8 +65,13 @@ case "$1" in statusproc /usr/bin/wsdd ;; + restart) + $0 stop + $0 start + ;; + *) - echo "Usage: $0 (start|stop|status)" + echo "Usage: $0 (start|stop|status|restart)" exit 1 ;; esac From 2ee8edb81a1851ce6bab10dac383c36c67139917 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 16:18:46 +0100 Subject: [PATCH 11/11] wsdd: Call it by its full name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weismüller --- src/initscripts/packages/wsdd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/initscripts/packages/wsdd b/src/initscripts/packages/wsdd index ed0174224..68e8f3de0 100644 --- a/src/initscripts/packages/wsdd +++ b/src/initscripts/packages/wsdd @@ -52,12 +52,12 @@ case "$1" in # Create chroot directory for wsdd mkdir -p /var/run/wsdd - boot_mesg "Starting wsdd daemon..." + boot_mesg "Starting Web Service Discovery Host Daemon..." loadproc -b -p "${PIDFILE}" /usr/bin/wsdd "${ARGS[@]}" ;; stop) - boot_mesg "Stopping wsdd daemon..." + boot_mesg "Stopping Web Service Discovery Host Daemon..." killproc -p "${PIDFILE}" /usr/bin/wsdd ;;