7a3408
From fa6359064ef72968c212581e4f0011a15d809f42 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <fa6359064ef72968c212581e4f0011a15d809f42@dist-git>
7a3408
From: Martin Kletzander <mkletzan@redhat.com>
7a3408
Date: Mon, 24 Aug 2015 13:04:46 +0200
7a3408
Subject: [PATCH] security_dac: Label non-listening sockets
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1146886
7a3408
7a3408
SELinux security driver already does that, but DAC driver somehow missed
7a3408
the memo.  Let's fix it so it works the same way.
7a3408
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
(cherry picked from commit 7b6953bc2256200a5ff4b985c431bfe3c3e0cfb1)
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/security/security_dac.c | 10 +++++++++-
7a3408
 1 file changed, 9 insertions(+), 1 deletion(-)
7a3408
7a3408
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
7a3408
index deb6980..bed23c3 100644
7a3408
--- a/src/security/security_dac.c
7a3408
+++ b/src/security/security_dac.c
7a3408
@@ -789,6 +789,15 @@ virSecurityDACSetChardevLabel(virSecurityManagerPtr mgr,
7a3408
         ret = 0;
7a3408
         break;
7a3408
 
7a3408
+    case VIR_DOMAIN_CHR_TYPE_UNIX:
7a3408
+        if (!dev_source->data.nix.listen) {
7a3408
+            if (virSecurityDACSetOwnership(dev_source->data.nix.path,
7a3408
+                                           user, group) < 0)
7a3408
+                goto done;
7a3408
+        }
7a3408
+        ret = 0;
7a3408
+        break;
7a3408
+
7a3408
     case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
7a3408
     case VIR_DOMAIN_CHR_TYPE_NULL:
7a3408
     case VIR_DOMAIN_CHR_TYPE_VC:
7a3408
@@ -796,7 +805,6 @@ virSecurityDACSetChardevLabel(virSecurityManagerPtr mgr,
7a3408
     case VIR_DOMAIN_CHR_TYPE_STDIO:
7a3408
     case VIR_DOMAIN_CHR_TYPE_UDP:
7a3408
     case VIR_DOMAIN_CHR_TYPE_TCP:
7a3408
-    case VIR_DOMAIN_CHR_TYPE_UNIX:
7a3408
     case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
7a3408
     case VIR_DOMAIN_CHR_TYPE_NMDM:
7a3408
     case VIR_DOMAIN_CHR_TYPE_LAST:
7a3408
-- 
7a3408
2.5.1
7a3408