Commit 6c6100d0 authored by Nick Kralevich's avatar Nick Kralevich Committed by Android Git Automerger
Browse files

am c1398d50: am 8e99dfe1: am a1f6b095: FileSystemPermissionTest: assert /system mounted RO

* commit 'c1398d50':
  FileSystemPermissionTest: assert /system mounted RO
parents e06f84d4 c1398d50
......@@ -23,10 +23,12 @@ import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.LargeTest;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
......@@ -583,6 +585,34 @@ public class FileSystemPermissionTest extends AndroidTestCase {
return retval;
}
/**
* Scan through /proc/self/mounts, looking for the /system line. If the line
* has "ro" in the 4th column, then we know the filesystem is mounted read-only.
*/
public void testSystemMountedRO() throws IOException {
BufferedReader br = new BufferedReader(new FileReader("/proc/self/mounts"));
String line;
boolean foundSystem = false;
while((line = br.readLine()) != null) {
String[] fields = line.split(" ");
String mountPoint = fields[1];
if ("/system".equals(mountPoint)) {
foundSystem = true;
String all_options = fields[3];
boolean foundRo = false;
String[] options = all_options.split(",");
for (String option : options) {
if ("ro".equals(option)) {
foundRo = true;
break;
}
}
assertTrue(mountPoint + " is not mounted read-only", foundRo);
}
}
assertTrue("Cannot find /system partition", foundSystem);
}
public void testAllBlockDevicesAreSecure() throws Exception {
Set<File> insecure = getAllInsecureBlockDevicesInDirAndSubdir(new File("/dev"));
assertTrue("Found insecure: " + insecure.toString(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment