]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add missing stubs to securityselinuxhelper.c
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 14 Jan 2013 18:33:44 +0000 (18:33 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 14 Jan 2013 18:34:49 +0000 (18:34 +0000)
Make sure we override both the raw and non-raw stubs in
securityselinuxhelper.c. Also add diagnostics if
securityselinuxlabeltest fails a test item

tests/securityselinuxhelper.c
tests/securityselinuxlabeltest.c

index daad7dd43fa74a28f8024c8db4a882a747f5bb51..abe4d7cc49660037fd4bee3720e06d08d3229f79 100644 (file)
@@ -46,6 +46,11 @@ int getcon_raw(security_context_t *context)
     return 0;
 }
 
+int getcon(security_context_t *context)
+{
+    return getcon_raw(context);
+}
+
 int getpidcon_raw(pid_t pid, security_context_t *context)
 {
     if (pid != getpid()) {
@@ -63,22 +68,36 @@ int getpidcon_raw(pid_t pid, security_context_t *context)
     return 0;
 }
 
+int getpidcon(pid_t pid, security_context_t *context)
+{
+    return getpidcon_raw(pid, context);
+}
+
 int setcon_raw(security_context_t context)
 {
     return setenv("FAKE_CONTEXT", context, 1);
 }
 
+int setcon(security_context_t context)
+{
+    return setcon_raw(context);
+}
+
 
 #if WITH_ATTR
-int setfilecon(const char *path, security_context_t con)
+int setfilecon_raw(const char *path, security_context_t con)
 {
     const char *constr = con;
     return setxattr(path, "user.libvirt.selinux",
                     constr, strlen(constr), 0);
 }
 
+int setfilecon(const char *path, security_context_t con)
+{
+    return setfilecon_raw(path, con);
+}
 
-int getfilecon(const char *path, security_context_t *con)
+int getfilecon_raw(const char *path, security_context_t *con)
 {
     char *constr = NULL;
     ssize_t len = getxattr(path, "user.libvirt.selinux",
@@ -96,4 +115,8 @@ int getfilecon(const char *path, security_context_t *con)
     constr[len] = '\0';
     return 0;
 }
+int getfilecon(const char *path, security_context_t *con)
+{
+    return getfilecon_raw(path, con);
+}
 #endif
index b108860f2311f45bbf8dfc814f0ecdab069f8228..c0bb09b5bc9977f546e7482db68b2a01c081ecf8 100644 (file)
@@ -300,6 +300,10 @@ cleanup:
         VIR_FREE(files[i].context);
     }
     VIR_FREE(files);
+    if (ret < 0 && virTestGetVerbose()) {
+        virErrorPtr err = virGetLastError();
+        fprintf(stderr, "%s\n", err ? err->message : "<unknown>");
+    }
     return ret;
 }