Working around netifaces segfault on FreeBSD

netifaces.gateways() function segmentation fault on FreeBSD, making
Glances unusable. As a workaround, just disable netifaces on FreeBSD.
See https://bitbucket.org/al45tair/netifaces/issues/15.

Fixes #670.
This commit is contained in:
Alessio Sergi 2015-09-11 12:37:37 +02:00
parent 1427274e50
commit 7cfc223c12
3 changed files with 24 additions and 15 deletions

View File

@ -35,7 +35,7 @@ except ImportError:
zeroconf_tag = False
# Import Glances libs
from glances.core.glances_globals import appname
from glances.core.glances_globals import appname, is_freebsd
from glances.core.glances_logging import logger
# Zeroconf 0.17 or higher is needed
@ -194,13 +194,16 @@ class GlancesAutoDiscoverClient(object):
except socket.error as e:
logger.error("Cannot start zeroconf: {0}".format(e))
try:
# -B @ overwrite the dynamic IPv4 choice
if zeroconf_bind_address == '0.0.0.0':
zeroconf_bind_address = self.find_active_ip_address()
except KeyError:
# Issue #528 (no network interface available)
pass
# XXX FreeBSD: Segmentation fault (core dumped)
# -- https://bitbucket.org/al45tair/netifaces/issues/15
if not is_freebsd:
try:
# -B @ overwrite the dynamic IPv4 choice
if zeroconf_bind_address == '0.0.0.0':
zeroconf_bind_address = self.find_active_ip_address()
except KeyError:
# Issue #528 (no network interface available)
pass
print("Announce the Glances server on the LAN (using {0} IP address)".format(zeroconf_bind_address))
self.info = ServiceInfo(

View File

@ -33,6 +33,7 @@ is_py3 = sys.version_info >= (3, 3)
# Operating system flag
# Note: Somes libs depends of OS
is_bsd = sys.platform.find('bsd') != -1
is_freebsd = sys.platform.startswith('freebsd')
is_linux = sys.platform.startswith('linux')
is_mac = sys.platform.startswith('darwin')
is_windows = sys.platform.startswith('win')

View File

@ -19,17 +19,22 @@
"""IP plugin."""
# Import system libs
try:
import netifaces
netifaces_tag = True
except ImportError:
netifaces_tag = False
# Import Glances libs
from glances.core.glances_globals import is_freebsd
from glances.core.glances_logging import logger
from glances.plugins.glances_plugin import GlancesPlugin
# XXX FreeBSD: Segmentation fault (core dumped)
# -- https://bitbucket.org/al45tair/netifaces/issues/15
if not is_freebsd:
try:
import netifaces
netifaces_tag = True
except ImportError:
netifaces_tag = False
else:
netifaces_tag = False
class Plugin(GlancesPlugin):