зеркало из https://github.com/mozilla/gecko-dev.git
Bug 879489 - SUTAgent - Make sure /data/local/tmp is a directory and is writable, r=jmaher. DONTBUILD
This commit is contained in:
Родитель
08ac38eb57
Коммит
a52e529c14
|
@ -1353,20 +1353,29 @@ private void CancelNotification()
|
|||
return(sRet);
|
||||
}
|
||||
|
||||
public void FixDataLocalPermissions()
|
||||
{
|
||||
String chmodResult;
|
||||
File localDir = new java.io.File("/data/local");
|
||||
if (!localDir.canWrite()) {
|
||||
chmodResult = ChmodDir("/data/local");
|
||||
Log.i("SUTAgentAndroid", "Changed permissions on /data/local to make it writable: " + chmodResult);
|
||||
}
|
||||
File tmpDir = new java.io.File("/data/local/tmp");
|
||||
if (tmpDir.exists() && !tmpDir.isDirectory()) {
|
||||
if (!tmpDir.delete()) {
|
||||
Log.e("SUTAgentAndroid", "Could not delete file /data/local/tmp");
|
||||
}
|
||||
}
|
||||
if (!tmpDir.exists() && !tmpDir.mkdirs()) {
|
||||
Log.e("SUTAgentAndroid", "Could not create directory /data/local/tmp");
|
||||
}
|
||||
chmodResult = ChmodDir("/data/local/tmp");
|
||||
Log.i("SUTAgentAndroid", "Changed permissions on /data/local/tmp to make it writable: " + chmodResult);
|
||||
}
|
||||
|
||||
public String GetTestRoot()
|
||||
{
|
||||
|
||||
// According to all the docs this should work, but I keep getting an
|
||||
// exception when I attempt to create the file because I don't have
|
||||
// permission, although /data/local/tmp is supposed to be world
|
||||
// writeable/readable
|
||||
File tmpFile = new java.io.File("/data/local/tmp/tests");
|
||||
try{
|
||||
tmpFile.createNewFile();
|
||||
} catch (IOException e){
|
||||
Log.i("SUTAgentAndroid", "Caught exception creating file in /data/local/tmp: " + e.getMessage());
|
||||
}
|
||||
|
||||
String state = Environment.getExternalStorageState();
|
||||
// Ensure sdcard is mounted and NOT read only
|
||||
if (state.equalsIgnoreCase(Environment.MEDIA_MOUNTED) &&
|
||||
|
@ -1374,8 +1383,15 @@ private void CancelNotification()
|
|||
{
|
||||
return(Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||
}
|
||||
if (tmpFile.exists())
|
||||
File tmpFile = new java.io.File("/data/local/tmp/tests");
|
||||
try{
|
||||
tmpFile.createNewFile();
|
||||
} catch (IOException e){
|
||||
Log.i("SUTAgentAndroid", "Caught exception creating file in /data/local/tmp: " + e.getMessage());
|
||||
}
|
||||
if (tmpFile.exists())
|
||||
{
|
||||
tmpFile.delete();
|
||||
return("/data/local");
|
||||
}
|
||||
Log.e("SUTAgentAndroid", "ERROR: Cannot access world writeable test root");
|
||||
|
@ -3828,7 +3844,7 @@ private void CancelNotification()
|
|||
else {
|
||||
// set the new file's permissions to rwxrwxrwx, if possible
|
||||
try {
|
||||
Process pProc = Runtime.getRuntime().exec("chmod 777 "+files[lcv]);
|
||||
Process pProc = Runtime.getRuntime().exec(this.getSuArgs("chmod 777 "+files[lcv]));
|
||||
RedirOutputThread outThrd = new RedirOutputThread(pProc, null);
|
||||
outThrd.start();
|
||||
outThrd.joinAndStopRedirect(5000);
|
||||
|
@ -3848,7 +3864,7 @@ private void CancelNotification()
|
|||
|
||||
// set the new directory's (or file's) permissions to rwxrwxrwx, if possible
|
||||
try {
|
||||
Process pProc = Runtime.getRuntime().exec("chmod 777 "+sTmpDir);
|
||||
Process pProc = Runtime.getRuntime().exec(this.getSuArgs("chmod 777 "+sTmpDir));
|
||||
RedirOutputThread outThrd = new RedirOutputThread(pProc, null);
|
||||
outThrd.start();
|
||||
outThrd.joinAndStopRedirect(5000);
|
||||
|
|
|
@ -162,6 +162,8 @@ public class SUTAgentAndroid extends Activity
|
|||
|
||||
DoCommand dc = new DoCommand(getApplication());
|
||||
|
||||
dc.FixDataLocalPermissions();
|
||||
|
||||
// Get configuration settings from "ini" file
|
||||
File dir = getFilesDir();
|
||||
File iniFile = new File(dir, "SUTAgent.ini");
|
||||
|
|
Загрузка…
Ссылка в новой задаче