Slackware NetworkManager and Firewall Conflict

In my journey to update all of my Slackware 14.1 32-bit systems to 14.2 64-bit, I ran across a quirk with the way Slackware launches NetworkManager. In 14.1 the startup scripts are flawed in that rc.networkmanager is launched after rc.firewall. This breaks rc.firewall because no network interface is yet defined.

I am updating my Slackware 14.1 32-bit systems to 14.2 64-bit in two steps by first updating to 14.1 64-bit. In preparing for the move to 14.2, I have been merging nominal differences from the 14.2 rc.d scripts to my 14.1 scripts. One of the improvements in 14.2 is rc.networkmanager is correctly launched before rc.firewall.

Despite the improvements, in my use case NetworkManager did not finish creating the routing table before rc.firewall launched. This again resulted in a broken firewall.

I use NetworkManager only with my Thinkpad T400 laptop. In my other systems I use the traditional rc.inet1.conf because all of those systems are connected with CAT5e. Those systems are stationary. I could use NetworkManager but I see no need.

In the systems not using NetworkManager there is no problem launching rc.firewall because the network interface and routing table are configured through rc.inet1.conf.

Some trial-and-error testing revealed NetworkManager needed about 5 seconds on the T400 to create the routing table.

Another bump entered the picture when I would use the laptop wireless in one access point, such as at home, and then use the laptop wireless at another location, such as at work. Once again the firewall would not initialize correctly. In the end I modified the rc.firewall script with the following:

    if [ -x /etc/rc.d/rc.networkmanager ] && [ "`ps ax | grep /usr/sbin/NetworkManager | grep -v grep`" = "" ]; then
      # NetworkManager is executable but not yet running.
      echo ”  NetworkManager is configured to run on this system"
      echo ”  but is not yet running.”
      exit 0
    elif [ "`ps ax | grep /usr/sbin/NetworkManager | grep -v grep`" != "" ]; then
      echo "NetworkManager seems to be running."
      NM="true"
      WAIT_TIME=20 # Seconds
      # Ensure the network device is defined.
      unset NET_DEV
      COUNT=0
      echo -n "Ensuring NetworkManager has connected."
      while [ "$NET_DEV" = "" ] && [ $COUNT -lt $WAIT_TIME ]; do
        echo -n .””
        NET_DEV="`/usr/bin/nmcli d | grep connected | awk ‘{print $1}'`"
        sleep 1
        COUNT=$((COUNT+1))
      done
      echo ""
      unset NET_DEV
      COUNT=0
      echo -n "Ensuring NetworkManager has created the routing table."
      while [ "`/sbin/route -n | grep \"^0.0.0.0\"`" = "" ] && [ $COUNT -lt $WAIT_TIME ]; do
        echo -n .””
        sleep 1
        COUNT=$((COUNT+1))
      done
      echo ""
    fi

The snippet seems to working. The rc.firewall now launches without complaint.

Posted: Category: Usability Tagged: Slackware

Next: Keyboard Shortcut To Toggle A Trackpad

Previous: Moving vnstat from 32-bit to 64-bit