Module Development Guide
更新: 8/20/2025字数: 0 字时长: 0 分钟
For most aspects, ShiroSU is largely consistent withMagisk
andKernelSU
. This document only describes the differences.
TIP
If ShiroSU is only used as a module manager for other root implementations, the module standard should follow the current root implementation. ShiroSUwill not interferewith any behavior of other root implementations.
However, modules'WebUI needs to considerShiroSU'smodule WebUI.
IMPORTANT
Ensure all text files within the module useUNIX (LF)
line endings, notWindows (CR + LF)
orMacintosh (CR)
!
Systemless[1]
ShiroSU's Systemless is a mount mechanism similar to Magisk, with fully compatible interfaces, such as the.replace
usage. However, ShiroSU's mount mechanism has stronger compatibility. It is based on dynamic partition identification. This means modules can directly mount partitions likeodm
, and other root implementations cannot mount, without extra effort.
Furthermore, to ensure stronger security, ShiroSU's Systemless ignores theSELinux contextof mountedfiles/directories,directory permissions, andfile/directory user/group ownership. If a file is mounted to a non-existent directory, itsSELinux context,permissions, anduser/groupwill inherit from the parent directory. Generally, these actions do not affect module operation and instead help improve stability.
TIP
ShiroSU's Systemless uses thesystemless
folder within the module directory for mounting. If a module uses thesystem
folder for Systemless, thesystemless
folder will beautomatically created.
If a module is only compatible with ShiroSU, it can directly use thesystemless
folder for Systemless.
Shell
ShiroSU differs significantly from other root implementations here. ShiroSU's running shell scripts arenotrun in "standalone mode" withinBusyBox
.
To improve the convenience of shell script development, ShiroSU usessush(Bash written in Rust) to run shell scripts and prioritizes the command set ofuutils(coreutils written in Rust) over Magisk's BusyBox. Commands arefirst retrieved from uutils, and only if not found are they retrieved from BusyBox.
Since it's not run in "standalone mode" within BusyBox, commands are injected through thePATH
environment variable. Do not hardcode modifications toPATH
within module shell scripts!
Environment Variables
To aid in differentiation, ShiroSU injects the following variables during module execution:
SSU
(boolean): When running in the ShiroSU environment, this value will betrue
. However, this does not mean you can execute code with$SSU && # code ...
. Always use[ "$SSU" = true ]
or a similar method to detect ShiroSU.SSU_VER
(string): ShiroSU's version number (excluding patch number).SSU_VER_CODE
(integer): ShiroSU's pure numerical version number (including patch number).
Recovery
ShiroSU does not support installing modules via Recovery, and code withinMETA-INF/com/google/android/update-binary
will not be executed during module installation.
SU Calls
ShiroSU's SU implementation defaults to asudo
that can only be used to directly execute shell commands, allowing direct execution of commands likesudo ls /
.
sudo
exists only as a simplesu -c
alternative, butnomodule should usesudo
orsu -c
to execute shell commands!
Similarly, modules shouldnothardcode commands, such as/data/adb/ssu/bin/busybox crond
, because regardless of BusyBox "standalone mode" or directPATH
injection, commands can be called directly without any hardcoded manual retrieval.
ANSI Escape Codes[2]
ShiroSU allows the use ofANSI escape codes
inmodule.prop
or shell scripts to enhance text display. For example, inmodule.prop
:
id=ssu_cmd_ext
name=Command Set Extension
version=Auto-generated by SSU
versionAnsi=\e[1mAuto-generated\e[0m by SSU
versionCode=1
author=SSU Developers (OOM. WG.)
description=Add coreutils, busybox, and bash to /system/bin.
descriptionAnsi=Add \e[1mcoreutils, busybox, and bash\e[0m to \e[1m/system/bin\e[0m.
Using the abovemodule.prop
, the module will displayAuto-generated
,coreutils, busybox, and bash
, and/system/bin
in bold within the ShiroSU manager.
Inmodule.prop
, you can usenameAnsi
,versionAnsi
,authorAnsi
, anddescriptionAnsi
to display text containing ANSI escape codes.
While omitting theAnsi
suffix is possible, for compatibility, use theAnsi
suffix.
ShiroSU parsesmodule.prop
sequentially, so ensure values with theAnsi
suffix are placed later in the file.Expand to view rendering effect
Module WebUI
ShiroSU, likeKernelSU
, allows modules to use WebUI for functionality, seeModule WebUI.
module.prop
The ShiroSU manager has a mechanism to detect ifmodule.prop
is corrupted or conforms to the standard. If corrupted or non-compliant, the manager will display a tag above the module.
WARNING
Some modules usesed
commands to modifymodule.prop
for real-time content updates. However, this method has a high probability of corrupting themodule.prop
file. Avoid modifyingmodule.prop
withsed
or other methods for real-time display. Implement amodule.prop
corruption detection mechanism to restore default content upon corruption.
The ShiroSU manager checks the following:
- Whether
module.prop
contains non-compliant syntax. - Whether
id
,name
,version
,author
,description
(and theirAnsi
counterparts) are empty. - Whether
id
matches the regular expression:^[a-zA-Z][a-zA-Z0-9._-]+$
. - Whether
versionCode
is greater than0. - Whether
module.prop
contains case inconsistencies (the manager will parse correctly but still display a tag).
If onlymodule.prop
is corrupted, reinstalling the module usually resolves the issue. If it's non-compliant, developers must fix it.
Kernel Interface
ShiroSU uses/data/adb/ssu/._settings
as the kernel settings directory, typically containing the following files:
._su_list
: List of packages authorized to use superuser privileges.._bypass_list
: List of entries bypassing SELinux restrictions.._hide_list
: List of entries needing hidden root usage traces.
These files storebinary UID
(32-bit integer) +\0
+package name
format, with multiple values separated by\n
.
IMPORTANT
These files are read-only. No modules/applications should modify ShiroSU's kernel configuration files.Only the ShiroSU managerhas modification rights!
Modifications by other modules/applications are expected to be ineffective. ShiroSU will progressively add restrictions on kernel configuration file writing in future updates.
Other Differences
ShiroSU will providemodule backup interface,module update interface (executing original module code during updates), andmodule storage interfacein future updates. These features are still under development and will be released in future updates.