Compare commits

...

9 Commits

Author SHA1 Message Date
tiann
f9df8d3351 Revert "ci: Remove tags with same KMI"
This reverts commit ddbc71b273.
2023-04-06 13:35:43 +08:00
tiann
8f4299ef62 ksud: keep pwd after switch mnt ns 2023-04-06 13:20:23 +08:00
zhcnUTF8
fabaa61279 kernel: check CONFIG_SECCOMP status (#351) 2023-04-05 19:09:47 +08:00
Howard Wu
f17de87952 Save install logs to public download folder (#350) 2023-04-05 15:54:55 +08:00
Ylarod
93a607083a ksud: exec uninstall.sh while uninstalling (#347) 2023-04-05 14:36:35 +08:00
Ylarod
7544558173 website: fix typo, add hidden-features (#349) 2023-04-05 14:36:22 +08:00
Ylarod
c96b0e8f8b ksud: support .ksurc (#345) 2023-04-05 13:30:21 +08:00
Igor Sorocean
b181147922 Fix ro translation (#344) 2023-04-05 12:16:02 +08:00
Ylarod
862d12a904 ksud: add /data/adb/ksu/bin to PATH (#343) 2023-04-05 11:47:35 +08:00
17 changed files with 103 additions and 11 deletions

View File

@@ -23,6 +23,16 @@ jobs:
include:
- sub_level: 66
os_patch_level: 2021-11
- sub_level: 81
os_patch_level: 2022-03
- sub_level: 101
os_patch_level: 2022-05
- sub_level: 110
os_patch_level: 2022-07
- sub_level: 136
os_patch_level: 2022-11
- sub_level: 149
os_patch_level: 2023-01
- sub_level: 160
os_patch_level: 2023-02
uses: ./.github/workflows/gki-kernel.yml

View File

@@ -21,9 +21,21 @@ jobs:
strategy:
matrix:
include:
- version: "5.10"
sub_level: 107
os_patch_level: 2022-11
- version: "5.10"
sub_level: 149
os_patch_level: 2023-01
- version: "5.10"
sub_level: 157
os_patch_level: 2023-02
- version: "5.15"
sub_level: 41
os_patch_level: 2022-11
- version: "5.15"
sub_level: 74
os_patch_level: 2023-01
- version: "5.15"
sub_level: 78
os_patch_level: 2023-02

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.vscode/

View File

@@ -76,8 +76,12 @@ void escape_to_root(void)
#else
current_thread_info()->flags &= ~(TIF_SECCOMP | _TIF_SECCOMP);
#endif
#ifdef CONFIG_SECCOMP
current->seccomp.mode = 0;
current->seccomp.filter = NULL;
#else
#endif
// setgroup to root
if (cred->group_info)
@@ -545,4 +549,4 @@ void ksu_core_exit(void)
pr_info("ksu_kprobe_exit\n");
ksu_kprobe_exit();
#endif
}
}

View File

@@ -24,7 +24,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import me.weishu.kernelsu.R
import me.weishu.kernelsu.ksuApp
import me.weishu.kernelsu.ui.util.LocalSnackbarHost
import me.weishu.kernelsu.ui.util.installModule
import me.weishu.kernelsu.ui.util.reboot
@@ -73,7 +72,7 @@ fun InstallScreen(navigator: DestinationsNavigator, uri: Uri) {
val format = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault())
val date = format.format(Date())
val file = File(
ksuApp.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
"KernelSU_install_log_${date}.log"
)
file.writeText(text)

View File

@@ -3,7 +3,7 @@
<string name="home">Acasă</string>
<string name="home_not_installed">Nu este instalat</string>
<string name="home_click_to_install">Click pentru a instala</string>
<string name="home_working">Se procesează</string>
<string name="home_working">Funcționează</string>
<string name="home_working_version">Versiune: %d</string>
<string name="home_unsupported">Necompatibil</string>
<string name="home_unsupported_reason">KernelSU suportă doar nuclee GKI acum</string>
@@ -29,7 +29,7 @@
<string name="module_failed_to_disable">Dezactivarea modulului %s a eșuat</string>
<string name="module_empty">Niciun modul instalat</string>
<string name="module">Modul</string>
<string name="module">Module</string>
<string name="uninstall">Dezinstalează</string>
<string name="module_install">Instalează</string>
<string name="install">Instalează</string>

View File

@@ -1 +1,2 @@
/target
.cargo/

View File

@@ -1,12 +1,15 @@
use const_format::concatcp;
pub const ADB_DIR: &str = "/data/adb/";
pub const DAEMON_PATH: &str = concatcp!(ADB_DIR, "ksud");
pub const WORKING_DIR: &str = concatcp!(ADB_DIR, "ksu/");
pub const BINARY_DIR: &str = concatcp!(WORKING_DIR, "bin/");
pub const KSURC_PATH: &str = concatcp!(WORKING_DIR, ".ksurc");
pub const DAEMON_PATH: &str = concatcp!(ADB_DIR, "ksud");
#[cfg(target_os = "android")]
pub const DAEMON_LINK_PATH: &str = concatcp!(BINARY_DIR, "ksud");
pub const MODULE_DIR: &str = concatcp!(ADB_DIR, "modules/");
pub const MODULE_IMG: &str = concatcp!(WORKING_DIR, "modules.img");
pub const MODULE_UPDATE_IMG: &str = concatcp!(WORKING_DIR, "modules_update.img");

View File

@@ -248,5 +248,21 @@ pub fn install() -> Result<()> {
std::fs::copy("/proc/self/exe", defs::DAEMON_PATH)?;
// install binary assets
assets::ensure_binaries().with_context(|| "Failed to extract assets")
assets::ensure_binaries().with_context(|| "Failed to extract assets")?;
#[cfg(target_os = "android")]
link_ksud_to_bin()?;
Ok(())
}
#[cfg(target_os = "android")]
fn link_ksud_to_bin() -> Result<()> {
use std::path::PathBuf;
let ksu_bin = PathBuf::from(defs::DAEMON_PATH);
let ksu_bin_link = PathBuf::from(defs::DAEMON_LINK_PATH);
if ksu_bin.exists() && !ksu_bin_link.exists() {
std::os::unix::fs::symlink(&ksu_bin, &ksu_bin_link)?;
}
Ok(())
}

View File

@@ -3,8 +3,10 @@ use anyhow::{Ok, Result};
#[cfg(unix)]
use anyhow::ensure;
use getopts::Options;
use std::env;
#[cfg(unix)]
use std::os::unix::process::CommandExt;
use std::path::PathBuf;
use std::{ffi::CStr, process::Command};
use crate::{
@@ -84,7 +86,7 @@ pub fn root_shell() -> Result<()> {
"COMMAND",
);
opts.optflag("h", "help", "display this help message and exit");
opts.optflag("l", "login", "force run in the global mount namespace");
opts.optflag("l", "login", "pretend the shell to be a login shell");
opts.optflag(
"p",
"preserve-environment",
@@ -208,6 +210,15 @@ pub fn root_shell() -> Result<()> {
}
}
// add /data/adb/ksu/bin to PATH
#[cfg(any(target_os = "linux", target_os = "android"))]
add_path_to_env(defs::BINARY_DIR)?;
// when KSURC_PATH exists and ENV is not set, set ENV to KSURC_PATH
if PathBuf::from(defs::KSURC_PATH).exists() && env::var("ENV").is_err() {
command = command.env("ENV", defs::KSURC_PATH);
}
// escape from the current cgroup and become session leader
// WARNING!!! This cause some root shell hang forever!
// command = command.process_group(0);
@@ -233,6 +244,16 @@ pub fn root_shell() -> Result<()> {
Err(command.exec().into())
}
fn add_path_to_env(path: &str) -> Result<()> {
let mut paths =
env::var_os("PATH").map_or(Vec::new(), |val| env::split_paths(&val).collect::<Vec<_>>());
let new_path = PathBuf::from(path);
paths.push(new_path);
let new_path_env = env::join_paths(paths)?;
env::set_var("PATH", new_path_env);
Ok(())
}
pub fn get_version() -> i32 {
let mut result: i32 = 0;
#[cfg(any(target_os = "linux", target_os = "android"))]

View File

@@ -333,6 +333,7 @@ fn _install_module(zip: &str) -> Result<()> {
let mut buffer: Vec<u8> = Vec::new();
let entry_path = PathBuf::from_str("module.prop")?;
let zip_path = PathBuf::from_str(zip)?;
let zip_path = zip_path.canonicalize()?;
zip_extract_file_to_memory(&zip_path, &entry_path, &mut buffer)?;
let mut module_prop = HashMap::new();
@@ -555,6 +556,10 @@ pub fn uninstall_module(id: &str) -> Result<()> {
}
})?;
if module_id.eq(mid) {
let uninstall_script = path.join("uninstall.sh");
if uninstall_script.exists() {
exec_script(uninstall_script, true)?;
}
remove_dir_all(path)?;
break;
}

View File

@@ -103,7 +103,11 @@ pub fn switch_mnt_ns(pid: i32) -> Result<()> {
use std::os::fd::AsRawFd;
let path = format!("/proc/{pid}/ns/mnt");
let fd = std::fs::File::open(path)?;
let current_dir = std::env::current_dir();
let ret = unsafe { libc::setns(fd.as_raw_fd(), libc::CLONE_NEWNS) };
if let std::result::Result::Ok(current_dir) = current_dir {
let _ = std::env::set_current_dir(current_dir);
}
ensure!(ret == 0, "switch mnt ns failed");
Ok(())
}

View File

@@ -53,6 +53,7 @@ function sidebarGuide() {
{ text: 'Module Guide', link: '/guide/module.md' },
{ text: 'Rescue from bootloop', link: '/guide/rescue-from-bootloop.md' },
{ text: 'FAQ', link: '/guide/faq' },
{ text: 'Hidden features', link: '/guide/hidden-features' },
]
}
]

View File

@@ -53,6 +53,7 @@ function sidebarGuide() {
{ text: '模块开发指南', link: '/zh_CN/guide/module.md' },
{ text: '救砖', link: '/zh_CN/guide/rescue-from-bootloop.md' },
{ text: '常见问题', link: '/zh_CN/guide/faq' },
{ text: '隐藏功能', link: '/zh_CN/guide/hidden-features' },
]
}
]

View File

@@ -0,0 +1,7 @@
# Hidden Features
## .ksurc
By default, `/system/bin/sh` loads `/system/etc/mkshrc`.
You can make su load customized rc file by creating a `/data/adb/ksu/.ksurc` file.

View File

@@ -0,0 +1,7 @@
# 隐藏功能
## ksurc
默认情况下,`/system/bin/sh` 会加载 `/system/etc/mkshrc`
可以通过创建 `/data/adb/ksu/.ksurc` 文件来让 su 加载该文件而不是 `/system/etc/mkshrc`

View File

@@ -60,7 +60,7 @@ KernelSU 模块就是一个放置在 `/data/adb/modules` 内且满足如下结
│ │
│ ├── post-fs-data.sh <--- 这个脚本将会在 post-fs-data 模式下运行
│ ├── service.sh <--- 这个脚本将会在 late_start 服务模式下运行
| ├── uninstall.sh <--- 这个脚本将会在模块被卸载运行
| ├── uninstall.sh <--- 这个脚本将会在模块被卸载运行
│ ├── system.prop <--- 这个文件中指定的属性将会在系统启动时通过 resetprop 更改
│ ├── sepolicy.rule <--- 这个文件中的 SELinux 策略将会在系统启动时加载
│ │