From d8b363c35fa7326ecef78b7877c7fe87e8cfa615 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Mon, 17 Mar 2008 15:09:38 +0000 Subject: [PATCH] Cope with missing selinux attribute --- ChangeLog | 5 +++++ src/storage_backend.c | 25 +++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5fadb1f044..5b92497f47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Mar 17 11:09:22 EDT 2008 Daniel P. Berrange + + * src/storage_backend.c: Cope with missing SELinux context + data by ignoring the error + Mon Mar 17 11:46:09 CET 2008 Daniel Veillard * src/libvirt.c docs/libvirt-*.xml docs/html/libvirt-libvirt.html: diff --git a/src/storage_backend.c b/src/storage_backend.c index da0f34a1fa..9702de3392 100644 --- a/src/storage_backend.c +++ b/src/storage_backend.c @@ -240,17 +240,22 @@ virStorageBackendUpdateVolInfoFD(virConnectPtr conn, #if HAVE_SELINUX if (fgetfilecon(fd, &filecon) == -1) { - virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, - _("cannot get file context of %s: %s"), - vol->target.path, strerror(errno)); - return -1; + if (errno != ENODATA) { + virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("cannot get file context of %s: %s"), + vol->target.path, strerror(errno)); + return -1; + } else { + vol->target.perms.label = NULL; + } + } else { + vol->target.perms.label = strdup(filecon); + if (vol->target.perms.label == NULL) { + virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("context")); + return -1; + } + freecon(filecon); } - vol->target.perms.label = strdup(filecon); - if (vol->target.perms.label == NULL) { - virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("context")); - return -1; - } - freecon(filecon); #else vol->target.perms.label = NULL; #endif