From 39c198ac6f98cd197c4bd77c727a3d1e6df2f619 Mon Sep 17 00:00:00 2001
From: James Hawkins <jhawkins@google.com>
Date: Tue, 19 Jan 2016 10:54:20 -0800
Subject: [PATCH] bootstat: Implement the SELinux policy to allow
 reading/writing to /data/misc/bootstat.

BUG: 21724738
Change-Id: I2789f57cc8182af1a7c33672ef82297f32f54e2e
---
 bootstat.te   | 9 +++++++++
 file.te       | 1 +
 file_contexts | 1 +
 3 files changed, 11 insertions(+)
 create mode 100644 bootstat.te

diff --git a/bootstat.te b/bootstat.te
new file mode 100644
index 000000000..14b4eceba
--- /dev/null
+++ b/bootstat.te
@@ -0,0 +1,9 @@
+# bootstat command
+type bootstat, domain;
+type bootstat_exec, exec_type, file_type;
+
+init_daemon_domain(bootstat)
+
+# Allow persistent storage in /data/misc/bootstat.
+allow bootstat bootstat_data_file:dir rw_dir_perms;
+allow bootstat bootstat_data_file:file create_file_perms;
diff --git a/file.te b/file.te
index 0c965a38b..81ff887af 100644
--- a/file.te
+++ b/file.te
@@ -111,6 +111,7 @@ type storage_stub_file, file_type;
 type adb_keys_file, file_type, data_file_type;
 type audio_data_file, file_type, data_file_type;
 type bluetooth_data_file, file_type, data_file_type;
+type bootstat_data_file, file_type, data_file_type;
 type boottrace_data_file, file_type, data_file_type;
 type camera_data_file, file_type, data_file_type;
 type gatekeeper_data_file, file_type, data_file_type;
diff --git a/file_contexts b/file_contexts
index 1cd5fbaf5..78964cbf6 100644
--- a/file_contexts
+++ b/file_contexts
@@ -251,6 +251,7 @@
 # Misc data
 /data/misc/adb(/.*)?            u:object_r:adb_keys_file:s0
 /data/misc/audio(/.*)?          u:object_r:audio_data_file:s0
+/data/misc/bootstat(/.*)?       u:object_r:bootstat_data_file:s0
 /data/misc/boottrace(/.*)?      u:object_r:boottrace_data_file:s0
 /data/misc/bluetooth(/.*)?      u:object_r:bluetooth_data_file:s0
 /data/misc/bluedroid(/.*)?      u:object_r:bluetooth_data_file:s0
-- 
GitLab