Commit a53c9ff5 authored by Max Lv's avatar Max Lv

run nodejs in non-root user

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