[libvirt] [PATCH] virsh: check actual access to the cert

Doug Goldstein cardoe at gentoo.org
Fri May 6 16:24:25 UTC 2011


Instead of calling stat(), check that we'll actually be able to access
and read the file.

Signed-off-by: Doug Goldstein <cardoe at gentoo.org>
---
 src/remote/remote_driver.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 9965d38..c4e43aa 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1140,8 +1140,7 @@ static gnutls_certificate_credentials_t x509_cred;
 static int
 check_cert_file(const char *type, const char *file)
 {
-    struct stat sb;
-    if (stat(file, &sb) < 0) {
+    if (access(file, F_OK|R_OK)) {
         virReportSystemError(errno,
                              _("Cannot access %s '%s'"),
                              type, file);
-- 
1.7.5.rc3




More information about the libvir-list mailing list