include $(CLEAR_VARS)
+
+ifeq ($(SUPERUSER_PACKAGE),)
+SUPERUSER_PACKAGE := com.thirdparty.superuser
+endif
+
LOCAL_MODULE := su
LOCAL_FORCE_STATIC_EXECUTABLE := true
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
+LOCAL_CFLAGS := -DSQLITE_OMIT_LOAD_EXTENSION -DREQUESTOR=\"$(SUPERUSER_PACKAGE)\"
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
include $(BUILD_EXECUTABLE)
-
include $(LOCAL_PATH)/Superuser/Android.mk
\ No newline at end of file
-ifeq ($(SUPERUSER_PACKAGE),)
-SUPERUSER_PACKAGE := com.thirdparty.superuser
-endif
+ifndef SUPERUSER_EMBEDDED
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_AAPT_FLAGS := --extra-packages com.koushikdutta.widgets -S $(LOCAL_PATH)/../../Widgets/Widgets/res --auto-add-overlay --rename-manifest-package $(SUPERUSER_PACKAGE)
include $(BUILD_PACKAGE)
+
+endif
snprintf(user, user_len, "--user %d", ctx->user.android_user_id);
}
else if (ctx->user.multiuser_mode == MULTIUSER_MODE_NONE) {
- snprintf(user, user_len, "");
+ user[0] = '\0';
}
else {
snprintf(user, user_len, "--user 0");
#include "su.h"
#include "utils.h"
-int get_shell_uid() {
+unsigned get_shell_uid() {
struct passwd* ppwd = getpwnam("shell");
if (NULL == ppwd) {
- return -1;
+ return 2000;
}
return ppwd->pw_uid;
exit(128 + sig);
}
-void sigchld_handler(int sig) {
- child_cleanup(su_ctx);
- (void)sig;
-}
-
static int socket_create_temp(char *path, size_t len) {
int fd;
struct sockaddr_un sun;
write_token(fd, "version", PROTO_VERSION);
write_token(fd, "pid", ctx->from.pid);
- write_token(fd, "from.name", ctx->from.name);
- write_token(fd, "to.name", ctx->to.name);
+ write_string(fd, "from.name", ctx->from.name);
+ write_string(fd, "to.name", ctx->to.name);
write_token(fd, "from.uid", ctx->from.uid);
write_token(fd, "to.uid", ctx->to.uid);
write_string(fd, "from.bin", ctx->from.bin);
#define CM_ROOT_ACCESS_ADB_ONLY 2
#define CM_ROOT_ACCESS_APPS_AND_ADB 3
+#ifndef REQUESTOR
#define REQUESTOR "com.koushikdutta.superuser"
+#endif
#define REQUESTOR_DATA_PATH "/data/data/"
#define REQUESTOR_FILES_PATH REQUESTOR_DATA_PATH REQUESTOR "/files"
#define REQUESTOR_USER_PATH "/data/user/"
extern void set_identity(unsigned int uid);
extern int send_request(struct su_context *ctx);
extern int send_result(struct su_context *ctx, policy_t policy);
-extern void sigchld_handler(int sig);
static inline char *get_command(const struct su_request *to)
{