2013-07-17 15:45:20 +00:00
|
|
|
#!/system/bin/sh
|
|
|
|
|
|
|
|
L="log -p i -t SELinuxLabel"
|
|
|
|
|
|
|
|
# Bail out early if not on a SELinux build
|
|
|
|
getprop ro.build.selinux | grep -q 1 || exit
|
|
|
|
if [ ! -f /file_contexts ]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
LABELDATA=0
|
2013-12-07 15:20:17 +00:00
|
|
|
LABELDALVIKCACHE=0
|
2013-07-17 15:45:20 +00:00
|
|
|
|
|
|
|
# Test /data
|
2013-07-18 14:41:06 +00:00
|
|
|
ls -Zd /data/system | grep -q unlabeled
|
2013-07-17 15:45:20 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
$L "userdata is unlabeled, fixing..."
|
|
|
|
LABELDATA=1
|
|
|
|
fi
|
|
|
|
|
2013-12-31 17:59:54 +00:00
|
|
|
# Double-check other files under /data
|
2013-12-28 11:08:52 +00:00
|
|
|
ls -Z /data/misc/wifi/wpa_supplicant.conf | grep -q "wifi_"
|
|
|
|
if [ $? -eq 1 ]; then
|
2013-12-31 17:59:54 +00:00
|
|
|
$L "data is mis-labeled, fixing..."
|
2013-12-28 11:08:52 +00:00
|
|
|
LABELDATA=1
|
|
|
|
fi
|
|
|
|
|
2013-12-07 15:20:17 +00:00
|
|
|
ls -Zd /data/dalvik-cache | grep -q unlabeled
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
$L "dalvik-cache is unlabeled, fixing..."
|
|
|
|
LABELDALVIKCACHE=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
ls -Zd /cache/dalvik-cache | grep -q unlabeled
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
$L "dalvik-cache is unlabeled, fixing..."
|
|
|
|
LABELDALVIKCACHE=1
|
|
|
|
fi
|
|
|
|
|
2013-07-17 15:45:20 +00:00
|
|
|
|
|
|
|
if [ $LABELDATA = "1" ]; then
|
|
|
|
$L "/data relabel starting..."
|
|
|
|
restorecon -R /data
|
|
|
|
$L "/data relabel complete"
|
2013-07-18 14:46:28 +00:00
|
|
|
$L "/cache relabel starting..."
|
|
|
|
restorecon -R /cache
|
|
|
|
$L "/cache relabel complete"
|
2013-07-17 15:45:20 +00:00
|
|
|
fi
|
2013-12-07 15:20:17 +00:00
|
|
|
|
|
|
|
if [ $LABELDALVIKCACHE = "1" ]; then
|
|
|
|
$L "dalvik-cache relabel starting..."
|
|
|
|
restorecon -R /data/dalvik-cache
|
|
|
|
restorecon -R /cache/dalvik-cache
|
|
|
|
$L "dalvik-cache relabel complete"
|
|
|
|
fi
|