[Eisfair_dev] [e1] Samba 9.0.0 (Status 'unstable')

Thomas Bork tom at eisfair.org
Mo Feb 24 20:24:35 CET 2020


Am 24.02.2020 um 13:11 schrieb Peter Bäumer:

>> Geht, kann immer gesetzt werden.
> Hab es jetzt auch im Log gesehen :)
> Ist /var/lib/wsdd der passende Oedner für das chroot ?

Ich habe /run/wsdd/chroot genommen.

>>> -U UUID, --uuid UUID  UUID for the target device
>>>    Keine Ahnung für was das gut sein soll :(
>> Die sollte für ein System immer gleich sein, bildet wsdd aus dem 
>> Hostnamen, wenn man nix setzt.
> Wenn das wsdd automatisch macht braucht man das auch nicht im Menü 
> konfigurieren :)

Richtig.

>>> -w WORKGROUP, --workgroup WORKGROUP  set workgroup name (default 
>>> WORKGROUP)
>>>    Der Workgroup Name kann aus der /etc/config.d/samba ermittelt 
>>> werden (SAMBA_WORKGROUP)
>> Parst das init-Skript aus testparm.
>>> -d DOMAIN, --domain DOMAIN  set domain name (disables workgroup)
>>>    Kann der Domainname auch aus der /etc/config.d/samba ermittelt 
>>> werden?
>> Funktioniert sowohl mit Workgroup als auch Domäne.
> Gehe ich richtig in der Annahme wenn server role nicht ROLE_STANDALONE ist
> dann ist ein Domänencontroller (PDC) oder Domän-Memberserver ?
>    if testparm -s 2>&1 |grep -q "ROLE_STANDALONE" ; then
>        SERVER_ROLE="--workgroup"
>    else
>        SERVER_ROLE="--domain"
>    fi
> Wenn ich das Python Skript richtig lese wäre der einzige unterschied
> das der Hostname bei Workgoup in Großbuchstaben dargestellt wird und bei 
> Domain und kleinen.

Es muss nur Workgroup definiert werden. Die andere Option ist nur für 
AD-Domänen, die ich nicht unterstütze.

> Für das Eis-Menü hätte ich bis jetzt:
>    START_WSDD=yes|no
>    WSDD_VERBOSE=yes|no
>    WSDD_LOG_COUNT='10'
>    WSDD_LOG_INTERVAL='monthly'
> 
> und die Links für start|stop|restart|status
> 
> Optional:
>    Wäre toll wenn Samba bei einer Konfigurationsänderung den wssd Dämon 
> mit Restarten könnte,
>    damit wsdd Änderungen sofort mit bekommt.

Ich habe das im Moment so bei mir zu laufen, als wäre wsdd Bestandteil 
des Samba-Paketes. Ich kopiere mal das init-Skript hierher:

#!/bin/sh
# Copyright 2017 Steffen Christgau
# Distributed under the terms of the MIT licence

#set -x

#. /etc/config.d/wsdd
. /etc/init.d/functions

NAME='wsdd'
DAEMON="/usr/bin/${NAME}"
WSDD_USER='nobody'
WSDD_GROUP='nogroup'
WSDD_CHROOT='/run/wsdd/chroot'
SMB_CONFIG_FILE='/etc/smb.conf'
LOG_FILE="${WSDD_LOG_FILE:-/var/log/log.wsdd}"
WSDD_PIDFILE=/run/${NAME}/${NAME}.pid
PID=''

wsdd_start()
{
	if [ -e ${WSDD_PIDFILE} ]
	then
	    PID=`cat ${WSDD_PIDFILE}`
	else
	    PID=`ps ax | grep "python3 ${DAEMON}" | grep -v 'grep' | head -1 | 
awk '{print $1}'`
	fi

	if [ -n "$PID" ]
	then
		boot_mesg " * ${NAME} is already running ..."
		echo_warning
		exit 0
	fi

	#boot_mesg " * Starting ${NAME} ..."
	boot_mesg "   - Starting ${NAME} ..."
	OPTS="${WSDD_OPTS} -u ${WSDD_USER}:${WSDD_GROUP} -c ${WSDD_CHROOT}"

	if [ -z "$WSDD_WORKGROUP" ]
	then
		# try to extract workgroup with Samba's testparm
		if which testparm >/dev/null 2>/dev/null
		then
			GROUP="$(testparm -s --parameter-name workgroup 2>/dev/null)"
		fi

		# fallback to poor man's approach if testparm is unavailable or failed 
for some reason
		if [ -z "$GROUP" ] && [ -r "${SMB_CONFIG_FILE}" ]
		then
			GROUP=`grep -i '^\s*workgroup\s*=' ${SMB_CONFIG_FILE} | cut -f2 -d= | 
tr -d '[:blank:]'`
		fi

		if [ -n "${GROUP}" ]
		then
			OPTS="-w ${GROUP} ${OPTS}"
		fi
	else
		OPTS="-w ${WSDD_WORKGROUP} ${OPTS}"
	fi

	if [ ! -r "${LOG_FILE}" ]
	then
		touch "${LOG_FILE}"
	fi
	chown ${WSDD_USER}:${WSDD_GROUP} "${LOG_FILE}"

         if [ ! -d ${WSDD_CHROOT} ]
         then
             mkdir -p ${WSDD_CHROOT}
             chown -R ${WSDD_USER}:${WSDD_GROUP} "${WSDD_CHROOT}"
         fi

	startproc -l ${LOG_FILE} ${DAEMON} ${OPTS}

	idx=0
	while [ ${idx} -le 5 ]
	do
		sleep 1
		PID=`ps ax | grep "python3 ${DAEMON}" | grep -v 'grep' | head -1 | awk 
'{print $1}'`
		if [ -n "$PID" ]
		then
			echo "$PID" > ${WSDD_PIDFILE}
			kill -0 "$PID"
			evaluate_retval
			break
		fi
		idx=`expr $idx + 1`
	done
}

wsdd_stop()
{
	#boot_mesg " * Stopping ${NAME} ..."
	if [ -e ${WSDD_PIDFILE} ]
	then
	    PID=`cat ${WSDD_PIDFILE}`
	else
	    PID=`ps ax | grep "python3 ${DAEMON}" | grep -v 'grep' | head -1 | 
awk '{print $1}'`
	fi

	if [ -n "$PID" ]
	then
		boot_mesg "   - Stopping ${NAME} ..."
		for signal in "TERM" "INT" "HUP" "KILL"
		do
			kill -$signal ${PID}
			if [ $? -eq 0 ]
			then
				echo_ok
				break
			fi
			boot_mesg " * Warning: kill -$signal ${PID} failed."
			echo_warning
			sleep 1
		done
		sleep 1
		rm -f ${WSDD_PIDFILE}
	else
		boot_mesg "   Warning: ${NAME} is not running."
		echo_warning
	fi

         rm -rf "${WSDD_CHROOT}"
}

wsdd_restart()
{
     wsdd_stop
     sleep 1
     wsdd_start
}

case $1 in
start)
	wsdd_start
	;;
forcestart)
	wsdd_start
	;;
status)
	if [ -e ${WSDD_PIDFILE} ]
	then
	    PID=`cat ${WSDD_PIDFILE}`
	else
	    PID=`ps ax | grep "python3 ${DAEMON}" | grep -v 'grep' | head -1 | 
awk '{print $1}'`
	fi

	if [ -n "$PID" ]
	then
		#boot_mesg " * ${NAME} is running with pid $PID ..."
		boot_mesg "${NAME} is running with pid $PID."
	else
		#boot_mesg " * ${NAME} is not running ..."
		boot_mesg "${NAME} is not running."
	fi
	;;
stop)
	wsdd_stop
	;;
restart)
	wsdd_restart
	;;
esac




Das dazugehörige Skript von Samba 9.0.0:

#! /bin/sh
#----------------------------------------------------------------------------
# /etc/init.d/samba - init samba
#
# Copyright (c) 2002-2019 Thomas Bork, tom(at)eisfair(dot)net
#
# usage: /etc/init.d/samba {start|forcestart|status|stop|restart|reload}
#
# Creation   : 2001-11-04 tb
# Last Update: 2019-01-16 tb
#
# 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 2 of the License, or
# (at your option) any later version.
#----------------------------------------------------------------------------
#set -x
. /etc/config.d/samba
. /etc/init.d/functions

lockdir='/var/lib/samba'
socketsdir='/run/samba'
sambastatus='/var/install/bin/samba-check-status'
tdbbackupbin='/usr/bin/tdbbackup'
nmbdbin='/usr/sbin/nmbd'
smbdbin='/usr/sbin/smbd'
winbinddbin='/usr/sbin/winbindd'
netbin='/usr/bin/net'
mountpoint='/samba_dfs'
imgdir='/usr/local/share/samba'
dfsimage="$imgdir/dfs_root.img"
mountbin='/bin/mount'
umountbin='/bin/umount'

do_mount_dfs_image ()
{
   if [ "$1" = "--u" ]
   then
       if [ -n "`"$mountbin" -t ext3 | grep " $mountpoint "`" ]
       then
           cd /
           "$mountbin" -t ext3 | grep " $mountpoint " |
           while read mounted
           do
               "$umountbin" "$mountpoint"
               if [ $? -ne 0 ]
               then
                   boot_mesg "   Cannot umount $mountpoint."
                   echo_failure
               fi
           done
       fi
       rm -rf "$mountpoint"
   else
       mountoption="$1"
       if [ -z "$mountoption" ]
       then
           mountoption='--rw'
       fi

       if [ -f "$dfsimage" -a ! "`"$mountbin" -t ext3 | grep " 
$mountpoint "`" ]
       then
           modprobe loop 2>/dev/null
           mkdir "$mountpoint"
           "$mountbin" -o loop $mountoption "$dfsimage" "$mountpoint"
           if [ $? -ne 0 ]
           then
               boot_mesg "   Cannot mount $dfsimage $mountpoint 
$mountoption."
               echo_failure
               rmdir "$mountpoint"
           fi
       fi
   fi
}

do_loadnmbd ()
{
   if [ $nmbdstatus = alive ]
   then
       boot_mesg "   Warning: nmbd is already running."
       echo_warning
   else
       # create socketsdir /run/samba, nmbd and smbd cannot start
       # without and run is in new versions mounted as tmpfs
       if [ ! -d "$socketsdir" ]
       then
           mkdir -p "$socketsdir"
           if [ $? -ne 0 ]
           then
               boot_mesg "   Error: Cannot create directory $socketsdir!"
               echo_failure
               exit 1
           fi
       fi

       if [ ! -d "$lockdir" ]
       then
           mkdir -p "$lockdir"
           if [ $? -ne 0 ]
           then
               boot_mesg "   Error: Cannot create directory $lockdir!"
               echo_failure
               exit 1
           fi
       fi

       for tdb in $lockdir/brlock.tdb           \
                  $lockdir/connections.tdb      \
                  $lockdir/group_mapping.ldb    \
                  $lockdir/group_mapping.tdb    \
                  $lockdir/locking.tdb          \
                  $lockdir/messages.tdb         \
                  $lockdir/namelist.debug       \
                  $lockdir/printing/?*.tdb      \
                  $lockdir/sessionid.tdb        \
                  $lockdir/unexpected.tdb       \
                  $lockdir/winbindd_cache.tdb
       do
           rm -f $tdb
       done

       for tdb in $lockdir/?*.tdb \
                      /etc/?*.tdb
       do
           if [ -f $tdb ]
           then
               rm -f $tdb.samba.bak
               $tdbbackupbin -l -s .samba.bak $tdb
               $tdbbackupbin -v $tdb 1>/dev/null
           fi
       done

       # clean up old messaging sockets
       rm -f /etc/msg.sock/?*
       rm -f $lockdir/msg.lock/?*

       if [ "$SAMBA_PDC" = "yes" ]
       then
           /var/install/bin/samba-pdc-groupmapping -q addall
       fi

       do_mount_dfs_image --ro

       boot_mesg "   - Starting nmbd ..."
       "$nmbdbin" -D
       evaluate_retval
   fi
}

do_loadsmbd ()
{
   if [ $smbdstatus = alive ]
   then
       boot_mesg "   Warning: smbd is already running."
       echo_warning
   else
       boot_mesg "   - Starting smbd ..."
       "$smbdbin" -D
       if [ $? -eq 0 ]
       then
           echo_ok
           if [ "$SAMBA_START_MESSAGE_SEND" = "yes" ]
           then
               /var/install/bin/samba-netsend "all" "$SAMBA_START_MESSAGE"
           fi
       else
           echo_failure
       fi
   fi
}

do_loadwinbindd ()
{
   if [ $winbinddstatus = alive ]
   then
       boot_mesg "   Warning: winbindd is already running."
       echo_warning
   else
       boot_mesg "   - Starting winbindd ..."
       "$winbinddbin"
       evaluate_retval
   fi
}

do_startsamba ()
{
   boot_mesg " * Starting Samba ..."
   . $sambastatus
   do_loadnmbd
   do_loadsmbd

   if [ -n "$SAMBA_PASSWORD_SERVER" ]
   then
       do_loadwinbindd
   fi

   if [ -f /etc/init.d/wsdd ]
   then
       /etc/init.d/wsdd start
   fi
}

do_showmapping ()
{
   "$netbin" groupmap list | grep -v " -> -1" | sort |
   while read line
   do
       set -- $line
       domaingroup="$1"
       eisfairgroup="$3 $4"
       echo "$domaingroup $eisfairgroup"
   done
}

do_passwordserver ()
{
   if [ -n "$SAMBA_PASSWORD_SERVER" ]
   then
       echo "Available domain groups:"
       wbinfo -g
       echo "Available domain users:"
       wbinfo -u
   fi
}

case $1 in
'start')
     if [ "$START_SAMBA" = "yes" ]
     then
         do_startsamba
     fi
     ;;
'forcestart')
     do_startsamba
     ;;
'status')
     /usr/local/bin/colecho "Checking status of Samba ..." gn
     . $sambastatus

     if [ $nmbdstatus = alive ]
     then
         echo "nmbd is running."
     else
         echo "nmbd is not running."
     fi

     if [ $smbdstatus = alive ]
     then
         echo "smbd is running."
     else
         echo "smbd is not running."
     fi

     if [ $winbinddstatus = alive ]
     then
         echo "winbindd is running."
         do_passwordserver
     else
         echo "winbindd is not running."
     fi

     if [ -f /etc/init.d/wsdd ]
     then
         /etc/init.d/wsdd status
     fi

     if [ "$SAMBA_PDC" = "yes" ]
     then
         echo "Static groupmapping from windows groups to unix groups:"
         do_showmapping
     fi
     ;;
'stop')
     boot_mesg " * Stopping Samba ..."

     if [ -f /etc/init.d/wsdd ]
     then
         /etc/init.d/wsdd stop
     fi

     . $sambastatus

     if [ $winbinddstatus = alive ]
     then
         boot_mesg "   - Stopping winbindd ..."
         for signal in "TERM" "INT" "HUP" "KILL"
         do
             /usr/bin/killall -$signal winbindd
             if [ $? -eq 0 ]
             then
                 echo_ok
                 break
             fi
             boot_mesg "   Warning: killall -$signal winbindd failed."
             echo_warning
             sleep 1
         done
         sleep 1
         rm -f $winbinddpidfile
     else
         if [ -n "$SAMBA_PASSWORD_SERVER" ]
         then
             boot_mesg "   Warning: winbindd is not running."
             echo_warning
         fi
     fi

     if [ $smbdstatus = alive ]
     then
         if [ "$SAMBA_SHUTDOWN_MESSAGE_SEND" = "yes" ]
         then
             if [ -n "`ps ax | grep smbd | grep -v grep`" ]
             then
                 /var/install/bin/samba-netsend 
"$SAMBA_SHUTDOWN_MESSAGE_HOSTS" "$SAMBA_SHUTDOWN_MESSAGE"
             fi
         fi

         boot_mesg "   - Stopping smbd ..."
         for signal in "TERM" "INT" "HUP" "KILL"
         do
             /usr/bin/killall -$signal smbd
             if [ $? -eq 0 ]
             then
                 echo_ok
                 break
             fi
             boot_mesg "   Warning: killall -$signal nmbd failed."
             echo_warning
             sleep 1
         done
         sleep 1
         rm -f $smbdpidfile
     else
         boot_mesg "   Warning: smbd is not running."
         echo_warning
     fi

     if [ $nmbdstatus = alive ]
     then
         boot_mesg "   - Stopping nmbd ..."
         for signal in "TERM" "INT" "HUP" "KILL"
         do
             /usr/bin/killall -$signal nmbd
             if [ $? -eq 0 ]
             then
                 echo_ok
                 break
             fi
             boot_mesg "   Warning: killall -$signal nmbd failed."
             echo_warning
             sleep 1
         done
         sleep 1
         rm -f $nmbdpidfile
     else
         boot_mesg "   Warning: nmbd is not running."
         echo_warning
     fi

     do_mount_dfs_image --u
     ;;
'restart')
     $0 stop && $0 forcestart
     ;;
'reload')
     boot_mesg " * Reloading Samba ..."
     . $sambastatus

     if [ $smbdstatus = alive -a $nmbdstatus = alive ]
     then
         for i in `ps ax | grep nmbd | grep -v grep | cut -c1-6`
         do
             boot_mesg "   - Reloading nmbd with pid $i ..."
             /bin/kill -SIGHUP $i
             evaluate_retval
         done

         for i in `ps ax | grep smbd | grep -v grep | cut -c1-6`
         do
             boot_mesg "   - Reloading smbd with pid $i ..."
             /bin/kill -SIGHUP $i
             evaluate_retval
         done

         for i in `ps ax | grep winbindd | grep -v grep | cut -c1-6`
         do
             boot_mesg "   - Reloading winbindd with pid $i ..."
             /bin/kill -SIGHUP $i
             evaluate_retval
         done
     else
         echo "   Samba is not running, performing restart ..."
         $0 restart
     fi
     ;;
*)
     echo "usage: /etc/init.d/`basename $0` 
{start|forcestart|status|stop|restart|reload}" >&2
     exit 1
     ;;
esac


Die Ausgaben von Samba:

pvscsi # /etc/init.d/samba stop
  * Stopping Samba ...
    - Stopping wsdd ...
    - Stopping smbd ...
    - Stopping nmbd ...
pvscsi # /etc/init.d/samba start
  * Starting Samba ...
    - Starting nmbd ... 
[  OK  ]
    - Starting smbd ... 
[  OK  ]
    - Starting wsdd ... 
[  OK  ]
pvscsi # /etc/init.d/samba stop
  * Stopping Samba ...
    - Stopping wsdd ... 
[  OK  ]
    - Stopping smbd ... 
[  OK  ]
    - Stopping nmbd ... 
[  OK  ]
pvscsi # /etc/init.d/samba restart
  * Stopping Samba ...
    Warning: wsdd is not running. 
[ WARN ]
    Warning: smbd is not running. 
[ WARN ]
    Warning: nmbd is not running. 
[ WARN ]
  * Starting Samba ...
    - Starting nmbd ... 
[  OK  ]
    - Starting smbd ... 
[  OK  ]
    - Starting wsdd ... 
[  OK  ]
pvscsi # /etc/init.d/samba status
Checking status of Samba ...
nmbd is running.
smbd is running.
winbindd is not running.
wsdd is running with pid 3150.
Static groupmapping from windows groups to unix groups:
Domänen-Administratoren -> root
Domänen-Benutzer -> users
Domänen-Computer -> machines
Domänen-Gäste -> nogroup
Domänen-Hauptbenutzer -> sys
pvscsi #

-- 
der tom
[eisfair-team]


Mehr Informationen über die Mailingliste Eisfair_dev