mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-23 08:27:40 +00:00
003e44fb84
We used to construct /sbin tmpfs overlay in early-init stage after SELinux is properly initialized. However the way it is implemented (forking daemon from magiskinit with complicated file waiting triggers) is extremely complicated and error prone. This commit moves the construction of the sbin overlay to pre-init stage. The catch is that since SELinux is not present at that point, proper selabel has to be reconstructed afterwards. Some additional SEPolicy rules are added to make sure init can access magisk binaries, and the secontext relabeling task is assigned to the main Magisk daemon.
44 lines
1.4 KiB
C
44 lines
1.4 KiB
C
#pragma once
|
|
|
|
// selinuxfs paths
|
|
#define SELINUX_MNT "/sys/fs/selinux"
|
|
#define SELINUX_ENFORCE SELINUX_MNT "/enforce"
|
|
#define SELINUX_POLICY SELINUX_MNT "/policy"
|
|
#define SELINUX_LOAD SELINUX_MNT "/load"
|
|
#define SELINUX_CONTEXT SELINUX_MNT "/context"
|
|
#define SELINUX_VERSION SELINUX_MNT "/policyvers"
|
|
|
|
// sepolicy paths
|
|
#define PLAT_POLICY_DIR "/system/etc/selinux/"
|
|
#define VEND_POLICY_DIR "/vendor/etc/selinux/"
|
|
#define PROD_POLICY_DIR "/product/etc/selinux/"
|
|
#define ODM_POLICY_DIR "/odm/etc/selinux/"
|
|
#define SPLIT_PLAT_CIL PLAT_POLICY_DIR "plat_sepolicy.cil"
|
|
|
|
#define SEPOL_PROC_DOMAIN "magisk"
|
|
#define SEPOL_FILE_DOMAIN "magisk_file"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
extern void (*freecon)(char *con);
|
|
extern int (*setcon)(const char *con);
|
|
extern int (*getfilecon)(const char *path, char **con);
|
|
extern int (*lgetfilecon)(const char *path, char **con);
|
|
extern int (*fgetfilecon)(int fd, char **con);
|
|
extern int (*setfilecon)(const char *path, const char *con);
|
|
extern int (*lsetfilecon)(const char *path, const char *con);
|
|
extern int (*fsetfilecon)(int fd, const char *con);
|
|
void getfilecon_at(int dirfd, const char *name, char **con);
|
|
void setfilecon_at(int dirfd, const char *name, const char *con);
|
|
|
|
void selinux_builtin_impl();
|
|
void dload_selinux();
|
|
void restorecon();
|
|
void restore_rootcon();
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|