Skip to content

ksud: fix some module scripts won't add KSU_MODULE environment var#3445

Open
AlexLiuDev233 wants to merge 1 commit intotiann:mainfrom
AlexLiuDev233:ksud-module-env-flags
Open

ksud: fix some module scripts won't add KSU_MODULE environment var#3445
AlexLiuDev233 wants to merge 1 commit intotiann:mainfrom
AlexLiuDev233:ksud-module-env-flags

Conversation

@AlexLiuDev233
Copy link
Copy Markdown
Contributor

@AlexLiuDev233 AlexLiuDev233 commented May 5, 2026

KSU_MODULE environment var will only pass in exec_script, that's cause only stage-scripts, action.sh and uninstall scripts have this environment var

So, it cause customize.sh, and meta*.sh won't have this envionment var
And module developers will see them can't use ksud module config set command,
because ksud throw
This command must be run in the context of a module or passed --internal <name>

Taking the magic_mount_rs module as an example:
before:

KSU='true'
KSU_KERNEL_VER_CODE='32481'
KSU_VER='3.2.4-24-gcc83433b'
KSU_VER_CODE='32481'

after:

KSU='true'
KSU_KERNEL_VER_CODE='32481'
KSU_MODULE='magic_mount_rs'
KSU_VER='3.2.4-24-gcc83433b'
KSU_VER_CODE='32481'

KSU_MODULE environment var will only pass in exec_script,
that's cause only stage-scripts, action.sh and uninstall scripts have this environment var

So, it cause customize.sh, and meta*.sh won't have this envionment var
And module developers will see them can't use ksud module config set command,
because ksud throw This command must be run in the context of a module or passed --internal <name>

Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates ksud’s script execution environment handling so module-related scripts consistently receive the KSU_MODULE environment variable (not just scripts launched through exec_script), enabling module scripts like customize.sh / meta*.sh to use module-scoped commands (e.g., module config operations) without requiring --internal.

Changes:

  • Refactors get_common_script_envs() to accept an optional module_id and inject KSU_MODULE when available/valid.
  • Ensures installer execution (exec_install_script) propagates KSU_MODULE by passing the installing module’s id into the common env set.
  • Updates metamodule script execution to pass a metamodule id into the common env set.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
userspace/ksud/src/module.rs Refactors common script env generation to optionally include KSU_MODULE, and wires it into install script execution and exec_script().
userspace/ksud/src/metamodule.rs Adds metamodule id helper and passes an id into common envs for metamodule-run scripts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread userspace/ksud/src/module.rs
Comment thread userspace/ksud/src/metamodule.rs
Comment thread userspace/ksud/src/metamodule.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants