Fix: handle legacy files in NO_SUDO mode#133
Conversation
|
Hi, Thanks for the very well documented problem and PR. I have reviewed your implementation and suggested some changes. |
…script to abort. Disabled set -e temporarily for this check and re-enabled it after execution
|
Hi @leopoldhub, I have reverted my last two commits (matching actual_installation_path="$(which 'fw-fanctrl' 2>/dev/null)"Since set -e is enabled, when this command returns a non-zero value, it breaks the script and stops execution. Second ProblemThe script continues execution until this line: ./post-install.sh --dest-dir "$DEST_DIR" --sysconf-dir "$SYSCONF_DIR" "$([ "$NO_SUDO" = true ] && echo "--no-sudo")"It passes this root check in # Root check
if [ "$EUID" -ne 0 ] && [ "$NO_SUDO" = false ]
then
echo "This program requires root permissions or use the '--no-sudo' option"
exit 1
fiSince it's using systemctl daemon-reloadThis fails because the user is not root.. I believe this root check should be: # Root check
if [ "$EUID" -ne 0 ] || [ "$NO_SUDO" = true]
then
echo "This program requires root permissions or use the '--no-sudo' option"
exit 1
fiBehavior:
However, I wanted to check with you before changing anything, since the root check is written the same way in both |
|
Hi @leopoldhub, Apologies for the repeated check, but I’m still waiting for your input regarding the root check in both |
|
Hi, sorry for the delay. I think the conditions are working as expected. The For example, a user who has set their default permissions to be able to run Since I hope this was useful, please let me know if it wasn't clear or if you have any further questions. |
|
For the |
|
In the install script, if I replace Since we know that users without '--no-sudo')
NO_SUDO=true
SHOULD_POST_INSTALL=false
SHOULD_PRE_UNINSTALL=false
;;Because we should either prevent the known error or provide a clear error message guiding users to use these flags, I prefer preventing the error. |
No, as explained in my previous message, users and processes running the script with Also, the philosophy here is to do the maximum (aka attempting a full install) except when explicitly specified. In your example, we cannot differentiate between a user/process that knows that it will not install everything and a mistake. We can however tell the user that it failed as executing the prev/post scripts and steps to fix it. |
…nstall and post-install scripts, providing user guidance for permission issues.
e18c5be to
781b435
Compare
|
@leopoldhub , waiting for your review. It might seem like a lot of changes, but it's actually small changes spread across the last three commits (before the merge commit). |
leopoldhub
left a comment
There was a problem hiding this comment.
Hey,
Sorry for the delay, I have been busy lately.
I left a single comment on one of your changes, after that it should be good!
|
Thank you very much for your contribution, |
Fix issue 132: handle legacy files in NO_SUDO mode
Summary
This pull request improves the installer to properly handle legacy files when
--no-sudomode is used. It prevents permission errors by detecting global legacy files or system-installed Python packages that cannot be removed without root privileges. In such cases, the installer aborts and provides clear instructions to the user on how to resolve the situation.Changes Introduced
NO_SUDO=truemode:fw-fanctrlPython package exists.sudo ./install.sh --removefw-fanctrlPython package:sudo python -m pip uninstall fw-fanctrlTesting Instructions
--no-sudoand no legacy files--no-sudoand leftover global filessudo ./install.sh --remove--no-sudoand system-installedfw-fanctrlsudo python -m pip uninstall fw-fanctrlTo test:
sudowhen old/usr/local/bin/fw-fanctrlexists.sudowhen an old system-widefw-fanctrlPython package is still installed.--no-sudoto verify backward compatibility.Notes
--no-sudoinstallations.sudoworkflows will not be affected.