Skip to content

Commit

Permalink
Merge pull request #2 from koush/master
Browse files Browse the repository at this point in the history
update base
  • Loading branch information
alvinhkh committed Mar 4, 2013
2 parents 0f86b40 + 1760433 commit 91b74d8
Show file tree
Hide file tree
Showing 29 changed files with 436 additions and 148 deletions.
3 changes: 3 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ LOCAL_STATIC_LIBRARIES := libc
LOCAL_C_INCLUDES := external/sqlite/dist
LOCAL_SRC_FILES := Superuser/jni/su/su.c Superuser/jni/su/activity.c Superuser/jni/su/db.c Superuser/jni/su/utils.c ../../sqlite/dist/sqlite3.c
LOCAL_CFLAGS := -DSQLITE_OMIT_LOAD_EXTENSION -DREQUESTOR=\"$(SUPERUSER_PACKAGE)\"
ifdef SUPERUSER_PACKAGE_PREFIX
LOCAL_CFLAGS += -DREQUESTOR_PREFIX=\"$(SUPERUSER_PACKAGE_PREFIX)\"
endif
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
include $(BUILD_EXECUTABLE)

4 changes: 2 additions & 2 deletions Superuser/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.koushikdutta.superuser"
android:versionCode="1006"
android:versionName="1.0.0.6" >
android:versionCode="1007"
android:versionName="1.0.0.7" >

<uses-sdk
android:minSdkVersion="8"
Expand Down
42 changes: 25 additions & 17 deletions Superuser/jni/su/su.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,36 +703,44 @@ int main(int argc, char *argv[]) {
read_options(&ctx);
user_init(&ctx);

if (ctx.user.multiuser_mode == MULTIUSER_MODE_OWNER_ONLY && ctx.user.android_user_id != 0) {
// verify superuser is installed
if (stat(ctx.user.base_path, &st) < 0) {
// send to market
if (0 == strcmp(JAVA_PACKAGE_NAME, REQUESTOR))
silent_run("am start -d market://details?id=" JAVA_PACKAGE_NAME);
PLOGE("stat %s", ctx.user.base_path);
deny(&ctx);
}

if (access_disabled(&ctx.from)) {
LOGD("access_disabled");
// odd perms on superuser data dir
if (st.st_gid != st.st_uid) {
LOGE("Bad uid/gid %d/%d for Superuser Requestor application",
(int)st.st_uid, (int)st.st_gid);
deny(&ctx);
}

ctx.umask = umask(027);

if (ctx.from.uid == AID_ROOT || ctx.from.uid == AID_SHELL) {
LOGD("Allowing root/shell.");

// always allow if this is the superuser uid
// superuser needs to be able to reenable itself when disabled...
if (ctx.from.uid == st.st_uid) {
allow(&ctx);
}

if (stat(ctx.user.base_path, &st) < 0) {
silent_run("am start -d market://details?id=" JAVA_PACKAGE_NAME);
PLOGE("stat %s", ctx.user.base_path);
// check if superuser is disabled completely
if (access_disabled(&ctx.from)) {
LOGD("access_disabled");
deny(&ctx);
}

if (st.st_gid != st.st_uid) {
LOGE("Bad uid/gid %d/%d for Superuser Requestor application",
(int)st.st_uid, (int)st.st_gid);
// deny if this is a non owner request and owner mode only
if (ctx.user.multiuser_mode == MULTIUSER_MODE_OWNER_ONLY && ctx.user.android_user_id != 0) {
deny(&ctx);
}

if (ctx.from.uid == st.st_uid) {
// automatically grant the superuser app itself

ctx.umask = umask(027);

// TODO: customizable behavior for shell? It can currently be toggled via settings.
if (ctx.from.uid == AID_ROOT || ctx.from.uid == AID_SHELL) {
LOGD("Allowing root/shell.");
allow(&ctx);
}

Expand Down
11 changes: 7 additions & 4 deletions Superuser/jni/su/su.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
#ifndef REQUESTOR
#define REQUESTOR JAVA_PACKAGE_NAME
#endif
#ifndef REQUESTOR_PREFIX
#define REQUESTOR_PREFIX JAVA_PACKAGE_NAME
#endif
#define REQUESTOR_DATA_PATH "/data/data/"
#define REQUESTOR_FILES_PATH REQUESTOR_DATA_PATH REQUESTOR "/files"
#define REQUESTOR_USER_PATH "/data/user/"
Expand All @@ -58,16 +61,16 @@
#define REQUESTOR_MULTIUSER_MODE REQUESTOR_FILES_PATH "/multiuser_mode"

/* intent actions */
#define ACTION_REQUEST "start -n " REQUESTOR "/" JAVA_PACKAGE_NAME ".RequestActivity"
#define ACTION_NOTIFY "start -n " REQUESTOR "/" JAVA_PACKAGE_NAME ".NotifyActivity"
#define ACTION_RESULT "broadcast -n " REQUESTOR "/" JAVA_PACKAGE_NAME ".SuReceiver"
#define ACTION_REQUEST "start -n " REQUESTOR "/" REQUESTOR_PREFIX ".RequestActivity"
#define ACTION_NOTIFY "start -n " REQUESTOR "/" REQUESTOR_PREFIX ".NotifyActivity"
#define ACTION_RESULT "broadcast -n " REQUESTOR "/" REQUESTOR_PREFIX ".SuReceiver"

#define DEFAULT_SHELL "/system/bin/sh"

#define xstr(a) str(a)
#define str(a) #a

#define VERSION_CODE 1
#define VERSION_CODE 2
#define VERSION xstr(VERSION_CODE) " " REQUESTOR

#define PROTO_VERSION 1
Expand Down
Binary file added Superuser/res/drawable-hdpi/ic_toggle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Superuser/res/drawable-hdpi/ic_toggle_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Superuser/res/drawable-mdpi/ic_toggle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Superuser/res/drawable-mdpi/ic_toggle_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Superuser/res/drawable-xhdpi/ic_toggle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Superuser/res/drawable-xhdpi/ic_toggle_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Superuser/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@
<string name="checking_superuser">Checker Superuser...</string>
<string name="install_error">Der skete en fejl i installationen af Superuser. Send venligst en log af fejlen til udvikleren.</string>
<string name="install_success">Installationen af Superuser var sucessfuld.</string>
<string name="su_binary_outdated">Superuser-binaryet er for gammelt.</string>
<string name="superuser_access">Superuser-adgang</string>
<string name="disabled">Slået fra</string>
<string name="apps_only">Kun apps</string>
<string name="adb_only">Kun ADB</string>
<string name="apps_and_adb">Apps og ADB</string>
</resources>
2 changes: 1 addition & 1 deletion Superuser/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<string name="installing">Installazione</string>
<string name="installing_superuser">Sto installando Superuser...</string>
<string name="install_superuser">Installa Superuser</string>
<string name="install_superuser_info">Il file binario di Superuser (su) deve essere aggiornato.\n\nPerfavore scegli un metodo per installarlo.\n\L\'installazione tramite Recovery è raccomandata per i dispositivi HTC.</string>
<string name="install_superuser_info">Il file binario di Superuser (su) deve essere aggiornato.\n\nPerfavore scegli un metodo per installarlo.\nL\'installazione tramite Recovery è raccomandata per i dispositivi HTC.</string>
<string name="recovery_install">Installa da Recovery</string>
<string name="install">Installa</string>
<string name="checking_superuser">Sto controllando Superuser...</string>
Expand Down
20 changes: 13 additions & 7 deletions Superuser/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string name="pin_protection">Использование PIN-кода</string>
<string name="pin_protection_summary">Запрашивать ввод PIN-кода для запросов прав Суперпользователя</string>
<string name="request_timeout">Таймаут доступа</string>
<string name="request_timeout_summary">Приложения, получившие права Суперпользователя, будут отклонены через %s секунд (ы)</string>
<string name="request_timeout_summary">Запросы прав Суперпользователя будут автоматически отклонены через %s секунд</string>
<string name="notifications">Уведомления</string>
<string name="none">Выключены</string>
<string name="notifications_summary">Будет показано %s когда приложение получает или нет права Суперпользователя</string>
Expand All @@ -37,11 +37,11 @@
<string name="confirm_pin">Подтвердите PIN-код</string>
<string name="pin_mismatch">PIN-коды не совпадают, попробуйте ещё раз</string>
<string name="pin_set">Включено использование PIN-кода</string>
<string name="number_seconds">%s секунд (ы)</string>
<string name="number_seconds">%s секунд</string>
<string name="superuser_granted">%s были предоставлены права Суперпользователя</string>
<string name="superuser_denied">%s не были предоставлены права Суперпользователя</string>
<string name="toast">Оповещение</string>
<string name="notification">Уведомление</string>
<string name="toast">оповещение</string>
<string name="notification">уведомление</string>
<string name="no_notification">Уведомления отключены</string>
<string name="developer_warning">Предупреждение:\nandroid.permission.ACCESS_SUPERUSER\nне были объявлены в манифесте приложения</string>
<string name="superuser_description">Полный доступ к функциям устройства и памяти</string>
Expand All @@ -50,16 +50,16 @@
<string name="declared_permission_summary">Разрешение будут получать только приложения с заявленным в манифесте android.permission.ACCESS_SUPERUSER</string>
<string name="automatic_response">Автоматический режим</string>
<string name="prompt">Спрашивать каждый раз</string>
<string name="automatic_response_allow_summary">Новые запросы будут подтверждены</string>
<string name="automatic_response_deny_summary">Новые запросы будут запрещены</string>
<string name="automatic_response_allow_summary">Новые запросы будут разрешены</string>
<string name="automatic_response_deny_summary">Новые запросы будут отклонены</string>
<string name="automatic_response_prompt_summary">Запрашивать разрешение каждый раз</string>
<string name="security">Безопасность</string>
<string name="multiuser_policy">Многопользовательские настройки</string>
<string name="multiuser_owner_only_summary">Только владелец может запрашивать права Суперпользователя</string>
<string name="multiuser_owner_managed_summary">Владелец будет оповещён если другой пользователь потребует прав Суперпользователя</string>
<string name="multiuser_user_summary">Все пользователи могут запрашивать права Суперпользователя</string>
<string name="multiuser_owner_only">Только владелец</string>
<string name="multiuser_owner_managed">Управляемые владельцем</string>
<string name="multiuser_owner_managed">Одобренные владельцем</string>
<string name="multiuser_user">Все пользователи</string>
<string name="multiuser_require_owner">Многопользовательские настройки управляются только владельцем</string>
<string name="owner_login_info">Пожалуйста, перейдите в аккаунт владельца для управления запросом</string>
Expand All @@ -75,4 +75,10 @@
<string name="checking_superuser">Проверка Суперпользователя...</string>
<string name="install_error">Произошла ошибка при установке Суперпользователя. Пожалуйста, отправте лог ошибки разработчику</string>
<string name="install_success">Установка Суперспользователя прошла успешно!</string>
<string name="su_binary_outdated">Файл su устарел</string>
<string name="superuser_access">Доступ Суперпользователя</string>
<string name="disabled">Выключен</string>
<string name="apps_only">Только приложения</string>
<string name="adb_only">Только ADB</string>
<string name="apps_and_adb">Приложения и ADB</string>
</resources>
6 changes: 6 additions & 0 deletions Superuser/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@
<string name="checking_superuser">Kontrollerar Superuser...</string>
<string name="install_error">Ett fel uppstod när Superuser installerades. Skicka en logg till utvecklaren för att möjliggöra felsökning.</string>
<string name="install_success">Superuser installerades korrekt.</string>
<string name="su_binary_outdated">Superuserbinären (su) är inaktuell.</string>
<string name="superuser_access">Superuseråtkomst</string>
<string name="disabled">Inaktiverad</string>
<string name="apps_only">Endast Appar</string>
<string name="adb_only">Endast ADB</string>
<string name="apps_and_adb">Appar och ADB</string>
</resources>
88 changes: 88 additions & 0 deletions Superuser/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="superuser">超级用户</string>
<string name="allow">允许</string>
<string name="deny">拒绝</string>
<string name="status_incoming">收到超级用户请求…</string>
<string name="unknown_uid">未知 UID:%s</string>
<string name="application_request">%s 正在请求超级用户访问权限。</string>
<string name="info">警告:如果你对此不了解,你应该选拒绝。</string>
<string name="request">超级用户请求</string>
<string name="package_header">软件包:</string>
<string name="app_header">应用程序:</string>
<string name="uid_header">请求的 UID:</string>
<string name="command_header">命令:</string>
<string name="this_time_only">仅此次</string>
<string name="remember_for">记住选择 %s 分钟</string>
<string name="remember_forever">永久记住选择</string>
<string name="interactive">交互式</string>
<string name="logs">日志</string>
<string name="settings">设置</string>
<string name="delete">删除</string>
<string name="no_logs">无日志</string>
<string name="no_apps">当前没有超级用户应用程序策略</string>
<string name="logging">日志</string>
<string name="logging_summary">启用/禁用超级用户请求日志</string>
<string name="pin_protection">密码保护</string>
<string name="pin_protection_summary">授权超级用户请求时要求输入密码</string>
<string name="request_timeout">请求超时</string>
<string name="request_timeout_summary">%s 秒后超级用户请求将超时并被拒绝</string>
<string name="notifications">通知</string>
<string name="none">无</string>
<string name="notifications_summary">当应用程序被允许或拒绝时将显示一个%s</string>
<string name="enter_pin">输入密码</string>
<string name="enter_new_pin">输入新密码</string>
<string name="incorrect_pin">密码不正确</string>
<string name="confirm_pin">确认密码</string>
<string name="pin_mismatch">密码不一致</string>
<string name="pin_set">超级用户密码保护已启用</string>
<string name="number_seconds">%s 秒</string>
<string name="superuser_granted">已授予 %s 超级用户权限</string>
<string name="superuser_denied">已拒绝 %s 获取超级用户权限</string>
<string name="toast">提示</string>
<string name="notification">通知</string>
<string name="no_notification">不显示通知</string>
<string name="developer_warning">"开发人员警告:
android.permission.ACCESS_SUPERUSER
在 manifest 中未定义。"</string>
<string name="superuser_description">对所有设备功能和存储的完整权限</string>
<string name="superuser_description_more">超级用户授予访问你的设备的所有功能和存储设备的完整权限,包括加密和敏感硬件设备。此许可有潜在的风险。</string>
<string name="declared_permission">权限申明</string>
<string name="declared_permission_summary">仅允许来自申明了 android.permission.ACCESS_SUPERUSER 权限的应用程序的请求</string>
<string name="automatic_response">自动响应</string>
<string name="prompt">提示</string>
<string name="automatic_response_allow_summary">自动允许新请求</string>
<string name="automatic_response_deny_summary">自动拒绝新请求</string>
<string name="automatic_response_prompt_summary">对新请求显示确认对话框</string>
<string name="security">安全</string>
<string name="multiuser_policy">多用户策略</string>
<string name="multiuser_owner_only_summary">仅机主可以请求超级用户权限</string>
<string name="multiuser_owner_managed_summary">其他用户请求超级用户权限时,机主将被提示</string>
<string name="multiuser_user_summary">所有用户都可以请求超级用户权限</string>
<string name="multiuser_owner_only">仅机主</string>
<string name="multiuser_owner_managed">机主控制</string>
<string name="multiuser_user">所有用户</string>
<string name="multiuser_require_owner">多用户策略仅可以由机主管理</string>
<string name="owner_login_info">请切换到机主帐户允许或拒绝此请求。</string>
<string name="all_commands">所有命令</string>
<string name="about">关于</string>
<string name="apps">应用程序</string>
<string name="installing">正在安装</string>
<string name="installing_superuser">正在安装超级用户…</string>
<string name="install_superuser">安装超级用户</string>
<string name="install_superuser_info">"超级用户二进制可执行文件 (su) 需要更新。

请选择安装方式。
对 HTC 设备建议选择 recovery 模式安装。"</string>
<string name="recovery_install">recovery 模式安装</string>
<string name="install">常规安装</string>
<string name="checking_superuser">正在检查超级用户…</string>
<string name="install_error">安装超级用户时出错。请将错误日志发送给开发人员。</string>
<string name="install_success">超级用户安装成功。</string>
<string name="su_binary_outdated">su 二进制可执行文件已过期。</string>
<string name="superuser_access">超级用户使用权</string>
<string name="disabled">禁用</string>
<string name="apps_only">仅应用</string>
<string name="adb_only">仅 ADB</string>
<string name="apps_and_adb">应用和 ADB</string>
</resources>
2 changes: 1 addition & 1 deletion Superuser/res/values-zh-rHK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<string name="installing">正在安裝</string>
<string name="installing_superuser">正在安裝超級使用者...</string>
<string name="install_superuser">安裝超級使用者</string>
<string name="install_superuser_info">超級使用者的二進制檔案(su)一定要更新\n\n請選擇安裝方法\n\HTC 設備建議選擇回復模式(Recovery)的安裝方法</string>
<string name="install_superuser_info">超級使用者的二進制檔案(su)一定要更新\n\n請選擇安裝方法\nHTC 設備建議選擇回復模式(Recovery)的安裝方法</string>
<string name="recovery_install">回復模式(Recovery)</string>
<string name="install">安裝</string>
<string name="checking_superuser">正在檢查超級使用者...</string>
Expand Down
Loading

0 comments on commit 91b74d8

Please sign in to comment.