mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
util: virFirewallDGetPolicies: gracefully handle older firewalld
If the running firewalld doesn't support getPolicies() then we fallback to the "libvirt" zone. Throwing an error log is excessive since we gracefully fallback. Avoids these logs: error : virGDBusCallMethod:242 : error from service: \ GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod Fixes: ab56f84976e0 ("util: add virFirewallDGetPolicies()") Signed-off-by: Eric Garver <eric@garver.life> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
7594532ae2
commit
d5ae0cd178
@ -240,6 +240,7 @@ virFirewallDGetPolicies(char ***policies, size_t *npolicies)
|
||||
GDBusConnection *sysbus = virGDBusGetSystemBus();
|
||||
g_autoptr(GVariant) reply = NULL;
|
||||
g_autoptr(GVariant) array = NULL;
|
||||
g_autoptr(virError) error = NULL;
|
||||
|
||||
*npolicies = 0;
|
||||
*policies = NULL;
|
||||
@ -247,10 +248,12 @@ virFirewallDGetPolicies(char ***policies, size_t *npolicies)
|
||||
if (!sysbus)
|
||||
return -1;
|
||||
|
||||
error = g_new0(virError, 1);
|
||||
|
||||
if (virGDBusCallMethod(sysbus,
|
||||
&reply,
|
||||
G_VARIANT_TYPE("(as)"),
|
||||
NULL,
|
||||
error,
|
||||
VIR_FIREWALL_FIREWALLD_SERVICE,
|
||||
"/org/fedoraproject/FirewallD1",
|
||||
"org.fedoraproject.FirewallD1.policy",
|
||||
@ -258,6 +261,12 @@ virFirewallDGetPolicies(char ***policies, size_t *npolicies)
|
||||
NULL) < 0)
|
||||
return -1;
|
||||
|
||||
if (error->level == VIR_ERR_ERROR) {
|
||||
if (!virGDBusErrorIsUnknownMethod(error))
|
||||
virReportErrorObject(error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_variant_get(reply, "(@as)", &array);
|
||||
*policies = g_variant_dup_strv(array, npolicies);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user