Bug 4871 - Solaris init script stop fails when killing smbd
Summary: Solaris init script stop fails when killing smbd
Status: RESOLVED WONTFIX
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Packaging (show other bugs)
Version: 3.0.23c
Hardware: All Solaris
: P3 normal
Target Milestone: none
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-09 13:13 UTC by Peter Lyons (mail bounced back)
Modified: 2019-06-18 23:07 UTC (History)
1 user (show)

See Also:


Attachments
Fix this bug and support Solaris zones (1.12 KB, patch)
2008-09-09 20:31 UTC, SATOH Fumiyasu
no flags Details
Revised patch (1.52 KB, patch)
2009-02-05 08:19 UTC, SATOH Fumiyasu
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Lyons (mail bounced back) 2007-08-09 13:13:24 UTC
When the solaris version of the smb init script is run with the "stop" argument, it works but exits with a nonzero exit code.  This happens because it runs /usr/bin/ps and greps for the smbd process, but since there are now 2 processes, the code (which looks to expect only 1 process) kills both the parent and child process. However, killing the parent kills the child, so when /usr/bin/kill gets to the child pid, it is no longer running, so it returns an error code and prints "No such process".

To fix this, you can run the /usr/bin/ps command through sort -nr and head -1 and/or consider using the PID files.
Comment 1 Björn Jacke 2007-08-21 04:06:25 UTC
the "sort -nr" way is *bad* because after a overrun of the pid table the child processes will have lower pids than the parent process.
Comment 2 SATOH Fumiyasu 2008-01-15 00:01:04 UTC
Proposed patch:

--- samba.init.master.dist	2005-07-28 22:19:54.000000000 +0900
+++ samba.init.master	2008-01-15 15:00:08.000000000 +0900
@@ -11,9 +11,7 @@
 fi
 
 killproc() {            # kill the named process(es)
-        pid=`/usr/bin/ps -e |
-             /usr/bin/grep -w $1 |
-             /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
+        pid=`/usr/bin/pgrep -x -P 1 $1`
         [ "$pid" != "" ] && kill $pid
 }
 
Comment 3 SATOH Fumiyasu 2008-09-09 20:31:12 UTC
Created attachment 3547 [details]
Fix this bug and support Solaris zones
Comment 4 SATOH Fumiyasu 2009-02-05 08:19:02 UTC
Created attachment 3925 [details]
Revised patch
Comment 5 Björn Jacke 2019-06-18 23:07:50 UTC
there are no solaris init scripts bundled with samba upstream any more and Solaris uses svc since Solaris 10 anyway now (which is kind of the grown up role model of systemd). We leave it up to the distributions to make those though now.