Compare commits

..

9 Commits

24 changed files with 124 additions and 1043 deletions

View File

@@ -8,16 +8,6 @@ updates:
actions:
patterns:
- "*"
- package-ecosystem: cargo
directory: userspace/ksuinit
schedule:
interval: daily
allow:
- dependency-type: "all"
groups:
crates:
patterns:
- "*"
- package-ecosystem: cargo
directory: userspace/ksud_magic
schedule:

View File

@@ -19,48 +19,12 @@ on:
workflow_dispatch:
jobs:
check-cache:
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache-artifacts.outputs.cache-hit }}
cache-key: ${{ steps.generate-cache-key.outputs.cache-key }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate cache key from source files
id: generate-cache-key
run: |
# Calculate hash of all files except manager directory
HASH=$(find . -type f \
-not -path "./manager/*" \
-not -path "./.git/*" \
-not -path "./.github/workflows/build-manager-ci.yml" \
-exec sha256sum {} \; | sort | sha256sum | cut -d' ' -f1)
echo "cache-key=artifacts-$HASH" >> $GITHUB_OUTPUT
echo "Generated cache key: artifacts-$HASH"
- name: Check for cached artifacts
id: cache-artifacts
uses: actions/cache@v4
with:
path: |
cached-artifacts/susfsd
cached-artifacts/ksud_overlayfs
cached-artifacts/ksud_magic
key: ${{ steps.generate-cache-key.outputs.cache-key }}
build-lkm:
needs: check-cache
if: needs.check-cache.outputs.cache-hit != 'true'
uses: ./.github/workflows/build-lkm.yml
secrets: inherit
build-susfsd:
needs: [check-cache, build-lkm]
if: needs.check-cache.outputs.cache-hit != 'true'
needs: build-lkm
strategy:
matrix:
include:
@@ -69,22 +33,8 @@ jobs:
with:
os: ${{ matrix.os }}
build-ksuinit:
needs: [check-cache, build-susfsd]
if: needs.check-cache.outputs.cache-hit != 'true'
strategy:
matrix:
include:
- target: aarch64-linux-android
os: ubuntu-latest
uses: ./.github/workflows/ksuinit.yml
with:
target: ${{ matrix.target }}
os: ${{ matrix.os }}
build-ksud:
needs: [check-cache, build-ksuinit]
if: needs.check-cache.outputs.cache-hit != 'true'
needs: build-susfsd
strategy:
matrix:
include:
@@ -99,50 +49,8 @@ jobs:
target: ${{ matrix.target }}
os: ${{ matrix.os }}
cache-artifacts:
needs: [check-cache, build-ksud]
if: needs.check-cache.outputs.cache-hit != 'true'
runs-on: ubuntu-latest
steps:
- name: Download susfsd artifacts
uses: actions/download-artifact@v4
with:
name: susfsd-linux-android
path: cached-artifacts/susfsd
- name: Download ksuinit artifacts
uses: actions/download-artifact@v4
with:
pattern: ksuinit-aarch64-linux-android
path: cached-artifacts/ksuinit
merge-multiple: true
- name: Download ksud_overlayfs artifacts
uses: actions/download-artifact@v4
with:
pattern: ksud_overlayfs-*
path: cached-artifacts/ksud_overlayfs
merge-multiple: true
- name: Download ksud_magic artifacts
uses: actions/download-artifact@v4
with:
pattern: ksud_magic-*
path: cached-artifacts/ksud_magic
merge-multiple: true
- name: Cache artifacts
uses: actions/cache/save@v4
with:
path: |
cached-artifacts/susfsd
cached-artifacts/ksud_overlayfs
cached-artifacts/ksud_magic
key: ${{ needs.check-cache.outputs.cache-key }}
build-manager:
needs: [check-cache, build-ksud]
if: always() && needs.check-cache.result == 'success' && (needs.check-cache.outputs.cache-hit == 'true' || needs.build-ksud.result == 'success')
needs: build-ksud
runs-on: ubuntu-latest
defaults:
run:
@@ -184,122 +92,87 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# Restore cached artifacts if cache hit
- name: Restore cached artifacts
if: needs.check-cache.outputs.cache-hit == 'true'
uses: actions/cache/restore@v4
with:
path: |
cached-artifacts/susfsd
cached-artifacts/ksud_overlayfs
cached-artifacts/ksud_magic
key: ${{ needs.check-cache.outputs.cache-key }}
# Download fresh artifacts if cache miss
- name: Download susfsd
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: susfsd-linux-android
path: .
# Download fresh ksud artifacts if cache miss
- name: Copy susfsd to app jniLibs
run: |
mkdir -p app/src/main/jniLibs/arm64-v8a
cp -f ../arm64-v8a/susfsd ../manager/app/src/main/jniLibs/arm64-v8a/libsusfsd.so
mkdir -p app/src/main/jniLibs/armeabi-v7a
cp -f ../armeabi-v7a/susfsd ../manager/app/src/main/jniLibs/armeabi-v7a/libsusfsd.so
mkdir -p app/src/main/jniLibs/x86_64
cp -f ../x86_64/susfsd ../manager/app/src/main/jniLibs/x86_64/libsusfsd.so
- name: Download arm64 ksud_overlayfs
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_overlayfs-aarch64-linux-android
path: ksud_overlayfs
- name: Download arm ksud_overlayfs
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_overlayfs-armv7-linux-androideabi
path: ksud_overlayfs
- name: Download x86_64 ksud_overlayfs
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_overlayfs-x86_64-linux-android
path: ksud_overlayfs
- name: Copy ksud_overlayfs to app jniLibs
run: |
mkdir -p app/src/main/jniLibs/arm64-v8a
mkdir -p app/src/main/jniLibs/armeabi-v7a
mkdir -p app/src/main/jniLibs/x86_64
cp -f ../ksud_overlayfs/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_overlayfs.so
cp -f ../ksud_overlayfs/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_overlayfs.so
cp -f ../ksud_overlayfs/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_overlayfs.so
- name: Download arm64 ksud_magic
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_magic-aarch64-linux-android
path: ksud_magic
- name: Download arm ksud_magic
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_magic-armv7-linux-androideabi
path: ksud_magic
- name: Download x86_64 ksud_magic
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_magic-x86_64-linux-android
path: ksud_magic
# Copy artifacts to jniLibs (works for both cached and fresh)
- name: Copy susfsd to app jniLibs
run: |
mkdir -p app/src/main/jniLibs/arm64-v8a
mkdir -p app/src/main/jniLibs/armeabi-v7a
mkdir -p app/src/main/jniLibs/x86_64
if [ "${{ needs.check-cache.outputs.cache-hit }}" == "true" ]; then
# Copy from cached artifacts
cp -f ../cached-artifacts/susfsd/arm64-v8a/susfsd ../manager/app/src/main/jniLibs/arm64-v8a/libsusfsd.so
cp -f ../cached-artifacts/susfsd/armeabi-v7a/susfsd ../manager/app/src/main/jniLibs/armeabi-v7a/libsusfsd.so
cp -f ../cached-artifacts/susfsd/x86_64/susfsd ../manager/app/src/main/jniLibs/x86_64/libsusfsd.so
else
# Copy from fresh artifacts
cp -f ../arm64-v8a/susfsd ../manager/app/src/main/jniLibs/arm64-v8a/libsusfsd.so
cp -f ../armeabi-v7a/susfsd ../manager/app/src/main/jniLibs/armeabi-v7a/libsusfsd.so
cp -f ../x86_64/susfsd ../manager/app/src/main/jniLibs/x86_64/libsusfsd.so
fi
- name: Copy ksud_overlayfs to app jniLibs
run: |
mkdir -p app/src/main/jniLibs/arm64-v8a
mkdir -p app/src/main/jniLibs/armeabi-v7a
mkdir -p app/src/main/jniLibs/x86_64
if [ "${{ needs.check-cache.outputs.cache-hit }}" == "true" ]; then
# Copy from cached artifacts
cp -f ../cached-artifacts/ksud_overlayfs/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_overlayfs.so
cp -f ../cached-artifacts/ksud_overlayfs/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_overlayfs.so
cp -f ../cached-artifacts/ksud_overlayfs/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_overlayfs.so
else
# Copy from fresh artifacts
cp -f ../ksud_overlayfs/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_overlayfs.so
cp -f ../ksud_overlayfs/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_overlayfs.so
cp -f ../ksud_overlayfs/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_overlayfs.so
fi
- name: Copy ksud_magic to app jniLibs
run: |
mkdir -p app/src/main/jniLibs/arm64-v8a
mkdir -p app/src/main/jniLibs/armeabi-v7a
mkdir -p app/src/main/jniLibs/x86_64
if [ "${{ needs.check-cache.outputs.cache-hit }}" == "true" ]; then
# Copy from cached artifacts
cp -f ../cached-artifacts/ksud_magic/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_magic.so
cp -f ../cached-artifacts/ksud_magic/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_magic.so
cp -f ../cached-artifacts/ksud_magic/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_magic.so
else
# Copy from fresh artifacts
cp -f ../ksud_magic/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_magic.so
cp -f ../ksud_magic/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_magic.so
cp -f ../ksud_magic/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_magic.so
fi
cp -f ../ksud_magic/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_magic.so
cp -f ../ksud_magic/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_magic.so
cp -f ../ksud_magic/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_magic.so
- name: Build with Gradle
run: |

View File

@@ -21,48 +21,12 @@ on:
- cron: "0 12 * * *" # 6 PM UTC+6 | 12 PM UTC
jobs:
check-cache:
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache-artifacts.outputs.cache-hit }}
cache-key: ${{ steps.generate-cache-key.outputs.cache-key }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate cache key from source files
id: generate-cache-key
run: |
# Calculate hash of all files except manager directory
HASH=$(find . -type f \
-not -path "./manager/*" \
-not -path "./.git/*" \
-not -path "./.github/workflows/build-manager-spoofed.yml" \
-exec sha256sum {} \; | sort | sha256sum | cut -d' ' -f1)
echo "cache-key=artifacts-spoofed-$HASH" >> $GITHUB_OUTPUT
echo "Generated cache key: artifacts-spoofed-$HASH"
- name: Check for cached artifacts
id: cache-artifacts
uses: actions/cache@v4
with:
path: |
cached-artifacts/susfsd
cached-artifacts/ksud_overlayfs
cached-artifacts/ksud_magic
key: ${{ steps.generate-cache-key.outputs.cache-key }}
build-lkm:
needs: check-cache
if: needs.check-cache.outputs.cache-hit != 'true'
uses: ./.github/workflows/build-lkm.yml
secrets: inherit
build-susfsd:
needs: [check-cache, build-lkm]
if: needs.check-cache.outputs.cache-hit != 'true'
needs: build-lkm
strategy:
matrix:
include:
@@ -71,22 +35,8 @@ jobs:
with:
os: ${{ matrix.os }}
build-ksuinit:
needs: [check-cache, build-susfsd]
if: needs.check-cache.outputs.cache-hit != 'true'
strategy:
matrix:
include:
- target: aarch64-linux-android
os: ubuntu-latest
uses: ./.github/workflows/ksuinit.yml
with:
target: ${{ matrix.target }}
os: ${{ matrix.os }}
build-ksud:
needs: [check-cache, build-ksuinit]
if: needs.check-cache.outputs.cache-hit != 'true'
needs: build-susfsd
strategy:
matrix:
include:
@@ -101,50 +51,8 @@ jobs:
target: ${{ matrix.target }}
os: ${{ matrix.os }}
cache-artifacts:
needs: [check-cache, build-ksud]
if: needs.check-cache.outputs.cache-hit != 'true'
runs-on: ubuntu-latest
steps:
- name: Download susfsd artifacts
uses: actions/download-artifact@v4
with:
name: susfsd-linux-android
path: cached-artifacts/susfsd
- name: Download ksuinit artifacts
uses: actions/download-artifact@v4
with:
pattern: ksuinit-aarch64-linux-android
path: cached-artifacts/ksuinit
merge-multiple: true
- name: Download ksud_overlayfs artifacts
uses: actions/download-artifact@v4
with:
pattern: ksud_overlayfs-*
path: cached-artifacts/ksud_overlayfs
merge-multiple: true
- name: Download ksud_magic artifacts
uses: actions/download-artifact@v4
with:
pattern: ksud_magic-*
path: cached-artifacts/ksud_magic
merge-multiple: true
- name: Cache artifacts
uses: actions/cache/save@v4
with:
path: |
cached-artifacts/susfsd
cached-artifacts/ksud_overlayfs
cached-artifacts/ksud_magic
key: ${{ needs.check-cache.outputs.cache-key }}
build-manager:
needs: [check-cache, build-ksud]
if: always() && needs.check-cache.result == 'success' && (needs.check-cache.outputs.cache-hit == 'true' || needs.build-ksud.result == 'success')
needs: build-ksud
runs-on: ubuntu-latest
defaults:
run:
@@ -191,122 +99,75 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# Restore cached artifacts if cache hit
- name: Restore cached artifacts
if: needs.check-cache.outputs.cache-hit == 'true'
uses: actions/cache/restore@v4
with:
path: |
cached-artifacts/susfsd
cached-artifacts/ksud_overlayfs
cached-artifacts/ksud_magic
key: ${{ needs.check-cache.outputs.cache-key }}
# Download fresh artifacts if cache miss
- name: Download susfsd
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: susfsd-linux-android
path: .
# Download fresh ksud artifacts if cache miss
- name: Copy susfsd to app jniLibs
run: |
mkdir -p app/src/main/jniLibs/arm64-v8a
cp -f ../arm64-v8a/susfsd ../manager/app/src/main/jniLibs/arm64-v8a/libsusfsd.so
mkdir -p app/src/main/jniLibs/armeabi-v7a
cp -f ../armeabi-v7a/susfsd ../manager/app/src/main/jniLibs/armeabi-v7a/libsusfsd.so
mkdir -p app/src/main/jniLibs/x86_64
cp -f ../x86_64/susfsd ../manager/app/src/main/jniLibs/x86_64/libsusfsd.so
- name: Download arm64 ksud_overlayfs
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_overlayfs-aarch64-linux-android
path: ksud_overlayfs
- name: Download arm ksud_overlayfs
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_overlayfs-armv7-linux-androideabi
path: ksud_overlayfs
- name: Download x86_64 ksud_overlayfs
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_overlayfs-x86_64-linux-android
path: ksud_overlayfs
- name: Copy ksud_overlayfs to app jniLibs
run: |
cp -f ../ksud_overlayfs/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_overlayfs.so
cp -f ../ksud_overlayfs/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_overlayfs.so
cp -f ../ksud_overlayfs/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_overlayfs.so
- name: Download arm64 ksud_magic
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_magic-aarch64-linux-android
path: ksud_magic
- name: Download arm ksud_magic
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_magic-armv7-linux-androideabi
path: ksud_magic
- name: Download x86_64 ksud_magic
if: needs.check-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: ksud_magic-x86_64-linux-android
path: ksud_magic
# Copy artifacts to jniLibs (works for both cached and fresh)
- name: Copy susfsd to app jniLibs
run: |
mkdir -p app/src/main/jniLibs/arm64-v8a
mkdir -p app/src/main/jniLibs/armeabi-v7a
mkdir -p app/src/main/jniLibs/x86_64
if [ "${{ needs.check-cache.outputs.cache-hit }}" == "true" ]; then
# Copy from cached artifacts
cp -f ../cached-artifacts/susfsd/arm64-v8a/susfsd ../manager/app/src/main/jniLibs/arm64-v8a/libsusfsd.so
cp -f ../cached-artifacts/susfsd/armeabi-v7a/susfsd ../manager/app/src/main/jniLibs/armeabi-v7a/libsusfsd.so
cp -f ../cached-artifacts/susfsd/x86_64/susfsd ../manager/app/src/main/jniLibs/x86_64/libsusfsd.so
else
# Copy from fresh artifacts
cp -f ../arm64-v8a/susfsd ../manager/app/src/main/jniLibs/arm64-v8a/libsusfsd.so
cp -f ../armeabi-v7a/susfsd ../manager/app/src/main/jniLibs/armeabi-v7a/libsusfsd.so
cp -f ../x86_64/susfsd ../manager/app/src/main/jniLibs/x86_64/libsusfsd.so
fi
- name: Copy ksud_overlayfs to app jniLibs
run: |
mkdir -p app/src/main/jniLibs/arm64-v8a
mkdir -p app/src/main/jniLibs/armeabi-v7a
mkdir -p app/src/main/jniLibs/x86_64
if [ "${{ needs.check-cache.outputs.cache-hit }}" == "true" ]; then
# Copy from cached artifacts
cp -f ../cached-artifacts/ksud_overlayfs/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_overlayfs.so
cp -f ../cached-artifacts/ksud_overlayfs/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_overlayfs.so
cp -f ../cached-artifacts/ksud_overlayfs/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_overlayfs.so
else
# Copy from fresh artifacts
cp -f ../ksud_overlayfs/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_overlayfs.so
cp -f ../ksud_overlayfs/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_overlayfs.so
cp -f ../ksud_overlayfs/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_overlayfs.so
fi
- name: Copy ksud_magic to app jniLibs
run: |
mkdir -p app/src/main/jniLibs/arm64-v8a
mkdir -p app/src/main/jniLibs/armeabi-v7a
mkdir -p app/src/main/jniLibs/x86_64
cp -f ../ksud_magic/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_magic.so
cp -f ../ksud_magic/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_magic.so
if [ "${{ needs.check-cache.outputs.cache-hit }}" == "true" ]; then
# Copy from cached artifacts
cp -f ../cached-artifacts/ksud_magic/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_magic.so
cp -f ../cached-artifacts/ksud_magic/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_magic.so
cp -f ../cached-artifacts/ksud_magic/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_magic.so
else
# Copy from fresh artifacts
cp -f ../ksud_magic/aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud_magic.so
cp -f ../ksud_magic/armv7-linux-androideabi/release/ksud ../manager/app/src/main/jniLibs/armeabi-v7a/libksud_magic.so
cp -f ../ksud_magic/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_magic.so
fi
cp -f ../ksud_magic/x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud_magic.so
- name: Build with Gradle
run: |

View File

@@ -33,20 +33,8 @@ jobs:
with:
os: ${{ matrix.os }}
build-ksuinit:
needs: build-susfsd
strategy:
matrix:
include:
- target: aarch64-linux-android
os: ubuntu-latest
uses: ./.github/workflows/ksuinit.yml
with:
target: ${{ matrix.target }}
os: ${{ matrix.os }}
build-ksud:
needs: build-ksuinit
needs: build-susfsd
strategy:
matrix:
include:

View File

@@ -6,7 +6,6 @@ on:
- next
paths:
- '.github/workflows/clippy.yml'
- 'userspace/ksuinit/**'
- 'userspace/ksud_magic/**'
- 'userspace/ksud_overlayfs/**'
pull_request:
@@ -14,7 +13,6 @@ on:
- next
paths:
- '.github/workflows/clippy.yml'
- 'userspace/ksuinit/**'
- 'userspace/ksud_magic/**'
- 'userspace/ksud_overlayfs/**'
@@ -34,11 +32,6 @@ jobs:
- name: Setup Cross
run: RUSTFLAGS="" cargo install cross
- name: Cache ksuinit
uses: Swatinem/rust-cache@v2
with:
workspaces: userspace/ksuinit
- name: Cache ksud_overlayfs
uses: Swatinem/rust-cache@v2
with:
@@ -51,8 +44,6 @@ jobs:
- name: Run Clippy
run: |
cross clippy --manifest-path userspace/ksuinit/Cargo.toml --target aarch64-linux-android --release
cross clippy --manifest-path userspace/ksud_magic/Cargo.toml --target aarch64-linux-android --release
cross clippy --manifest-path userspace/ksud_overlayfs/Cargo.toml --target aarch64-linux-android --release

View File

@@ -39,17 +39,16 @@ jobs:
run: |
cp susfsd-linux-android/arm64-v8a/susfsd ./userspace/ksud_overlayfs/bin/aarch64/
cp susfsd-linux-android/arm64-v8a/susfsd ./userspace/ksud_magic/bin/aarch64/
- name: Import ksuinit Binaries
run: |
cp ksuinit-aarch64-linux-android/aarch64-linux-android/release/ksuinit ./userspace/ksud_overlayfs/bin/aarch64/
cp ksuinit-aarch64-linux-android/aarch64-linux-android/release/ksuinit ./userspace/ksud_magic/bin/aarch64/
cp susfsd-linux-android/armeabi-v7a/susfsd ./userspace/ksud_overlayfs/bin/arm/
cp susfsd-linux-android/armeabi-v7a/susfsd ./userspace/ksud_magic/bin/arm/
cp susfsd-linux-android/x86_64/susfsd ./userspace/ksud_overlayfs/bin/x86_64/
cp susfsd-linux-android/x86_64/susfsd ./userspace/ksud_magic/bin/x86_64/
- name: Setup Rust
run: |
rustup update stable
rustup target add x86_64-linux-android
rustup target add aarch64-linux-android
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
- name: Cache ksud_overlayfs
uses: Swatinem/rust-cache@v2

View File

@@ -1,57 +0,0 @@
name: Build ksuinit
on:
workflow_call:
inputs:
target:
required: true
type: string
os:
required: false
type: string
default: ubuntu-latest
pack_lkm:
required: false
type: boolean
default: true
use_cache:
required: false
type: boolean
default: true
jobs:
build:
runs-on: ${{ inputs.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust
run: |
rustup update stable
rustup target add aarch64-linux-android
- name: Set Rust & Android linker
run: |
TOOLCHAIN="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64"
if [ ! -d "$TOOLCHAIN" ]; then
echo "Android NDK not found at $ANDROID_NDK"
exit 1
fi
echo "CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$TOOLCHAIN/bin/aarch64-linux-android21-clang" >> $GITHUB_ENV
- name: Cache ksuinit
uses: Swatinem/rust-cache@v2
with:
workspaces: userspace/ksuinit
cache-targets: false
- name: Build ksuinit
run: |
cargo build --target ${{ inputs.target }} --release --manifest-path ./userspace/ksuinit/Cargo.toml
- name: Upload ksuinit artifact
uses: actions/upload-artifact@v4
with:
name: ksuinit-${{ inputs.target }}
path: userspace/ksuinit/target/**/release/ksuinit

View File

@@ -6,7 +6,6 @@ on:
- 'next'
paths:
- '.github/workflows/rustfmt.yml'
- 'userspace/ksuinit/**'
- 'userspace/ksud_magic/**'
- 'userspace/ksud_overlayfs/**'
pull_request:
@@ -14,7 +13,6 @@ on:
- 'next'
paths:
- '.github/workflows/rustfmt.yml'
- 'userspace/ksuinit/**'
- 'userspace/ksud_magic/**'
- 'userspace/ksud_overlayfs/**'
@@ -31,11 +29,6 @@ jobs:
with:
components: rustfmt
- uses: LoliGothick/rustfmt-check@master
with:
token: ${{ github.token }}
working-directory: userspace/ksuinit
- uses: LoliGothick/rustfmt-check@master
with:
token: ${{ github.token }}

View File

@@ -6,14 +6,6 @@
# For LKM make sure you have imported the androidX-X.X_kernelsu.ko drivers to userspace/ksud_*/bin/aarch64 directory.
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="aarch64-linux-android21-clang"
cross build --target aarch64-linux-android --release --manifest-path ./userspace/ksuinit/Cargo.toml
cp userspace/ksuinit/target/aarch64-linux-android/release/ksuinit userspace/ksud_magic/bin/aarch64/ksuinit
cp userspace/ksuinit/target/aarch64-linux-android/release/ksuinit userspace/ksud_overlayfs/bin/aarch64/ksuinit
cross build --target aarch64-linux-android --release --manifest-path ./userspace/ksud_magic/Cargo.toml
cp userspace/ksud_magic/target/aarch64-linux-android/release/ksud manager/app/src/main/jniLibs/arm64-v8a/libksud_magic.so

View File

@@ -81,6 +81,35 @@ import com.rifsxd.ksunext.ui.util.rootAvailable
@Destination<RootGraph>
@Composable
fun InstallScreen(navigator: DestinationsNavigator) {
var showLkmWarning by rememberSaveable { mutableStateOf(true) }
if (showLkmWarning) {
AlertDialog(
onDismissRequest = {
showLkmWarning = false
navigator.popBackStack()
},
title = { Text(
text = stringResource(R.string.warning),
style = MaterialTheme.typography.titleLarge,
fontWeight = FontWeight.SemiBold
) },
text = { Text(stringResource(R.string.lkm_warning_message)) },
confirmButton = {
TextButton(onClick = { showLkmWarning = false }) {
Text(stringResource(R.string.proceed))
}
},
dismissButton = {
TextButton(onClick = {
showLkmWarning = false
navigator.popBackStack()
}) {
Text(stringResource(R.string.cancel))
}
}
)
}
var installMethod by remember {
mutableStateOf<InstallMethod?>(null)

View File

@@ -231,6 +231,6 @@
<string name="module_sort_enabled_first">Сортиране (първо активирани)</string>
<string name="module_sort_action_first">Сортиране (първо действие)</string>
<string name="module_sort_webui_first">Сортиране (първо WebUI)</string>
<string name="settings_global_namespace_mode">Global Namespace Mode</string>
<string name="settings_global_namespace_mode_summary">All root sessions use the global mount namespace</string>
<string name="settings_global_namespace_mode">Режим на глобално пространство от имена</string>
<string name="settings_global_namespace_mode_summary">Всички сесии на root използват глобалното пространство от имена за монтиране</string>
</resources>

View File

@@ -20,7 +20,7 @@
<string name="home_failure">Firma v2 di KernelSU Next non trovata nel kernel! [ !KSU_NEXT || != size/hash ]</string>
<string name="home_failure_tip">Chiedi allo sviluppatore del kernel d\'integrare KernelSU Next!</string>
<string name="home_kernel">Versione kernel</string>
<string name="hook_mode">Modalità Hook</string>
<string name="hook_mode">Modalità hook</string>
<string name="enable">Abilita</string>
<string name="disable">Disabilita</string>
<string name="enabled">Abilitato</string>
@@ -30,7 +30,7 @@
<string name="home_susfs_version">Versione SuSFS</string>
<string name="home_susfs_sus_su">SuS SU</string>
<string name="home_android">Versione Android</string>
<string name="home_manager_version">Versione Manager</string>
<string name="home_manager_version">Versione manager</string>
<string name="home_abi">ABI</string>
<string name="home_selinux_status">Stato SELinux</string>
<string name="selinux_status_disabled">Disabilitato</string>
@@ -103,7 +103,7 @@
<string name="proceed">Procedi</string>
<string name="cancel">Annulla</string>
<string name="later">Più tardi</string>
<string name="lkm_warning_message">La patch LKM si basa su codici vuoi continuare?</string>
<string name="lkm_warning_message">La patch LKM si basa su componenti closed source. Vuoi continuare?</string>
<string name="home_next_kernelsu">🔥 Prossima build</string>
<string name="home_next_kernelsu_repo">https://github.com/KernelSU-Next/KernelSU-Next</string>
<string name="home_next_kernelsu_body">Prossimo branch sperimentale. Provalo su GitHub!</string>
@@ -176,8 +176,8 @@
<string name="app_profile_template_import_empty">Gli appunti sono vuoti!</string>
<string name="module_changelog_failed">Recupero del changelog non riuscito: %s</string>
<string name="settings_check_update">Controlla aggiornamenti</string>
<string name="settings_check_update_summary">Cerca automaticamente gli aggiornamenti all\'apertura dell\'applicazione.</string>
<string name="grant_root_failed">Impossibile concedere i permessi root! </string>
<string name="settings_check_update_summary">Cerca automaticamente gli aggiornamenti all\'apertura dell\'applicazione</string>
<string name="grant_root_failed">Impossibile concedere i permessi root!</string>
<string name="action">Azione</string>
<string name="webui">WebUI</string>
<string name="open">Apri</string>

View File

@@ -41,7 +41,7 @@
<string name="module_failed_to_enable">Não foi possível ativar o módulo %s</string>
<string name="module_failed_to_disable">Não foi possível desativar o módulo %s</string>
<string name="module_empty">Nenhum módulo instalado</string>
<string name="module">Módulo</string>
<string name="module">Módulos</string>
<string name="module_install_prompt_with_name">Os seguintes módulos serão instalados: %1$s</string>
<string name="module_sort_a_to_z">Ordenar (A → Z)</string>
<string name="module_sort_z_to_a">Organizar (Z → A)</string>
@@ -73,7 +73,7 @@
<string name="module_update_json">UpdateJson</string>
<string name="module_update_json_empty">Vazio</string>
<string name="enable_developer_options">Ativar opções do desenvolvedor</string>
<string name="enable_developer_options_summary">Exibe as configurações ocultas e informações de depuração relevantes apenas para desenvolvedores.</string>
<string name="enable_developer_options_summary">Exibe ajustes ocultos e informações de depuração relevantes apenas para desenvolvedores.</string>
<string name="module_overlay_fs_not_available">Os módulos estão indisponíveis porque OverlayFS está desabilitado pelo kernel!</string>
<string name="refresh">Atualizar</string>
<string name="show_system_apps">Mostrar apps do sistema</string>
@@ -97,7 +97,7 @@
<string name="allowlist_restore">Restaurar lista de permissões</string>
<string name="allowlist_restore_message">Restaure a lista de permissões de um backup recente.</string>
<string name="allowlist_backup">Backup da lista de permissões</string>
<string name="allowlist_backup_message">Faça backup da lista de permissões configurada atualmente.</string>
<string name="allowlist_backup_message">Faça backup da lista de permissões atual.</string>
<string name="warning">Aviso</string>
<string name="warning_message">Este recurso ainda está em beta e em desenvolvimento. Certifique-se de fazer backup de seus módulos antes de continuar. Use esse recurso somente se você compreender os riscos potenciais. Proceda com cautela.</string>
<string name="proceed">Prosseguir</string>
@@ -231,6 +231,6 @@
<string name="module_sort_enabled_first">Ordenar (Habilitado primeiro)</string>
<string name="module_sort_action_first">Ordenar (exceto primeiro)</string>
<string name="module_sort_webui_first">Ordenar (WebUI primeiro)</string>
<string name="settings_global_namespace_mode">Global Namespace Mode</string>
<string name="settings_global_namespace_mode_summary">All root sessions use the global mount namespace</string>
<string name="settings_global_namespace_mode">Modo de namespace global</string>
<string name="settings_global_namespace_mode_summary">Todas as sessões raiz usam o namespace de montagem global</string>
</resources>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="issue_report_title">Возникли проблемы?</string>
<string name="issue_report_body">Обнаружена ошибка или нужна обратная связь?</string>
<string name="issue_report_body">Заметили ошибку или есть предложения?</string>
<string name="issue_report_body_2">Сообщите об этом как можно скорее!</string>
<string name="issue_report_github">Сообщить на GitHub</string>
<string name="issue_report_telegram">Связаться через Telegram</string>
@@ -96,7 +96,7 @@
<string name="module_backup">Бэкап модулей</string>
<string name="allowlist_restore">Восстановить список прав</string>
<string name="allowlist_restore_message">Восстановить список прав из последней резервной копии.</string>
<string name="allowlist_backup">Бэкап списка разрешений</string>
<string name="allowlist_backup">Бэкап списка прав</string>
<string name="allowlist_backup_message">Резервное копирование текущего списка разрешений.</string>
<string name="warning">Предупреждение</string>
<string name="warning_message">Эта функция всё ещё находится в стадии бета-тестирования. Пожалуйста, убедитесь, что вы создали резервные копии модулей перед использованием. Используйте это только если понимаете возможные риски. Будьте осторожны.</string>
@@ -117,7 +117,7 @@
<string name="profile">Профиль Приложения</string>
<string name="profile_default">По умолчанию</string>
<string name="profile_template">Шаблон</string>
<string name="profile_custom">Пользовательский</string>
<string name="profile_custom">Настроить</string>
<string name="profile_name">Имя профиля</string>
<string name="profile_namespace">Пространство монтирования</string>
<string name="profile_namespace_inherited">Унаследованный</string>
@@ -130,10 +130,10 @@
<string name="failed_to_update_app_profile">Не удалось обновить Профиль Приложения для %s</string>
<string name="require_kernel_version">Текущая версия KernelSU Next %1$d слишком низкая для корректной работы менеджера. Пожалуйста, обновитесь до версии %2$d или выше!</string>
<string name="settings_umount_modules_default">Размонтировать модули</string>
<string name="settings_umount_modules_default_summary">По умолчанию включает статус \"Umount\" для приложений. Если эта настройка включена, то все модификации, внесённые модулями, будут удалены для приложений без включённого root-доступа.</string>
<string name="settings_umount_modules_default_summary">Глобальное значение по умолчанию для параметра \"Размонтировать модули\" в Профиле Приложения. Если этот параметр включён, то все изменения, внесённые модулями, будут скрыты для приложений без установленного профиля или root-доступа.</string>
<string name="settings_susfs_toggle">Скрыть хук kprobes</string>
<string name="settings_susfs_toggle_summary">Эта опция отключает хук kprobes, созданный ksu, и вместо него активирует встроенный хук без использования kprobes, реализующий ту же функциональность, которая применяется к ядрам без GKI, не поддерживающим kprobe.</string>
<string name="profile_umount_modules_summary">Если эта настройка включена, то все модификации, внесённые модулями, будут удалены для данного приложения.</string>
<string name="profile_umount_modules_summary">Если этот параметр включен, то все модификации, внесённые модулями, будут скрыты для данного приложения.</string>
<string name="profile_selinux_domain">Домен</string>
<string name="profile_selinux_rules">Правила</string>
<string name="module_update">Обновить</string>
@@ -153,7 +153,7 @@
<string name="failed_to_update_sepolicy">Не удалось обновить правила SELinux для %s</string>
<string name="su_not_allowed">Предоставление прав суперпользователя запрещено для: %s</string>
<string name="module_changelog">Журнал изменений</string>
<string name="settings_profile_template">Шаблоны доступа</string>
<string name="settings_profile_template">Шаблоны root-доступа</string>
<string name="settings_profile_template_summary">Управление локальными и онлайн шаблонами root-доступа.</string>
<string name="app_profile_template_create">Создать шаблон</string>
<string name="app_profile_template_edit">Изменить шаблон</string>
@@ -231,6 +231,6 @@
<string name="module_sort_enabled_first">По статусу (Сначала включённые)</string>
<string name="module_sort_action_first">По статусу (Сначала со скриптом)</string>
<string name="module_sort_webui_first">По статусу (Сначала с WebUI)</string>
<string name="settings_global_namespace_mode">Общее пространство имён</string>
<string name="settings_global_namespace_mode_summary">Все сессии пользователя root будут использовать общее пространство имён</string>
<string name="settings_global_namespace_mode">Общее пространство монтирования</string>
<string name="settings_global_namespace_mode_summary">Все сессии root используют одну файловую систему.</string>
</resources>

View File

@@ -82,7 +82,7 @@
<string name="safe_mode">Güvenli mod</string>
<string name="reboot_to_apply">Etkili olması için yeniden başlatın</string>
<string name="module_magisk_conflict">Magisk ile yaşanan bir çakışma nedeniyle modüller kullanılamıyor!</string>
<string name="home_mount_system">Montaj sistemi</string>
<string name="home_mount_system">Bağlantı sistemi</string>
<string name="home_magic_mount">Magic Mount</string>
<string name="home_overlayfs_mount">OverlayFS</string>
<string name="unavailable">Mevcut değil</string>

View File

@@ -170,7 +170,7 @@
<string name="app_profile_import_from_clipboard">Nhập từ bộ nhớ tạm</string>
<string name="app_profile_export_to_clipboard">Xuất vào bộ nhớ tạm</string>
<string name="app_profile_template_export_empty">Không tìm thấy mẫu cục bộ để xuất!</string>
<string name="app_profile_template_import_success">Nhập thành công</string>
<string name="app_profile_template_import_success">Đã nhập thành công</string>
<string name="app_profile_template_sync">Đồng bộ hoá các mẫu trực tuyến</string>
<string name="app_profile_template_save_failed">Lưu mẫu thất bại</string>
<string name="app_profile_template_import_empty">Bộ nhớ tạm đang trống!</string>
@@ -186,7 +186,7 @@
<string name="direct_install">Cài đặt trực tiếp (Khuyến nghị)</string>
<string name="select_file">Chọn file</string>
<string name="install_inactive_slot">Cài đặt vào phân vùng không hoạt động (Sau OTA)</string>
<string name="install_inactive_slot_warning">Thiết bị của bạn sẽ **BUỘC** phải khởi động vào phân vùng không hoạt động hiện tại sau khi khởi động lại!\nChỉ sử dụng tùy chọn này sau khi OTA hoàn tất.\nTiếp tục?</string>
<string name="install_inactive_slot_warning">Thiết bị của bạn sẽ **BUỘC** phải khởi động vào phân vùng không hoạt động hiện tại sau khi khởi động lại!\nChỉ sử dụng tùy chọn này sau khi cập nhật OTA hoàn tất.\nTiếp tục?</string>
<string name="install_next">Tiếp tục</string>
<string name="select_file_tip">Phân vùng image %1$s được khuyến nghị</string>
<string name="select_kmi">Chọn KMI</string>

View File

@@ -1,3 +1,2 @@
**/*.ko
susfsd
ksuinit
susfsd

View File

@@ -1,3 +1,2 @@
**/*.ko
susfsd
ksuinit
susfsd

View File

@@ -1 +0,0 @@
target

View File

@@ -1,240 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "anyhow"
version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
[[package]]
name = "bitflags"
version = "2.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
[[package]]
name = "errno"
version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
dependencies = [
"libc",
"windows-sys",
]
[[package]]
name = "goblin"
version = "0.8.0"
source = "git+https://github.com/tiann/goblin#138d40d4c36471cfbb611eb493f0378ee9fc63f5"
dependencies = [
"log",
"plain",
"scroll 0.12.0",
]
[[package]]
name = "kernlog"
version = "0.3.1"
source = "git+https://github.com/tiann/kernlog.rs#ff0b1bd6d5261eae0fa297cec6951fe8d982151a"
dependencies = [
"libc",
"log",
]
[[package]]
name = "ksuinit"
version = "0.1.0"
dependencies = [
"anyhow",
"goblin",
"kernlog",
"log",
"obfstr",
"rustix",
"scroll 0.13.0",
"syscalls",
]
[[package]]
name = "libc"
version = "0.2.174"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
[[package]]
name = "linux-raw-sys"
version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
[[package]]
name = "log"
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "obfstr"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0d354e9a302760d07e025701d40534f17dd1fe4c4db955b4e3bd2907c63bdee"
[[package]]
name = "plain"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
[[package]]
name = "proc-macro2"
version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rustix"
version = "0.38.34"
source = "git+https://github.com/Kernel-SU/rustix.git?rev=4a53fbc#4a53fbc7cb7a07cabe87125cc21dbc27db316259"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys",
]
[[package]]
name = "scroll"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6"
dependencies = [
"scroll_derive",
]
[[package]]
name = "scroll"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1257cd4248b4132760d6524d6dda4e053bc648c9070b960929bf50cfb1e7add"
[[package]]
name = "scroll_derive"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "syn"
version = "2.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syscalls"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43d0e35dc7d73976a53c7e6d7d177ef804a0c0ee774ec77bcc520c2216fd7cbe"
[[package]]
name = "unicode-ident"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

View File

@@ -1,34 +0,0 @@
[package]
name = "ksuinit"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
# for elf parsing
goblin = { git = "https://github.com/tiann/goblin" }
scroll = "0.13"
anyhow = "1"
# If you want to use the following dependencies, please use aarch64-unknown-linux-musl & x86_64-unknown-linux-musl to compile statically
# rustix = { git = "https://github.com/bytecodealliance/rustix", rev = "7b44528", features = ["mount", "fs", "runtime", "system", "process"] }
rustix = { git = "https://github.com/Kernel-SU/rustix.git", rev = "4a53fbc", features = ["mount", "fs", "runtime", "system", "process"] }
syscalls = { version = "0.6", default-features = false, features = [
"aarch64",
"x86_64",
] }
# for kmsg logging
log = "0.4"
kernlog = { git = "https://github.com/tiann/kernlog.rs" }
obfstr = "0.4"
[profile.release]
strip = true
lto = true
opt-level = "z"
panic = "abort"

View File

@@ -1,185 +0,0 @@
use std::io::{ErrorKind, Write};
use crate::loader::load_module;
use anyhow::Result;
use rustix::fs::{chmodat, symlink, unlink, AtFlags, Mode};
use rustix::{
fd::AsFd,
fs::{access, makedev, mkdir, mknodat, Access, FileType, CWD},
mount::{
fsconfig_create, fsmount, fsopen, move_mount, unmount, FsMountFlags, FsOpenFlags,
MountAttrFlags, MoveMountFlags, UnmountFlags,
},
};
use obfstr::obfstr as s;
struct AutoUmount {
mountpoints: Vec<String>,
}
impl Drop for AutoUmount {
fn drop(&mut self) {
for mountpoint in self.mountpoints.iter().rev() {
if let Err(e) = unmount(mountpoint.as_str(), UnmountFlags::DETACH) {
log::error!("{} {}: {}", s!("Cannot umount"), mountpoint, e)
}
}
}
}
fn prepare_mount() -> AutoUmount {
let mut mountpoints = vec![];
// mount procfs
let result = mkdir("/proc", Mode::from_raw_mode(0o755))
.or_else(|err| match err.kind() {
ErrorKind::AlreadyExists => Ok(()),
_ => Err(err),
})
.and_then(|_| fsopen("proc", FsOpenFlags::FSOPEN_CLOEXEC))
.and_then(|fd| fsconfig_create(fd.as_fd()).map(|_| fd))
.and_then(|fd| {
fsmount(
fd.as_fd(),
FsMountFlags::FSMOUNT_CLOEXEC,
MountAttrFlags::empty(),
)
})
.and_then(|fd| {
move_mount(
fd.as_fd(),
"",
CWD,
"/proc",
MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH,
)
});
match result {
Ok(_) => mountpoints.push("/proc".to_string()),
Err(e) => log::error!("{} {:?}", s!("Cannot mount procfs: "), e),
}
// mount sysfs
let result = mkdir("/sys", Mode::from_raw_mode(0o755))
.or_else(|err| match err.kind() {
ErrorKind::AlreadyExists => Ok(()),
_ => Err(err),
})
.and_then(|_| fsopen("sysfs", FsOpenFlags::FSOPEN_CLOEXEC))
.and_then(|fd| fsconfig_create(fd.as_fd()).map(|_| fd))
.and_then(|fd| {
fsmount(
fd.as_fd(),
FsMountFlags::FSMOUNT_CLOEXEC,
MountAttrFlags::empty(),
)
})
.and_then(|fd| {
move_mount(
fd.as_fd(),
"",
CWD,
"/sys",
MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH,
)
});
match result {
Ok(_) => mountpoints.push("/sys".to_string()),
Err(e) => log::error!("{} {:?}", s!("Cannot mount sysfs:"), e),
}
AutoUmount { mountpoints }
}
fn setup_kmsg() {
const KMSG: &str = "/dev/kmsg";
let device = match access(KMSG, Access::EXISTS) {
Ok(_) => KMSG,
Err(_) => {
// try to create it
mknodat(
CWD,
"/kmsg",
FileType::CharacterDevice,
0o666.into(),
makedev(1, 11),
)
.ok();
"/kmsg"
}
};
let _ = kernlog::init_with_device(device);
}
fn unlimit_kmsg() {
// Disable kmsg rate limiting
if let Ok(mut rate) = std::fs::File::options()
.write(true)
.open(s!("/proc/sys/kernel/printk_devkmsg"))
{
writeln!(rate, "on").ok();
}
}
pub fn init() -> Result<()> {
// Setup kernel log first
setup_kmsg();
log::info!("{}", s!("Hello, KernelSU!"));
// mount /proc and /sys to access kernel interface
let _dontdrop = prepare_mount();
// This relies on the fact that we have /proc mounted
unlimit_kmsg();
if has_kernelsu() {
log::info!("{}", s!("KernelSU may be already loaded in kernel, skip!"));
} else {
log::info!("{}", s!("Loading kernelsu.ko.."));
if let Err(e) = load_module(s!("/kernelsu.ko")) {
log::error!("{}: {}", s!("Cannot load kernelsu.ko"), e);
}
}
// And now we should prepare the real init to transfer control to it
unlink("/init")?;
let real_init = match access("/init.real", Access::EXISTS) {
Ok(_) => "init.real",
Err(_) => "/system/bin/init",
};
log::info!("{} {}", s!("init is"), real_init);
symlink(real_init, "/init")?;
chmodat(
CWD,
"/init",
Mode::from_raw_mode(0o755),
AtFlags::SYMLINK_NOFOLLOW,
)?;
Ok(())
}
fn has_kernelsu() -> bool {
use syscalls::{syscall, Sysno};
let mut version = 0;
const CMD_GET_VERSION: i32 = 2;
unsafe {
let _ = syscall!(
Sysno::prctl,
0xDEADBEEF,
CMD_GET_VERSION,
std::ptr::addr_of_mut!(version)
);
}
log::info!("{}: {}", s!("KernelSU version"), version);
version != 0
}

View File

@@ -1,97 +0,0 @@
use anyhow::{Context, Result};
use goblin::elf::{section_header, sym::Sym, Elf};
use rustix::{cstr, system::init_module};
use scroll::{ctx::SizeWith, Pwrite};
use std::collections::HashMap;
use std::fs;
use obfstr::obfstr as s;
struct Kptr {
value: String,
}
impl Kptr {
pub fn new() -> Result<Self> {
let value = fs::read_to_string(s!("/proc/sys/kernel/kptr_restrict"))?;
fs::write(s!("/proc/sys/kernel/kptr_restrict"), "1")?;
Ok(Kptr { value })
}
}
impl Drop for Kptr {
fn drop(&mut self) {
let _ = fs::write(s!("/proc/sys/kernel/kptr_restrict"), self.value.as_bytes());
}
}
fn parse_kallsyms() -> Result<HashMap<String, u64>> {
let _dontdrop = Kptr::new()?;
let allsyms = fs::read_to_string(s!("/proc/kallsyms"))?
.lines()
.map(|line| line.split_whitespace())
.filter_map(|mut splits| {
splits
.next()
.and_then(|addr| u64::from_str_radix(addr, 16).ok())
.and_then(|addr| splits.nth(1).map(|symbol| (symbol, addr)))
})
.map(|(symbol, addr)| {
(
symbol
.find("$").or_else(|| symbol.find(".llvm."))
.map_or(symbol, |pos| &symbol[0..pos])
.to_owned(),
addr,
)
})
.collect::<HashMap<_, _>>();
Ok(allsyms)
}
pub fn load_module(path: &str) -> Result<()> {
// check if self is init process(pid == 1)
if !rustix::process::getpid().is_init() {
anyhow::bail!("{}", s!("Invalid process"));
}
let mut buffer =
fs::read(path).with_context(|| format!("{} {}", s!("Cannot read file"), path))?;
let elf = Elf::parse(&buffer)?;
let kernel_symbols =
parse_kallsyms().with_context(|| s!("Cannot parse kallsyms").to_string())?;
let mut modifications = Vec::new();
for (index, mut sym) in elf.syms.iter().enumerate() {
if index == 0 {
continue;
}
if sym.st_shndx != section_header::SHN_UNDEF as usize {
continue;
}
let Some(name) = elf.strtab.get_at(sym.st_name) else {
continue;
};
let offset = elf.syms.offset() + index * Sym::size_with(elf.syms.ctx());
let Some(real_addr) = kernel_symbols.get(name) else {
log::warn!("{}: {}", s!("Cannot found symbol"), &name);
continue;
};
sym.st_shndx = section_header::SHN_ABS as usize;
sym.st_value = *real_addr;
modifications.push((sym, offset));
}
let ctx = *elf.syms.ctx();
for ele in modifications {
buffer.pwrite_with(ele.0, ele.1, ctx)?;
}
init_module(&buffer, cstr!("")).with_context(|| s!("init_module failed.").to_string())?;
Ok(())
}

View File

@@ -1,19 +0,0 @@
#![no_main]
mod init;
mod loader;
use rustix::{cstr, runtime::execve};
/// # Safety
/// This is the entry point of the program
/// We cannot use the main because rust will abort if we don't have std{in/out/err}
/// https://github.com/rust-lang/rust/blob/3071aefdb2821439e2e6f592f41a4d28e40c1e79/library/std/src/sys/unix/mod.rs#L80
/// So we use the C main function and call rust code from there
#[no_mangle]
pub unsafe extern "C" fn main(_argc: i32, argv: *const *const u8, envp: *const *const u8) -> i32 {
let _ = init::init();
unsafe {
execve(cstr!("/init"), argv, envp);
}
0
}