Merge pull request #12847 from cpuguy83/fix_firewald_errors

Fix error message on firewalld init
This commit is contained in:
Jessie Frazelle 2015-05-12 12:01:59 -07:00
commit 1ea44366e3
2 changed files with 13 additions and 13 deletions

View file

@ -33,19 +33,18 @@ var (
onReloaded []*func() // callbacks when Firewalld has been reloaded onReloaded []*func() // callbacks when Firewalld has been reloaded
) )
func FirewalldInit() { func FirewalldInit() error {
var err error var err error
connection, err = newConnection() if connection, err = newConnection(); err != nil {
return fmt.Errorf("Failed to connect to D-Bus system bus: %v", err)
if err != nil {
logrus.Errorf("Failed to connect to D-Bus system bus: %s", err)
} }
if connection != nil { if connection != nil {
go signalHandler() go signalHandler()
} }
firewalldRunning = checkRunning() firewalldRunning = checkRunning()
return nil
} }
// New() establishes a connection to the system bus. // New() establishes a connection to the system bus.
@ -146,19 +145,15 @@ func checkRunning() bool {
logrus.Infof("Firewalld running: %t", err == nil) logrus.Infof("Firewalld running: %t", err == nil)
return err == nil return err == nil
} }
logrus.Info("Firewalld not running")
return false return false
} }
// Firewalld's passthrough method simply passes args through to iptables/ip6tables // Firewalld's passthrough method simply passes args through to iptables/ip6tables
func Passthrough(ipv IPV, args ...string) ([]byte, error) { func Passthrough(ipv IPV, args ...string) ([]byte, error) {
var output string var output string
logrus.Debugf("Firewalld passthrough: %s, %s", ipv, args) logrus.Debugf("Firewalld passthrough: %s, %s", ipv, args)
err := connection.sysobj.Call(dbusInterface+".direct.passthrough", 0, ipv, args).Store(&output) if err := connection.sysobj.Call(dbusInterface+".direct.passthrough", 0, ipv, args).Store(&output); err != nil {
if output != "" { return nil, err
logrus.Debugf("passthrough output: %s", output)
} }
return []byte(output), nil
return []byte(output), err
} }

View file

@ -7,7 +7,12 @@ import (
) )
func TestFirewalldInit(t *testing.T) { func TestFirewalldInit(t *testing.T) {
FirewalldInit() if !checkRunning() {
t.Skip("firewalld is not running")
}
if err := FirewalldInit(); err != nil {
t.Fatal(err)
}
} }
func TestReloaded(t *testing.T) { func TestReloaded(t *testing.T) {