Blob Blame History Raw
From 83f08959d1bfaadc05581703780534ed5ed7ba82 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <me@zygoon.pl>
Date: Wed, 2 Nov 2016 12:37:37 +0200
Subject: [PATCH] Set a context on the mount units

---
 systemd/systemd.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/systemd/systemd.go b/systemd/systemd.go
index a3f6c9e..32e0ebb 100644
--- a/systemd/systemd.go
+++ b/systemd/systemd.go
@@ -438,14 +438,20 @@ func MountUnitPath(baseDir, ext string) string {
 
 func (s *systemd) WriteMountUnitFile(name, what, where, fstype string) (string, error) {
 	extra := ""
+	var options []string
+	var extra string
 	if osutil.IsDirectory(what) {
-		extra = "Options=bind\n"
+		options = append(options, "bind")
 		fstype = "none"
 	}
 
+	options = append(options, `context="system_u:object_r:snappy_var_lib_t:s0"`)
 	if fstype == "squashfs" && useFuse() {
 		fstype = "fuse.squashfuse"
 	}
+	if len(options) > 0 {
+		extra = fmt.Sprintf("Options=%s\n", strings.Join(options, ","))
+	}
 
 	c := fmt.Sprintf(`[Unit]
 Description=Mount unit for %s
-- 
2.7.4