ports/151173: [PATCH] net/samba34: Fix rc script to return correct "status" exit code

Ulrich Spoerlein uqs at FreeBSD.org
Sun Oct 3 16:40:02 UTC 2010


>Number:         151173
>Category:       ports
>Synopsis:       [PATCH] net/samba34: Fix rc script to return correct "status" exit code
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 03 16:40:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Ulrich Spoerlein
>Release:        FreeBSD 8.1-STABLE i386
>Organization:
>Environment:
System: FreeBSD coyote.spoerlein.net 8.1-STABLE FreeBSD 8.1-STABLE #0 r212859M: Sun Sep 19 18:55:13 CEST
>Description:
When samba is not running, but samba_enable=YES in /etc/rc.conf, the "status"
subcommand will return with an exit value of 0 (indicating success). This
breaks scripts, that try to collect daemon status to restart stopped services.

Collect the return values of both smbd and nmbd and return with exit status of
either of them if one is failing.

Port maintainer (timur at FreeBSD.org) is cc'd.
Generated with FreeBSD Port Tools 0.99
>How-To-Repeat:
Stop samba, run the rc script as follows:

root at coyote:~# /usr/local/etc/rc.d/samba status ; echo $?
nmbd is not running.
smbd is not running.
0
>Fix:

--- samba34-3.4.8_2.patch begins here ---
Index: Makefile
===================================================================
RCS file: /data/src/freebsd.cvs/ports/net/samba34/Makefile,v
retrieving revision 1.5
diff -u -p -u -r1.5 Makefile
--- Makefile	15 Sep 2010 18:35:01 -0000	1.5
+++ Makefile	2 Oct 2010 09:47:33 -0000
@@ -7,7 +7,7 @@
 
 PORTNAME=		samba34
 PORTVERSION=		3.4.8
-PORTREVISION?=		1
+PORTREVISION?=		2
 CATEGORIES?=		net
 MASTER_SITES=		${MASTER_SITE_SAMBA}
 MASTER_SITE_SUBDIR=	. old-versions rc pre
Index: files/samba.in
===================================================================
RCS file: /data/src/freebsd.cvs/ports/net/samba34/files/samba.in,v
retrieving revision 1.2
diff -u -p -u -r1.2 samba.in
--- files/samba.in	27 Mar 2010 00:13:58 -0000	1.2
+++ files/samba.in	2 Oct 2010 09:47:33 -0000
@@ -137,7 +137,7 @@ samba_reload_cmd() {
 }
 
 samba_cmd() {
-    local name rcvar command pidfile samba_daemons
+    local name rcvar command pidfile samba_daemons result _result
     # Prevent recursive calling
     unset "${rc_arg}_cmd" "${rc_arg}_precmd" "${rc_arg}_postcmd"
     # Stop processes in the reverse to order
@@ -145,6 +145,7 @@ samba_cmd() {
 	samba_daemons=$(reverse_list ${samba_daemons})
     fi
     # Apply to all daemons
+    result=0
     for name in ${samba_daemons}; do
 	rcvar=$(set_rcvar)
 	command="%%PREFIX%%/sbin/${name}"
@@ -152,8 +153,14 @@ samba_cmd() {
 	# Daemon should be enabled and running
 	if [ -n "${rcvar}" ] && checkyesno "${rcvar}"; then
 	    run_rc_command "${_rc_prefix}${rc_arg}" ${rc_extra_args}
+	    # Collect return values
+	    _result=$?
+	    if [ ${_result} != 0 ]; then
+		result=${_result}
+	    fi
 	fi
     done
+    return $result
 }
 
 run_rc_command "$1"
--- samba34-3.4.8_2.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list