Skip to content

feat(root): refactor root access - #107

Draft
researchxxl wants to merge 57 commits into
mainfrom
refactorRoot
Draft

feat(root): refactor root access#107
researchxxl wants to merge 57 commits into
mainfrom
refactorRoot

Conversation

@researchxxl

@researchxxl researchxxl commented Jan 10, 2026

Copy link
Copy Markdown
Owner
  • restore outdated and buggy old root code
  • migrate settings screen to kotlin
  • use a maintained libsuperuser dependency instead of the old unmaintained one
  • add code conflict detection works with root

step 1 restore outdated and buggy old root code
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted January 20, 2026 23:05 — with GitHub Actions Inactive
@vale981

vale981 commented Jan 26, 2026

Copy link
Copy Markdown

Currently running the debug build :). Can confirm that this works. Thanks :)

@vale981

vale981 commented Jan 26, 2026

Copy link
Copy Markdown

Currently the "Run Script" feature does not work as the scripts ion ".stfolder" are likely not accessible due to permission issues. Would it be possible to fix this?

@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted January 31, 2026 12:40 — with GitHub Actions Inactive
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted February 4, 2026 11:43 — with GitHub Actions Inactive
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted February 6, 2026 13:09 — with GitHub Actions Inactive
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted February 8, 2026 15:38 — with GitHub Actions Inactive
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted February 9, 2026 21:09 — with GitHub Actions Inactive
@researchxxl

researchxxl commented Feb 15, 2026

Copy link
Copy Markdown
Owner Author

@vale981

Currently the "Run Script" feature does not work as the scripts ion ".stfolder" are likely not accessible due to permission issues. Would it be possible to fix this?

pls look at util.runScriptSet and runShellCommandGetOutput(command, false).. if you set true you will get root exec of the scripts

needs secure and proper implementation tbh for being accepted here and file permissions should be checked before

@researchxxl

Copy link
Copy Markdown
Owner Author

@dbhavsar76 may i kindly ask if you like to have fun with this?? it is also ok for me if you dont take the challenge

@dbhavsar76

Copy link
Copy Markdown
Contributor

I'll see what i can do. No promises. Meanwhile, I have the drawer ready.

@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted July 1, 2026 10:13 — with GitHub Actions Inactive
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted July 8, 2026 15:14 — with GitHub Actions Inactive
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted July 22, 2026 13:33 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown

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 refactors the app’s “run Syncthing as root” support by introducing a root capability check, adding a user-facing root toggle in settings, and updating service/runtime behavior to execute process management and permission-repair steps with root where appropriate.

Changes:

  • Add RootAccess helper and a new “Run Syncthing as Superuser” preference, wiring it into the settings UI and runtime startup logic.
  • Adjust shell-command helpers and Syncthing process management to optionally execute via su, including environment setup when launching Syncthing under root.
  • Attempt to repair app data permissions/SELinux contexts when config read/write fails (to recover from prior root-owned files).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
gradle/libs.versions.toml Adds libsuperuser version + catalog entry for root availability checks.
app/build.gradle.kts Adds the libsuperuser dependency to the app module.
app/src/main/res/values/strings.xml Adds user-facing strings for root toggle + root denial toast.
app/src/main/java/com/nutomic/syncthingandroid/util/Util.java Adds permission-fix helper and root-capable shell execution helpers.
app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java Attempts permission repair before failing config parse/save due to access issues.
app/src/main/java/com/nutomic/syncthingandroid/settings/SettingsBehaviorScreen.kt Adds UI switch to enable/disable root mode and restarts service on change.
app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java Stops treating use_root as deprecated during pref import.
app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingRunnable.java Runs process discovery/kill and syncthing launch via root when enabled.
app/src/main/java/com/nutomic/syncthingandroid/service/Constants.java Introduces PREF_USE_ROOT constant.
app/src/main/java/com/nutomic/syncthingandroid/root/RootAccess.java New helper for blocking root availability check via libsuperuser.
app/src/main/java/com/nutomic/syncthingandroid/receiver/BootReceiver.java Kills leftover SyncthingNative after app update when running in root mode.
Suppressed comments (1)

app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java:1267

  • Same pattern as in parseConfig(): after attempting fixAppDataPermissions(), re-check writability before proceeding, otherwise the method may continue and fail later when trying to write the temp file/rename, while the log suggests the permission issue was handled.
        if (!mConfigFile.canWrite() && !Util.fixAppDataPermissions(mContext)) {
            Log.w(TAG, "Failed to save updated config. Cannot change the owner of the config file.");
            return;
        }

Comment thread app/src/main/res/values/strings.xml
Comment thread app/src/main/res/values/strings.xml Outdated
Comment thread app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java
Repository owner deleted a comment from Copilot AI Aug 4, 2026
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted August 4, 2026 09:57 — with GitHub Actions Inactive
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jonas <244199422+researchxxl@users.noreply.github.com>
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted August 4, 2026 10:04 — with GitHub Actions Inactive
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted August 4, 2026 10:10 — with GitHub Actions Inactive
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted August 4, 2026 10:29 — with GitHub Actions Inactive
@researchxxl
researchxxl temporarily deployed to dev-sign-untrusted August 4, 2026 10:38 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[root] Add Full Device Storage Access [root] Updating shows error : "failed to read the configuration"

5 participants