From a53c9ff5ce4d0ef892d96dc128e91a322e55a965 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sun, 16 Dec 2012 15:17:53 +0800 Subject: [PATCH] run nodejs in non-root user --- AndroidManifest.xml | 7 - jni/Android.mk | 33 +- jni/node.c | 10 + res/values-zh/strings.xml | 452 +----------------- res/values/strings.xml | 2 +- res/xml/shadowsocks_preference.xml | 5 - src/com/github/shadowsocks/Node.java | 8 + src/com/github/shadowsocks/Shadowsocks.java | 4 - .../shadowsocks/ShadowsocksService.java | 14 +- 9 files changed, 52 insertions(+), 483 deletions(-) create mode 100644 jni/node.c create mode 100644 src/com/github/shadowsocks/Node.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 1f75f8a2..500574a9 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -7,7 +7,6 @@ - - - - - - - diff --git a/jni/Android.mk b/jni/Android.mk index 4ff57c15..9471b577 100755 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -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) -include $(subdirs) +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) diff --git a/jni/node.c b/jni/node.c new file mode 100644 index 00000000..b1a4dd95 --- /dev/null +++ b/jni/node.c @@ -0,0 +1,10 @@ +#include + +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); +} diff --git a/res/values-zh/strings.xml b/res/values-zh/strings.xml index 298afbad..06483ed3 100755 --- a/res/values-zh/strings.xml +++ b/res/values-zh/strings.xml @@ -52,7 +52,7 @@ 选择使用Shadowsocks的应用: 检测到一次非正常退出,状态已重置 Shadowsocks是一款开源软件,依照GPLv3协议发布。\n\n如果您有任何问题,请前往项目网站进行反馈。 - \n\n(gaeproxy.googlecode.com) + \n\n(github.com/clowwindy/shadowsocks) 关于 代理类型 正在连接... @@ -83,455 +83,5 @@ 系统代理 设置系统代理,无需ROOT权限,仅工作在Android 4.0及以上系统,并仅对当前Wifi连接生效 - - - Zirco Browser - Zirco Browser - %s - 使用Zirco Browser让你更好的使用互联网 - 关于 - 版权: - http://code.google.com/p/zirco-browser/ - GPL v3 - 添加书签 - 书签 - 历史 - 下载 - 配置 - 打开 - 在新页中打开 - 下载 - 下载开始 - 下载结束 - 下载错误: %s - 页 %s - 页 %1$s: %2$s - 不能打开网址 - 本程序不支持这个网址: %s. - 书签 - 排序方式 - 增加书签 - 没有书签 - 打开新页 - 编辑书签 - 删除书签 - 导入书签 - 导出书签 - 清空所有书签 - 正在导入书签中... - 重在导出书签中... - 正在清空书签中... - 顺序 - 倒序 - 选择导入源 - Android浏览器的书签 - 选择导出目标 - 编辑书签 - 增加书签 - 显示名称: - 地址Location: - 历史 - 打开新页 - 删除 - Zirco Browser-下载 - 没有下载 - %s (取消) - %s (完成) - Zirco Browser - Ad 白名单 - 白名单是空的. - 添加至白名单 - 清空白名单 - 通用设置 - 主页设定 - 定义你的默认主页 - 是否全屏幕 - 在全屏幕模式下显示 (需要重新启动程序). - 页切换时是否显示对话框 - 如果选中,也切换时会有提示 - 浏览器设定 - 历史记录大小 - 每天历史记录大小 - 是否支持JavaScript - 如果不支持JavaScript,很多网站效果不能打开,建议打开. - 是否加载图像 - 使用或者不使用图像 - 隐私设定 - 管理你的上网痕迹,确保隐私 - 保存表单数据 - 可保存数据,减少你下次输入时间 - 保存密码 - 可保存密码,让你下次访问更加方便 - 允许cookie - 是否允许Cookie - 清空历史 - 清空表单数据 - 清空缓存 - 清空cookies - 工具条显示时间 - 显示工具条多长时间自动隐藏 - 1 秒 - 2 秒 - 3 秒 - 4 秒 - 5 秒 - - - @string/PreferencesActivity.BarDuration1sec - @string/PreferencesActivity.BarDuration2sec - @string/PreferencesActivity.BarDuration3sec - @string/PreferencesActivity.BarDuration4sec - @string/PreferencesActivity.BarDuration5sec - - - 1000 - 2000 - 3000 - 4000 - 5000 - - - 工具条图标 - 工具条图标位置 - 右 - 左 - 两边都有 - - - @string/PreferencesActivity.BubbleRight - @string/PreferencesActivity.BubbleLeft - @string/PreferencesActivity.BubbleBoth - - - right - left - both - - - Ad广告设定 - 是否允许 Ad-blocker - Ad广告必须要求JavaScript能使用 - 白名单 - 管理 Ad广告白名单. - 确定 - 取消 - 请等待 - 是 - 否 - 操作没有完成,是否继续? - 今天 (%s) - 昨天 (%s) - %1$s 以前 (%2$s) - JavaScript对话框 - 清空历史记录 - 正在清空历史记录... - 清空表单数据 - 正在清空表单数据... - 清空缓存 - 正在清空缓存... - 清空Cookies - 正在清空缓存... - SD卡不能使用 - 找不到SD卡 - SD卡不能使用 - 关闭 - yyyy-MM-dd\'T\'HH:mm:ss.SSS - - - 关于 - 关于 - 本程序信息. - - - 更多.. - 默认缩放级别 - 设定默认缩放 - 关闭 - 大 - 非常大 - - - @string/PreferencesActivity.DefaultZoomClose - @string/PreferencesActivity.DefaultZoomMedium - @string/PreferencesActivity.DefaultZoomFar - - - CLOSE - MEDIUM - FAR - - - 欢迎! - 使用最多的书签 - 历史记录 - 更新历史 - 更新日志 - 本应用程序更新日志 - 主页 - 主页 - 开始页 - 空白页 - 自定义 - - - @string/PreferencesActivity.HomepageStart - @string/PreferencesActivity.HomepageBlank - @string/PreferencesActivity.HomepageCustom - - - - http://www.google.com/m?hl=en&gl=us&client=ms-null&source=android-browser-key&q=%s - http://www.baidu.com/s?wd=%s - 搜索 URL - 自定义搜索URL - 搜索 - 搜索 - 谷歌 - 百度 - 自定义 - - - @string/PreferencesActivity.SearchUrlGoogle - @string/PreferencesActivity.SearchUrlWikipedia - @string/PreferencesActivity.SearchUrlCustom - - - 搜索 - 搜 - 开始页设定 - 自定义开始页. - 是否显示搜索栏 - 如果选中,首页显示搜索栏 - 显示最常用书签 - 如果选中,首页显示最常用书签 - 是否显示历史 - 如果选中,显示浏览历史 - 书签个数 - 首页中最常用的书签显示 - 当前历史记录数 - 在首页中显示的历史记录个数 - User agent(UA) - 定义UA,网站根据UA显示给适合你浏览器的网页 - User Agent - User agent - Android默认 - 桌面级 - 自定义 - - - @string/PreferencesActivity.UserAgentDefault - @string/PreferencesActivity.UserAgentDesktop - @string/PreferencesActivity.UserAgentCustom - - - Android浏览器的书签 - SD卡 - 导出完成 - 你的所有书签已经保存在[%s]中 - 导出失败 - 错误信息: %s. - 复制链接地址 - 显示图片 - 复制图片地址 - 下载图片 - 发送邮件 - 复制邮件地址 - 地址已经复制到粘贴板 - 下载开始. - 正在下载中. - 下载完成. - 下载已经取消. - 复制URL - 清空缓存 - 如果选中,当程序退出的时候清空缓存. - 自定义首页 - 自定义首页界面 - 退出 - 需要重启 - 效果改变后需要重新启动程序,是否马上重启 - - - 可以使用插件 - 关闭 - 需要的时候提示 - 打开 - - - @string/PreferencesActivity.PluginsAlwaysOff - @string/PreferencesActivity.PluginsOnDemand - @string/PreferencesActivity.PluginsAlwaysOn - - - OFF - ON_DEMAND - ON - - - 继续 - 安全警告 - 网站的安全证书存在问题 - 网站证书没有可信任的发行者 - 站点名和证书不匹配 - 证书已经过期 - 证书没有验证 - Zirco Browser-通过网关访问的网站列表 - 列表为空 - 添加一个网站 - 清空所有站点 - 移动网站列表 - 管理网站 - 通过google移动平台访问网站,会减少流量和加快速度. - 增加 - 清空 - 删除 - - - 声音键 - 选择声音键的功能 - 默认不改变 - 放大 - 选择不同页 - 前进/后退 - - - @string/PreferencesActivity.VolumeKeysActionDefault - @string/PreferencesActivity.VolumeKeysActionZoom - @string/PreferencesActivity.VolumeKeysActionSwitchTabs - @string/PreferencesActivity.VolumeKeysActionHistory - - - DEFAULT - ZOOM - SWITCH_TABS - HISTORY - - - - Share page - Share via - Share link url - Share image url - Share email address - - - Hide title bars - If checked, windows title bars will not be - displayed (need application restart). - Use wide viewport - If checked, browser will use a viewport similar to - desktop browsers. - Load pages with overview - If checked, pages will load zoomed out to show an - overview of the page. - Switch tabs method - Define how you can switch between open tabs. - Buttons - Fling - Both - - - @string/PreferencesActivity.SwitchTabButtons - @string/PreferencesActivity.SwitchTabFling - @string/PreferencesActivity.SwitchTabBoth - - - buttons - fling - both - - - - Today - Yesterday - Last 7 days - Last month - Older - 主页 - 菜单 - 分享 - 选择文本 - 移动网关 - This application include code from the GreenDroid - project (https://github.com/cyrilmottier/GreenDroid/), licensed under - the Apache license, version 2. - - - Firefox bookmarks synchronization - Manage the settings of the bookmarks - synchronization with Firefox Sync. - Use Firefox Sync - If checked, you can retrieve your bookmarks from - Firefox Sync. - Server - Set the Firefox Sync server. - User name - Enter your Firefox Sync user name. - Password - Enter your Firefox Sync password. - Key - Enter your Firefox Sync key. - Firefox bookmarks - Synchronize - Clear - Places - Firefox bookmarks are not synchronized. Setup your - account informations and do a synchronization. - No bookmarks in this folder. - Setup - Synchronize - Synchronization - Connecting to server... - Getting data... - Reading data: %1$s / %2$s - Writting data... - Synchronization failed. - Synchronization failed: %s - Invalid authentication token. Check your settings. - Server - Server - Firefox Sync server - Custom server - - - @string/WeaveServerPreferenceActivity.DefaultServer - @string/WeaveServerPreferenceActivity.CustomServer - - - Choose file for upload - Export history and bookmarks - Export done - Your history and bookmarks have been saved to %s. - Export failed - Error message: %s. - Import failed - This operation can take some times. Do you wish to - proceed? - Tools - Manage bookmarks and history - Import, export, clear history and bookmarks. - Export bookmarks and history - Export bookmarks and history to the SD card. - Import bookmarks and history - Import bookmarks and history from the SD card. - Clear history and/or bookmarks - Use with caution, this operation cannot be undone. - Clearing history and/or bookmarks... - Clear history and/or bookmarks - Bookmarks - History - All - Exporting history and bookmarks... - Importing history and bookmarks... - Choose the import source - 正在清空书签中... - Remove completed downloads - Find on page - Find on page diff --git a/res/values/strings.xml b/res/values/strings.xml index 309d28e5..1051d9e0 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -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) About Proxy Type diff --git a/res/xml/shadowsocks_preference.xml b/res/xml/shadowsocks_preference.xml index d8bfb8df..9016fa4a 100755 --- a/res/xml/shadowsocks_preference.xml +++ b/res/xml/shadowsocks_preference.xml @@ -36,11 +36,6 @@ - -