diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index a80bc3fe3a..e71c95fcb8 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6417,7 +6417,7 @@ libxlDomainInterfaceAddresses(virDomainPtr dom, if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) + if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def, source) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 46a182be45..fb39a67326 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1699,7 +1699,7 @@ lxcDomainInterfaceAddresses(virDomainPtr dom, if (!(vm = lxcDomObjFromDomain(dom))) goto cleanup; - if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) + if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def, source) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 6fa48c06e3..05ad7a31a8 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2166,6 +2166,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, /* Has to be freed for each interface. */ virStringListFree(ifname); + ifname = NULL; /* as well as IP address which - moreover - * can be presented multiple times */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a5b38b3d24..b5ea445d8a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22071,7 +22071,7 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; - if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) + if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def, source) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index d4393680e9..f4d6147676 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3805,6 +3805,7 @@ enum remote_procedure { * * - @acl: : * - @acl: :: + * - @acl: :::: * * Declare the access control requirements for the API. May be repeated * multiple times, if multiple rules are required. @@ -3814,6 +3815,8 @@ enum remote_procedure { * is one of the permissions in access/viraccessperm.h * indicates the rule only applies if the named flag * is set in the API call + * and can be used to check an unsigned int parameter + * against value * * - @aclfilter: : * @@ -6208,6 +6211,7 @@ enum remote_procedure { /** * @generate: none * @acl: domain:read + * @acl: domain:write::source:VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT */ REMOTE_PROC_DOMAIN_INTERFACE_ADDRESSES = 353, diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 0b2ae59910..590a46ef66 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -2111,17 +2111,22 @@ elsif ($mode eq "client") { my @acl; foreach (@{$acl}) { my @bits = split /:/; - push @acl, { object => $bits[0], perm => $bits[1], flags => $bits[2] } + push @acl, { object => $bits[0], perm => $bits[1], flags => $bits[2], + param => $bits[3], value => $bits[4] } } my $checkflags = 0; + my $paramtocheck = undef; for (my $i = 1 ; $i <= $#acl ; $i++) { if ($acl[$i]->{object} ne $acl[0]->{object}) { die "acl for '$call->{ProcName}' cannot check different objects"; } - if (defined $acl[$i]->{flags}) { + if (defined $acl[$i]->{flags} && length $acl[$i]->{flags}) { $checkflags = 1; } + if (defined $acl[$i]->{param}) { + $paramtocheck = $acl[$i]->{param}; + } } my $apiname = $prefix . $call->{ProcName}; @@ -2157,6 +2162,9 @@ elsif ($mode eq "client") { if ($checkflags) { push @argdecls, "unsigned int flags"; } + if (defined $paramtocheck) { + push @argdecls, "unsigned int " . $paramtocheck; + } my $ret; my $pass; @@ -2207,7 +2215,7 @@ elsif ($mode eq "client") { my $method = "virAccessManagerCheck" . $object; my $space = ' ' x length($method); print " if ("; - if (defined $acl->{flags}) { + if (defined $acl->{flags} && length $acl->{flags}) { my $flags = $acl->{flags}; if ($flags =~ /^\!/) { $flags = substr $flags, 1; @@ -2217,6 +2225,17 @@ elsif ($mode eq "client") { } print " "; } + if (defined $acl->{param}) { + my $param = $acl->{param}; + my $value = $acl->{value}; + if ($value =~ /^\!/) { + $value = substr $value, 1; + print "($param != ($value)) &&\n"; + } else { + print "($param == ($value)) &&\n"; + } + print " "; + } print "(rv = $method(" . join(", ", @argvars, $perm) . ")) <= 0) {\n"; print " virObjectUnref(mgr);\n"; if ($action eq "Ensure") {