Commit a53c9ff5 authored by Max Lv's avatar Max Lv

run nodejs in non-root user

parent d1c75d99
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-feature <uses-feature
...@@ -40,12 +39,6 @@ ...@@ -40,12 +39,6 @@
android:name=".ShadowsocksService" android:name=".ShadowsocksService"
android:enabled="true"/> android:enabled="true"/>
<receiver android:name=".ShadowsocksReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application> </application>
</manifest> </manifest>
...@@ -34,17 +34,17 @@ LOCAL_CFLAGS := -Wall -O2 -I$(LOCAL_PATH)/pdnsd ...@@ -34,17 +34,17 @@ LOCAL_CFLAGS := -Wall -O2 -I$(LOCAL_PATH)/pdnsd
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS) #include $(CLEAR_VARS)
LOCAL_MODULE := shadowsocks #LOCAL_MODULE := shadowsocks
LOCAL_SRC_FILES := shadowsocks/local.c shadowsocks/encrypt.c #LOCAL_SRC_FILES := shadowsocks/local.c shadowsocks/encrypt.c
LOCAL_CFLAGS := -Wall -O2 -I$(LOCAL_PATH)/libev/ -I$(LOCAL_PATH)/openssl/include -std=c99 #LOCAL_CFLAGS := -Wall -O2 -I$(LOCAL_PATH)/libev/ -I$(LOCAL_PATH)/openssl/include -std=c99
LOCAL_STATIC_LIBRARIES := libev libcrypto #LOCAL_STATIC_LIBRARIES := libev libcrypto
LOCAL_LDLIBS := -llog #LOCAL_LDLIBS := -llog
include $(BUILD_EXECUTABLE) #include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS) include $(CLEAR_VARS)
...@@ -57,9 +57,20 @@ LOCAL_LDLIBS := -ldl -llog ...@@ -57,9 +57,20 @@ LOCAL_LDLIBS := -ldl -llog
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
subdirs := $(addprefix $(LOCAL_PATH)/openssl/,$(addsuffix /Android.mk, \ include $(CLEAR_VARS)
crypto \
)) LOCAL_MODULE:= node
LOCAL_SRC_FILES:= \
node.c
LOCAL_LDLIBS := -ldl
include $(BUILD_SHARED_LIBRARY)
#subdirs := $(addprefix $(LOCAL_PATH)/openssl/,$(addsuffix /Android.mk, \
#crypto \
#))
include $(subdirs) #include $(subdirs)
#include <jni.h>
void Java_com_github_shadowsocks_Node_exec(JNIEnv *env, jobject thiz, jstring cmd) {
const char *str = (*env)->GetStringUTFChars(env, cmd, 0);
setenv("LD_LIBRARY_PATH", "/vendor/lib:/system/lib", 1);
setegid(getgid());
seteuid(getuid());
system(str);
(*env)->ReleaseStringUTFChars(env, cmd, str);
}
This diff is collapsed.
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
published under published under
the GPLv3. \n\nIf you have any questions, please visit the GPLv3. \n\nIf you have any questions, please visit
our project page on our project page on
googlecode. \n\n(gaeproxy.googlecode.com) googlecode. \n\n(github.com/clowwindy/shadowsocks)
</string> </string>
<string name="about">About</string> <string name="about">About</string>
<string name="proxy_type">Proxy Type</string> <string name="proxy_type">Proxy Type</string>
......
...@@ -36,11 +36,6 @@ ...@@ -36,11 +36,6 @@
</EditTextPreference> </EditTextPreference>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/fearute_cat"> <PreferenceCategory android:title="@string/fearute_cat">
<CheckBoxPreference
android:key="isAutoConnect"
android:summary="@string/auto_connect_summary"
android:title="@string/auto_connect">
</CheckBoxPreference>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="isGFWList" android:key="isGFWList"
......
package com.github.shadowsocks;
public class Node {
static {
System.loadLibrary("node");
}
public static native void exec(String cmd);
}
...@@ -103,7 +103,6 @@ public class Shadowsocks extends PreferenceActivity implements ...@@ -103,7 +103,6 @@ public class Shadowsocks extends PreferenceActivity implements
private static ProgressDialog mProgressDialog = null; private static ProgressDialog mProgressDialog = null;
private CheckBoxPreference isAutoConnectCheck;
private CheckBoxPreference isGlobalProxyCheck; private CheckBoxPreference isGlobalProxyCheck;
private EditTextPreference proxyText; private EditTextPreference proxyText;
private EditTextPreference portText; private EditTextPreference portText;
...@@ -169,7 +168,6 @@ public class Shadowsocks extends PreferenceActivity implements ...@@ -169,7 +168,6 @@ public class Shadowsocks extends PreferenceActivity implements
isGFWListCheck.setEnabled(false); isGFWListCheck.setEnabled(false);
isBypassAppsCheck.setEnabled(false); isBypassAppsCheck.setEnabled(false);
isAutoConnectCheck.setEnabled(false);
isGlobalProxyCheck.setEnabled(false); isGlobalProxyCheck.setEnabled(false);
} }
...@@ -185,7 +183,6 @@ public class Shadowsocks extends PreferenceActivity implements ...@@ -185,7 +183,6 @@ public class Shadowsocks extends PreferenceActivity implements
isBypassAppsCheck.setEnabled(true); isBypassAppsCheck.setEnabled(true);
} }
isAutoConnectCheck.setEnabled(true);
} }
private boolean isTextEmpty(String s, String msg) { private boolean isTextEmpty(String s, String msg) {
...@@ -213,7 +210,6 @@ public class Shadowsocks extends PreferenceActivity implements ...@@ -213,7 +210,6 @@ public class Shadowsocks extends PreferenceActivity implements
proxyedApps = findPreference("proxyedApps"); proxyedApps = findPreference("proxyedApps");
isRunningCheck = (CheckBoxPreference) findPreference("isRunning"); isRunningCheck = (CheckBoxPreference) findPreference("isRunning");
isAutoConnectCheck = (CheckBoxPreference) findPreference("isAutoConnect");
isGlobalProxyCheck = (CheckBoxPreference) findPreference("isGlobalProxy"); isGlobalProxyCheck = (CheckBoxPreference) findPreference("isGlobalProxy");
isGFWListCheck = (CheckBoxPreference) findPreference("isGFWList"); isGFWListCheck = (CheckBoxPreference) findPreference("isGFWList");
isBypassAppsCheck = (CheckBoxPreference) findPreference("isBypassApps"); isBypassAppsCheck = (CheckBoxPreference) findPreference("isBypassApps");
......
...@@ -57,6 +57,7 @@ import android.util.Log; ...@@ -57,6 +57,7 @@ import android.util.Log;
import com.google.analytics.tracking.android.EasyTracker; import com.google.analytics.tracking.android.EasyTracker;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -183,10 +184,15 @@ public class ShadowsocksService extends Service { ...@@ -183,10 +184,15 @@ public class ShadowsocksService extends Service {
} }
public void startShadowsocksDaemon() { public void startShadowsocksDaemon() {
final String cmd = String.format("nohup " + BASE new Thread() {
+ "node " + BASE + "local.js -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" &", @Override
appHost, remotePort, port, sitekey); public void run() {
Utils.runRootCommand(cmd); final String cmd = String.format(BASE
+ "node " + BASE + "local.js -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\"",
appHost, remotePort, port, sitekey);
Node.exec(cmd);
}
}.start();
} }
public void startDnsDaemon() { public void startDnsDaemon() {
......
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