Compile with unified binary only
The su binary itself cannot do much, since it still requires a daemon to work The daemon code will soon be moved to a higher level (out of MagiskSU), so there is no point in creating a separate binary
This commit is contained in:
parent
3800b4b45c
commit
ed052e0b0b
12
Android.mk
12
Android.mk
@ -1,12 +0,0 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := su
|
||||
LOCAL_STATIC_LIBRARIES := libselinux libsqlite3
|
||||
LOCAL_C_INCLUDES := jni/selinux/libselinux/include/ jni/selinux/libsepol/include/ jni/sqlite3/
|
||||
LOCAL_SRC_FILES := su.c daemon.c activity.c db.c utils.c pts.c
|
||||
LOCAL_CFLAGS := -DSQLITE_OMIT_LOAD_EXTENSION -DINDEP_BINARY
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
include jni/selinux/libselinux/Android.mk
|
||||
include jni/sqlite3/Android.mk
|
34
indep_bin.h
34
indep_bin.h
@ -1,34 +0,0 @@
|
||||
/* This file is here because is uses some same macros in magisk.h
|
||||
* So we have to remove them from su.h.
|
||||
* However, if we want to build our own binary, we still have to define them
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _INDEP_BIN_H_
|
||||
#define _INDEP_BIN_H_
|
||||
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "su"
|
||||
|
||||
// fallback to using /system/bin/log.
|
||||
// can't use liblog.so because this is a static binary.
|
||||
#ifndef LOGE
|
||||
#define LOGE exec_loge
|
||||
#endif
|
||||
#ifndef LOGD
|
||||
#define LOGD exec_logd
|
||||
#endif
|
||||
#ifndef LOGW
|
||||
#define LOGW exec_logw
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#define PLOGE(fmt,args...) LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno))
|
||||
#define PLOGEV(fmt,err,args...) LOGE(fmt " failed with %d: %s", ##args, err, strerror(err))
|
||||
|
||||
int su_main(int argc, char *argv[]);
|
||||
|
||||
#endif
|
52
su.c
52
su.c
@ -45,12 +45,6 @@
|
||||
#include "su.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef INDEP_BINARY
|
||||
int main(int argc, char *argv[]) {
|
||||
return su_main(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int is_daemon;
|
||||
extern int daemon_from_uid;
|
||||
extern int daemon_from_pid;
|
||||
@ -96,52 +90,6 @@ int fork_zero_fucks() {
|
||||
}
|
||||
}
|
||||
|
||||
void exec_log(char *priority, char* logline) {
|
||||
int pid;
|
||||
if ((pid = fork()) == 0) {
|
||||
int null = open("/dev/null", O_WRONLY | O_CLOEXEC);
|
||||
dup2(null, STDIN_FILENO);
|
||||
dup2(null, STDOUT_FILENO);
|
||||
dup2(null, STDERR_FILENO);
|
||||
execl("/system/bin/log", "/system/bin/log", "-p", priority, "-t", LOG_TAG, logline, NULL);
|
||||
_exit(0);
|
||||
}
|
||||
int status;
|
||||
waitpid(pid, &status, 0);
|
||||
}
|
||||
|
||||
void exec_loge(const char* fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
char logline[PATH_MAX];
|
||||
va_start(args, fmt);
|
||||
vsnprintf(logline, PATH_MAX, fmt, args);
|
||||
va_end(args);
|
||||
exec_log("e", logline);
|
||||
}
|
||||
|
||||
void exec_logw(const char* fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
char logline[PATH_MAX];
|
||||
va_start(args, fmt);
|
||||
vsnprintf(logline, PATH_MAX, fmt, args);
|
||||
va_end(args);
|
||||
exec_log("w", logline);
|
||||
}
|
||||
|
||||
void exec_logd(const char* fmt, ...) {
|
||||
#ifdef DEBUG
|
||||
va_list args;
|
||||
|
||||
char logline[PATH_MAX];
|
||||
va_start(args, fmt);
|
||||
vsnprintf(logline, PATH_MAX, fmt, args);
|
||||
va_end(args);
|
||||
exec_log("d", logline);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int from_init(struct su_initiator *from) {
|
||||
char path[PATH_MAX], exe[PATH_MAX];
|
||||
char args[4096], *argv0, *argv_rest;
|
||||
|
9
su.h
9
su.h
@ -18,12 +18,7 @@
|
||||
#ifndef SU_h
|
||||
#define SU_h 1
|
||||
|
||||
#ifdef INDEP_BINARY
|
||||
#include "indep_bin.h"
|
||||
#else
|
||||
#include "magisk.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef AID_SHELL
|
||||
#define AID_SHELL (get_shell_uid())
|
||||
@ -167,10 +162,6 @@ static inline char *get_command(const struct su_request *to)
|
||||
return DEFAULT_SHELL;
|
||||
}
|
||||
|
||||
void exec_loge(const char* fmt, ...);
|
||||
void exec_logw(const char* fmt, ...);
|
||||
void exec_logd(const char* fmt, ...);
|
||||
|
||||
int run_daemon();
|
||||
int connect_daemon(int argc, char *argv[], int ppid);
|
||||
int su_main(int argc, char *argv[]);
|
||||
|
Loading…
Reference in New Issue
Block a user