Feat/battery threshold#7
Conversation
3e0bb43 to
f61b992
Compare
|
I had to add some machine translated bits for a few missing translations though, is that gonna be a problem? I can remove them if yes |
|
It's Ok to use help of LLM for translations, but basically you should not submit translations for languages that you cannot fully understand and fix manually. So only submit english + the languages you fully master that exist in noctalia core. I'm adding this to the PR checklist for clarity. Currently there is no Turkish translations available in v5, so the tr.json file should be removed. Let us know for the other languages, thanks. |
|
Cool, yeah I don't really understand those, I just copied translation files from the old plugin so I'm gonna remove them all later |
cf534fa to
62bee30
Compare
The configurable battery path is concatenated directly into runAsync. Noctalia executes string commands through /bin/sh -lc, so shell metacharacters in the configured directory can execute arbitrary commands as the Noctalia user. Paths containing spaces also break the writable check. The setup command at battery-threshold/service.luau:138 has the same unquoted construction problem.
The plugin elevates setup_rules.sh from the user-writable materialized plugin directory. The script then reads another user-writable file at battery-threshold/setup_rules.sh:16 and installs it into /etc/udev/rules.d at battery-threshold/setup_rules.sh:48. Either file can be replaced while authentication is pending, allowing substituted root script or udev-rule content to be installed with elevated privileges. This creates a local privilege-escalation path.
The manifest declares only polkit, but the plugin invokes test, pkexec, bash, readlink, getent, groupadd, usermod, cp, and udevadm. The udev rule also invokes chgrp and chmod. Repository policy requires external commands to be listed in dependencies and documented. Missing tools can make the required setup fail without the catalog disclosing those requirements.
threshold.txt is written using a relative path and the write result is ignored. It is then read at battery-threshold/service.luau:102. Relative paths resolve inside the materialized plugin directory, which is not update-safe. A plugin update or failed write can silently lose the slider-selected threshold. Noctalia's pluginDataDir() should be used for persistent plugin data. |
|
Regarding this
Do you have a suggestion on what could be changed? I honestly can't think of any way to make it fully secure other than just ditching the interactive setup and letting user handle all of it. I could just add a note in the docs that threshold file has to be writable and let user set it up, while leaving the setup script in here as a convenient way of doing it. If I did that I also don't have to list all the external tools used by the script right? |
|
You can keep the setup script. We already allow this pattern in the IdeaPad conservation-mode plugin, so removing interactive setup is not required. Please make the script self-contained instead of loading and copying a second file from the plugin directory. Write the fixed udev rule directly from setup_rules.sh, safely quote the script path and username in service.luau, validate the target user, and preferably run it visibly through a terminal with sudo like the IdeaPad plugin. Also be aware the plugin.toml has changed, The readme should follow the README_TEMPALTE.md as much as possible, and list all the external commands you use in there. The thumbnail text is truncated "lifesp" you should regenerate with a shorter sentence. |
|
Thanks for feedback, I'll get to it when I have some time |
Plugin
damian-ds7/battery-thresholdplugin.toml)What it does
Ports the battery threshold plugin from legacy-v4-plugins/battery-threshold.
It lets you set a battery charging threshold, and automatically reapplies it on system restart.
External dependencies
Uses polkit to make initial setup easier with an auth popup via pkexec, but it's not required and can be ran manually by user with sudo
Testing
Tested opening panel via ipc and bar widget, setting threshold via ipc and slider, threshold persistence after reboot
Screenshots / Videos
Checklist
idafter the/inplugin.tomlexactly.plugin.toml,README.md,thumbnail.webp, andtranslations/en.json.versionfollows semver and is bumped in this PR;min_noctaliais the version I tested against.translations/en.json(no machine-translated locales).catalog.toml; CI generates it.Code review attestation
Plugins run as trusted, unsandboxed Luau in the user's session. Confirm:
licensedeclared inplugin.toml.Regarding translations, I didn't add anything new just restructured existing ones to work with new format