[Bug 374589] Re: Samba fails to start at boot when not connected to network (and specific interfaces are configured)

camden lindsay 374589 at bugs.launchpad.net
Sat Sep 3 09:04:22 UTC 2011


It appears this and
https://bugs.launchpad.net/ubuntu/+source/samba/+bug/836849  are one in
the same, although the bug listed here is because the static ip
assignments are done through networkmanager...

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to samba in Ubuntu.
https://bugs.launchpad.net/bugs/374589

Title:
  Samba fails to start at boot when not connected to network (and
  specific interfaces are configured)

Status in “samba” package in Ubuntu:
  Triaged

Bug description:
  Binary package hint: samba

  When my laptop boots network is not yet configured since NM didn´t start it yet. Samba however tries to start since it is in S20 on rc2-5.d but it fails immediately because no network is configured yet. Running - sudo /etc/init.d/samba restart - is fine.
  In the log file I can find the following pair of errors:
  [2009/04/18 11:22:48,  0] lib/interface.c:load_interfaces(540)
    WARNING: no network interfaces found
  [2009/04/18 11:22:49,  0] smbd/server.c:open_sockets_smbd(548)
    open_sockets_smbd: No sockets available to bind to.

  Trying to resolve the problem, I wrote an updown script in /etc/NetworkManager/dispatcher.d naming it 02samba:
  $ ls -l  /etc/NetworkManager/dispatcher.d
  total 12K
  -rwxr-xr-x 1 root root 1.3K 2008-10-21 05:17 01ifupdown
  -rwxr-xr-x 1 root root 1.9K 2009-05-08 11:35 02samba

  If this solution makes sense I would recommend that it would be added to Ubuntu samba server package.
  Here is the script I wrote:
  #!/bin/sh -e
  # Script to dispatch NetworkManager events
  #
  # Runs ifupdown scripts when NetworkManager fiddles with interfaces.

  if [ -z "$1" ]; then
      echo "$0: called with no interface" 1>&2
      exit 1;
  fi

  # Fake ifupdown environment
  export IFACE="$1"
  export LOGICAL="$1"
  export ADDRFAM="NetworkManager"
  export METHOD="NetworkManager"
  export VERBOSITY="0"
  notRunningCont=`/etc/init.d/samba status | grep -c not`  # count "not running"

  # Run the right scripts
  case "$2" in
      up)
          export MODE="start"
          export PHASE="up"
          if [ -e /var/run/network/ifstate ]
          then
                  if grep --silent eth /var/run/network/ifstate
                  then
                          case $notRunningCont in # count "not running"
                          2) # both smbd and nmbd are down. start them
                                  exec /etc/init.d/samba start
                                  ;;
                          1) # probably smbd faild. 
                                  exec /etc/init.d/samba restart
                                  ;;
                          0) # samba seems running
                                  ;;
                          *) # unknown situation. try to restart anyways
                                  exec /etc/init.d/samba restart
                          esac
                  fi
          fi
          ;;
      down)
          export MODE="stop"
          export PHASE="down"
          if [ -e /var/run/network/ifstate ]
          then
                  if grep --silent eth /var/run/network/ifstate
                  then # network is still up. Make sure samba is also up. 
                          case  $notRunningCont in
                          2) # both smbd and nmbd are down. start them
                                  exec /etc/init.d/samba start
                                  ;;
                          1) # probably smbd faild. 
                                  exec /etc/init.d/samba restart
                                  ;;
                          0) # samba seems running
                                  ;;
                          *) # unknown situation. try to restart anyways
                                  exec /etc/init.d/samba restart
                          esac
                  else # shut samba down
                          exec /etc/init.d/samba stop
                  fi
          else # same here. Shut it down
                  exec /etc/init.d/samba stop
          fi
          ;;
     pre-up)
          export MODE="start"
          export PHASE="pre-up"
          exec run-parts /etc/network/if-pre-up.d
          ;;
      post-down)
          export MODE="stop"
          export PHASE="post-down"
          exec run-parts /etc/network/if-post-down.d
          ;;
      *)
          echo "$0: called with unknown action \`$2'" 1>&2
          exit 1
          ;;
  esac

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/samba/+bug/374589/+subscriptions




More information about the foundations-bugs mailing list