[libvirt] [PATCH] lxc: Don't crash if no security driver is specified in libvirt_lxc

When no security driver is specified libvirt_lxc segfaults as a debug message tries to access security labels for the container that are not present. This problem was introduced in commit 6c3cf57d6cb27cf10064baf8cca0f39. --- src/lxc/lxc_controller.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index ea5bc58..16cda9d 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -1612,11 +1612,15 @@ int main(int argc, char *argv[]) false, false, false))) goto cleanup; - VIR_DEBUG("Security model %s type %s label %s imagelabel %s", - NULLSTR(ctrl->def->seclabels[0]->model), - virDomainSeclabelTypeToString(ctrl->def->seclabels[0]->type), - NULLSTR(ctrl->def->seclabels[0]->label), - NULLSTR(ctrl->def->seclabels[0]->imagelabel)); + if (ctrl->def->seclabels) { + VIR_DEBUG("Security model %s type %s label %s imagelabel %s", + NULLSTR(ctrl->def->seclabels[0]->model), + virDomainSeclabelTypeToString(ctrl->def->seclabels[0]->type), + NULLSTR(ctrl->def->seclabels[0]->label), + NULLSTR(ctrl->def->seclabels[0]->imagelabel)); + } else { + VIR_DEBUG("Security model not initialized"); + } ctrl->veths = veths; ctrl->nveths = nveths; -- 1.8.0

On Mon, Nov 26, 2012 at 15:22:25 +0100, Peter Krempa wrote:
When no security driver is specified libvirt_lxc segfaults as a debug message tries to access security labels for the container that are not present.
This problem was introduced in commit 6c3cf57d6cb27cf10064baf8cca0f39. --- src/lxc/lxc_controller.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
ACK Jirka

On 11/26/12 15:48, Jiri Denemark wrote:
On Mon, Nov 26, 2012 at 15:22:25 +0100, Peter Krempa wrote:
When no security driver is specified libvirt_lxc segfaults as a debug message tries to access security labels for the container that are not present.
This problem was introduced in commit 6c3cf57d6cb27cf10064baf8cca0f39. --- src/lxc/lxc_controller.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
ACK
Jirka
Pushed, thanks. Peter
participants (2)
-
Jiri Denemark
-
Peter Krempa