From ba1a73156b262806e656b75101349d2e6e16a471 Mon Sep 17 00:00:00 2001
From: Nick Kralevich <nnk@google.com>
Date: Fri, 24 Jan 2014 15:46:27 -0800
Subject: [PATCH] allow wpa_cli to work.

With wpa_supplicant in enforcing, wpa_cli doesn't work.

Denial:

type=1400 audit(1390597866.260:59): avc:  denied  { write } for  pid=3410 comm="wpa_supplicant" name="wpa_ctrl_4852-1" dev="mmcblk0p28" ino=618993 scontext=u:r:wpa:s0 tcontext=u:object_r:wifi_data_file:s0 tclass=sock_file

After I9e35cc93abf89ce3594860aa3193f84a3b42ea6e and
I51b09c5e40946673a38732ea9f601b2d047d3b62, the /data/misc/wifi/sockets
directory is labeled properly. This change allows the communication
between the su domain and wpa.

Steps to reproduce:
  Start wifi (so wpa_supplicant will run)
  Start wpa_cli - it will hand
  $ adb root
  $ adb shell
  # wpa_cli -g @android:wpa_wlan0

Bug: 12721629
Change-Id: I03170acc155ad122c5197baaf590d17fc1ace6a5
---
 wpa_supplicant.te | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/wpa_supplicant.te b/wpa_supplicant.te
index de1eb5ddb..1ebf55602 100644
--- a/wpa_supplicant.te
+++ b/wpa_supplicant.te
@@ -19,3 +19,9 @@ allow wpa random_device:chr_file r_file_perms;
 type_transition wpa wifi_data_file:sock_file wpa_socket;
 allow wpa wpa_socket:dir { rw_dir_perms setattr };
 allow wpa wpa_socket:sock_file create_file_perms;
+
+# Allow wpa_cli to work. wpa_cli creates a socket in
+# /data/misc/wifi/sockets which wpa supplicant communicates with.
+userdebug_or_eng(`
+  unix_socket_send(wpa, wpa, su)
+')
-- 
GitLab