This clause in /usr/local/etc/rc.d/samba_server (lines 120-122): > if [ -n "${_rc_prefix}" -a "${_rc_prefix}" = "one" ] || [ -n "${rc_force}" ] || [ -n "${rc_fast}" ]; then > force_run=yes > fi forces nmbd and winbindd to be started regardless of the values of nmbd_enable and winbindd_enable in /etc/rc.conf. If one wants to start samba_server manually (without having set samba_server_enable="YES") after boot they have no option but to use 'onestart' but then that will ignore disabling of nmbd and winbindd in rc.conf; even in situations where 'disable netbios = yes' is explicitly set in smb4.conf. This leaves one with no option to start only smbd manually after boot without forcibly launching nmbd and winbindd which many not be desired in some scenarios. This was checked with samba_server script shipped with samba41-4.1.22_2.
I did the same observation concerning samba412 & samba413 (latest versions). I think this behaviour isn't normal. I'm in a case where I don't have network connectivity at startup, so I delay the launch of samba via a cron entry. And, to do so, I'm obliged to use 'onestart' command. Is it possible to correct this behavour?
Created attachment 226136 [details] Patch for samba_server rc script Launch the same daemons with command start or onestart
I eventually wrote a patch to get the same behaviour, whether samba_server is started by 'start' or 'onestart' command. The idea is that the variable $samba_daemons should contain only the daemon names it is supposed to start (mainly depending on rc.conf values). I followed all the indications I found in the code and it seems to work. In some way, the code of samba_server_config_init() is even simplified. The patch is applicable at least for samba412 & 413. Seems the code of this script hasn't changed since long time. Applying this patch, you get this: -------------------------- samba_server_defaultyes() { load_rc_config $1 eval ${1}_enable=\${${1}_enable-YES} if checkyesno ${1}_enable; then samba_daemons="$samba_daemons $1" fi } samba_server_config_init() { # Load configuration load_rc_config "${name}" # Defaults samba_server_enable=${samba_server_enable:=NO} samba_server_config=${samba_server_config=${samba_server_config_default}} samba_server_configfile_arg=${samba_server_config:+--configfile="${samba_server_config}"} #" #testparm_command="/usr/local/bin/samba-tool testparm --suppress-prompt --verbose ${samba_server_configfile_arg}" testparm_command="/usr/local/bin/testparm --suppress-prompt --verbose ${samba_server_config}" # Determine what daemons are necessary to run Samba in the current role samba_server_role=$(${testparm_command} --parameter-name='server role' 2>/dev/null) case "${samba_server_role}" in active\ directory\ domain\ controller) samba_server_defaultyes "samba" ;; auto|*) samba_server_defaultyes "nmbd" samba_server_defaultyes "smbd" # Winbindd will be active if it's set to "YES" in rc.conf # or if 'idmap id' is defined in smb4.conf load_rc_config "winbindd" samba_server_idmap=$(${testparm_command} --parameter-name='idmap uid' 2>/dev/null) if [ -n "${samba_server_idmap}" ]; then winbindd_enable="YES" fi if [ -n "$winbindd_enable" ] && checkyesno winbindd_enable; then samba_daemons="${samba_daemons} winbindd" fi ;; esac # Fetch parameters from configuration file samba_server_lockdir="$(${testparm_command} --parameter-name='lock directory' 2>/dev/null)" samba_server_lockdir=${samba_server_lockdir:=/var/db/samba4} samba_server_piddir="$(${testparm_command} --parameter-name='pid directory' 2>/dev/null)" samba_server_piddir=${samba_server_piddir:=/var/run/samba4} samba_server_privatedir="$(${testparm_command} --parameter-name='private dir' 2>/dev/null)" samba_server_privatedir=${samba_server_privatedir:=/var/db/samba4/private} } --------------------------