* Speed improvements on DropBearInstaller/Remover
* Possible fix on wrong install return code (with full paths)master
parent
d7737ae256
commit
b29bca2eea
|
@ -62,7 +62,7 @@ public class DropbearInstaller extends AsyncTask<Void, String, Boolean> {
|
|||
Log.i(TAG, "DropbearInstaller: doInBackground()");
|
||||
|
||||
int step = 0;
|
||||
int steps = 22;
|
||||
int steps = 14;
|
||||
|
||||
String dropbear = ServerUtils.getLocalDir(mContext) + "/dropbear";
|
||||
String dropbearkey = ServerUtils.getLocalDir(mContext) + "/dropbearkey";
|
||||
|
@ -72,12 +72,6 @@ public class DropbearInstaller extends AsyncTask<Void, String, Boolean> {
|
|||
String host_dss = ServerUtils.getLocalDir(mContext) + "/host_dss";
|
||||
String authorized_keys = ServerUtils.getLocalDir(mContext) + "/authorized_keys";
|
||||
String lock = ServerUtils.getLocalDir(mContext) + "/lock";
|
||||
|
||||
// system rw
|
||||
publishProgress("" + step++, "" + steps, "/system Read-Write");
|
||||
if (ShellUtils.remountReadWrite("/system") == false) {
|
||||
return falseWithError("/system");
|
||||
}
|
||||
|
||||
// dropbear
|
||||
publishProgress("" + step++, "" + steps, "Dropbear binary");
|
||||
|
@ -85,16 +79,8 @@ public class DropbearInstaller extends AsyncTask<Void, String, Boolean> {
|
|||
return falseWithError(dropbear);
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "Dropbear binary");
|
||||
if (ShellUtils.lnSymbolic(dropbear, "/system/xbin/dropbear") == false) {
|
||||
return falseWithError("/system/xbin/dropbear");
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "Dropbear binary");
|
||||
if (ShellUtils.chown("/system/xbin/dropbear", "0:0") == false) {
|
||||
return falseWithError("/system/xbin/dropbear");
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "Dropbear binary");
|
||||
if (ShellUtils.chmod("/system/xbin/dropbear", "755") == false) {
|
||||
return falseWithError("/system/xbin/dropbear");
|
||||
if (ShellUtils.chmod(dropbear, "755") == false) {
|
||||
return falseWithError(dropbear);
|
||||
}
|
||||
|
||||
// dropbearkey
|
||||
|
@ -103,16 +89,8 @@ public class DropbearInstaller extends AsyncTask<Void, String, Boolean> {
|
|||
return falseWithError(dropbearkey);
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "Dropbearkey binary");
|
||||
if (ShellUtils.lnSymbolic(dropbearkey, "/system/xbin/dropbearkey") == false) {
|
||||
return falseWithError("/system/xbin/dropbearkey");
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "Dropbearkey binary");
|
||||
if (ShellUtils.chown("/system/xbin/dropbearkey", "0:0") == false) {
|
||||
return falseWithError("/system/xbin/dropbearkey");
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "Dropbearkey binary");
|
||||
if (ShellUtils.chmod("/system/xbin/dropbearkey", "755") == false) {
|
||||
return falseWithError("/system/xbin/dropbearkey");
|
||||
if (ShellUtils.chmod(dropbearkey, "755") == false) {
|
||||
return falseWithError(dropbearkey);
|
||||
}
|
||||
|
||||
// scp
|
||||
|
@ -121,16 +99,8 @@ public class DropbearInstaller extends AsyncTask<Void, String, Boolean> {
|
|||
return falseWithError(scp);
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "SCP binary");
|
||||
if (ShellUtils.lnSymbolic(scp, "/system/xbin/scp") == false) {
|
||||
return falseWithError("/system/xbin/scp");
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "SCP binary");
|
||||
if (ShellUtils.chown("/system/xbin/scp", "0:0") == false) {
|
||||
return falseWithError("/system/xbin/scp");
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "SCP binary");
|
||||
if (ShellUtils.chmod("/system/xbin/scp", "755") == false) {
|
||||
return falseWithError("/system/xbin/scp");
|
||||
if (ShellUtils.chmod(scp, "755") == false) {
|
||||
return falseWithError(scp);
|
||||
}
|
||||
|
||||
// banner
|
||||
|
@ -174,12 +144,6 @@ public class DropbearInstaller extends AsyncTask<Void, String, Boolean> {
|
|||
if (ShellUtils.echoToFile("0", lock) == false) {
|
||||
return falseWithError(lock);
|
||||
}
|
||||
|
||||
// system ro
|
||||
publishProgress("" + step++, "" + steps, "/system Read-Only");
|
||||
if (ShellUtils.remountReadOnly("/system") == false) {
|
||||
return falseWithError("/system");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class DropbearRemover extends AsyncTask<Void, String, Boolean> {
|
|||
Log.i(TAG, "DropbearRemover: doInBackground()");
|
||||
|
||||
int step = 0;
|
||||
int steps = 13;
|
||||
int steps = 8;
|
||||
|
||||
String dropbear = ServerUtils.getLocalDir(mContext) + "/dropbear";
|
||||
String dropbearkey = ServerUtils.getLocalDir(mContext) + "/dropbearkey";
|
||||
|
@ -77,38 +77,20 @@ public class DropbearRemover extends AsyncTask<Void, String, Boolean> {
|
|||
String authorized_keys = ServerUtils.getLocalDir(mContext) + "/authorized_keys";
|
||||
String lock = ServerUtils.getLocalDir(mContext) + "/lock";
|
||||
|
||||
// system rw
|
||||
publishProgress("" + step++, "" + steps, "/system Read-Write");
|
||||
if (ShellUtils.remountReadWrite("/system") == false) {
|
||||
return falseWithError("/system");
|
||||
}
|
||||
|
||||
// dropbear
|
||||
publishProgress("" + step++, "" + steps, "Dropbear binary");
|
||||
if (ShellUtils.rm("/system/xbin/dropbear") == false) {
|
||||
return falseWithError("/system/xbin/dropbear");
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "Dropbear binary");
|
||||
if (ShellUtils.rm(dropbear) == false) {
|
||||
return falseWithError(dropbear);
|
||||
}
|
||||
|
||||
// dropbearkey
|
||||
publishProgress("" + step++, "" + steps, "Dropbearkey binary");
|
||||
if (ShellUtils.rm("/system/xbin/dropbearkey") == false) {
|
||||
return falseWithError("/system/xbin/dropbearkey");
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "Dropbearkey binary");
|
||||
if (ShellUtils.rm(dropbearkey) == false) {
|
||||
return falseWithError(dropbearkey);
|
||||
}
|
||||
|
||||
// scp
|
||||
publishProgress("" + step++, "" + steps, "SCP binary");
|
||||
if (ShellUtils.rm("/system/xbin/scp") == false) {
|
||||
return falseWithError("/system/xbin/scp");
|
||||
}
|
||||
publishProgress("" + step++, "" + steps, "SCP binary");
|
||||
if (ShellUtils.rm(scp) == false) {
|
||||
return falseWithError(scp);
|
||||
}
|
||||
|
@ -142,12 +124,6 @@ public class DropbearRemover extends AsyncTask<Void, String, Boolean> {
|
|||
if (ShellUtils.rm(lock) == false) {
|
||||
return falseWithError(lock);
|
||||
}
|
||||
|
||||
// system ro
|
||||
publishProgress("" + step++, "" + steps, "/system Read-Only");
|
||||
if (ShellUtils.remountReadOnly("/system") == false) {
|
||||
return falseWithError("/system");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -52,17 +52,17 @@ public abstract class RootUtils {
|
|||
File file = null;
|
||||
|
||||
file = new File(ServerUtils.getLocalDir(context) + "/dropbear");
|
||||
if (file.exists() == false || file.isFile() == false) {
|
||||
if (file.exists() == false || file.isFile() == false || file.canExecute() == false) {
|
||||
Log.w(TAG, "RootUtils: checkDropear(): dropbear");
|
||||
return false;
|
||||
}
|
||||
file = new File(ServerUtils.getLocalDir(context) + "/dropbearkey");
|
||||
if (file.exists() == false || file.isFile() == false) {
|
||||
if (file.exists() == false || file.isFile() == false || file.canExecute() == false) {
|
||||
Log.w(TAG, "RootUtils: checkDropear(): dropbearkey");
|
||||
return false;
|
||||
}
|
||||
file = new File(ServerUtils.getLocalDir(context) + "/scp");
|
||||
if (file.exists() == false || file.isFile() == false) {
|
||||
if (file.exists() == false || file.isFile() == false || file.canExecute() == false) {
|
||||
Log.w(TAG, "RootUtils: checkDropear(): scp");
|
||||
return false;
|
||||
}
|
||||
|
@ -77,38 +77,21 @@ public abstract class RootUtils {
|
|||
return false;
|
||||
}
|
||||
file = new File(ServerUtils.getLocalDir(context) + "/authorized_keys");
|
||||
if (file.exists() == false || file.isFile() == false || file.canRead() == false) {
|
||||
if (file.exists() == false || file.isFile() == false) {
|
||||
Log.w(TAG, "RootUtils: checkDropear(): authorized_keys");
|
||||
return false;
|
||||
}
|
||||
file = new File(ServerUtils.getLocalDir(context) + "/banner");
|
||||
if (file.exists() == false || file.isFile() == false || file.canRead() == false) {
|
||||
if (file.exists() == false || file.isFile() == false) {
|
||||
Log.w(TAG, "RootUtils: checkDropear(): banner");
|
||||
return false;
|
||||
}
|
||||
file = new File(ServerUtils.getLocalDir(context) + "/lock");
|
||||
if (file.exists() == false || file.isFile() == false || file.canRead() == false) {
|
||||
if (file.exists() == false || file.isFile() == false) {
|
||||
Log.w(TAG, "RootUtils: checkDropear(): lock");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
file = new File("/system/xbin/dropbear");
|
||||
if (file.exists() == false || file.isFile() == false) {
|
||||
Log.w(TAG, "RootUtils: checkDropear(): dropbear");
|
||||
return false;
|
||||
}
|
||||
file = new File("/system/xbin/dropbearkey");
|
||||
if (file.exists() == false || file.isFile() == false) {
|
||||
Log.w(TAG, "RootUtils: checkDropear(): dropbearkey");
|
||||
return false;
|
||||
}
|
||||
file = new File("/system/xbin/scp");
|
||||
if (file.exists() == false || file.isFile() == false) {
|
||||
Log.w(TAG, "RootUtils: checkDropear(): scp");
|
||||
return false;
|
||||
}
|
||||
|
||||
hasDropbear = true;
|
||||
|
||||
return hasDropbear;
|
||||
|
|
|
@ -56,13 +56,10 @@ public abstract class ServerUtils {
|
|||
HttpGet httpget = new HttpGet("http://ifconfig.me/ip");
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
HttpEntity entity = response.getEntity();
|
||||
Log.d(TAG, "=1=");
|
||||
|
||||
if (entity != null) {
|
||||
Log.d(TAG, "=2=");
|
||||
long len = entity.getContentLength();
|
||||
if (len != -1 && len < 1024) {
|
||||
Log.d(TAG, "=3=");
|
||||
externalIpAddress = EntityUtils.toString(entity);
|
||||
Log.d(TAG, "ServerUtils: getExternalIpAddress(): " + externalIpAddress);
|
||||
return externalIpAddress;
|
||||
|
@ -163,13 +160,13 @@ public abstract class ServerUtils {
|
|||
|
||||
// WARNING: this is not threaded
|
||||
public static final Boolean generateRsaPrivateKey(String path) {
|
||||
ShellUtils.commands.add("/system/xbin/dropbearkey -t rsa -f " + path);
|
||||
ShellUtils.commands.add(ServerUtils.getLocalDir(null) + "/dropbearkey -t rsa -f " + path);
|
||||
return ShellUtils.execute();
|
||||
}
|
||||
|
||||
// WARNING: this is not threaded
|
||||
public static final Boolean generateDssPrivateKey(String path) {
|
||||
ShellUtils.commands.add("/system/xbin/dropbearkey -t dss -f " + path);
|
||||
ShellUtils.commands.add(ServerUtils.getLocalDir(null) + "/dropbearkey -t dss -f " + path);
|
||||
return ShellUtils.execute();
|
||||
}
|
||||
|
||||
|
@ -312,7 +309,7 @@ public abstract class ServerUtils {
|
|||
// stdin
|
||||
DataOutputStream stdin = new DataOutputStream(suProcess.getOutputStream());
|
||||
Log.d(TAG, "ServerUtils: getDropbearVersion(): # dropbear -h");
|
||||
stdin.writeBytes("dropbear -h 2>&1 | busybox head -1\n");
|
||||
stdin.writeBytes(ServerUtils.getLocalDir(null) + "/dropbear -h 2>&1 | busybox head -1\n");
|
||||
stdin.flush();
|
||||
stdin.writeBytes("exit\n");
|
||||
stdin.flush();
|
||||
|
|
Loading…
Reference in New Issue