From ba7b867b461f3bf154d2dd9a46b9a423120fcecb Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 2 May 2013 16:55:52 +0100 Subject: [PATCH] Set conn->driver before running driver connectOpen method The access control checks in the 'connectOpen' driver method will require 'conn->driver' to be non-NULL. Set this before running the 'connectOpen' method and NULL-ify it again on failure. Signed-off-by: Daniel P. Berrange --- src/libvirt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libvirt.c b/src/libvirt.c index b467679d0b..8e8f415cac 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1201,6 +1201,7 @@ do_open(const char *name, } VIR_DEBUG("trying driver %d (%s) ...", i, virDriverTab[i]->name); + ret->driver = virDriverTab[i]; res = virDriverTab[i]->connectOpen(ret, auth, flags); VIR_DEBUG("driver %d %s returned %s", i, virDriverTab[i]->name, @@ -1209,10 +1210,12 @@ do_open(const char *name, (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status"))); if (res == VIR_DRV_OPEN_SUCCESS) { - ret->driver = virDriverTab[i]; break; } else if (res == VIR_DRV_OPEN_ERROR) { + ret->driver = NULL; goto failed; + } else { + ret->driver = NULL; } } -- 2.39.5