Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adblock: initscript seems to exit on any valid argument #26090

Open
brianjmurrell opened this issue Mar 5, 2025 · 0 comments · May be fixed by #26091
Open

adblock: initscript seems to exit on any valid argument #26090

brianjmurrell opened this issue Mar 5, 2025 · 0 comments · May be fixed by #26091

Comments

@brianjmurrell
Copy link
Contributor

I'm not sure I'm understanding the logic/intention of this line:

[ -s "${adb_pidfile}" ] && { [ "${action}" = "start" ] || [ "${action}" = "stop" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "report" ] || [ "${action}" = "suspend" ] || [ "${action}" = "resume" ] || [ "${action}" = "query" ] || { [ "${action}" = "list" ] && [ -n "${1}" ]; }; } && exit 1

To me, this reads as if the PIDFILE exists (and is not empty) AND if argument 1 of the script is any of the valid actions for the script then exit 1.

Am I reading that correctly? If so why would that initscript want to exit 1 when called with a valid action?

While this seems pretty basic to me, what's making me question my understanding here is that this logic seems to have been in place for 6 years now and it just seems unbelievable to me that such a fundamental aspect of the script could be broken for that long. So I feel I must be missing something, probably pretty obvious here.

Digging further, it seems that in bc299d0 the logic of the individual [ "${action}" != "…" ] && list was inverted but without inverting the the result of the entire group to maintain the overall logic as such:

[ -s "${adb_pidfile}" ] && ! { [ "${action}" = "start" ] ||
                               [ "${action}" = "stop" ] ||
                               [ "${action}" = "restart" ] ||
                               [ "${action}" = "reload" ] ||
                               [ "${action}" = "report" ] ||
                               [ "${action}" = "suspend" ] ||
                               [ "${action}" = "resume" ] ||
                               [ "${action}" = "query" ] || {
                                   [ "${action}" = "list" ] &&
                                   [ -n "${1}" ];
                               };
                             } && exit 1

Although, quite honestly, I find even that logic a bit awkward. Not sure why the state of the ${adb_pidfile} is even being included in that test. In any case the above change/fix does seem to fix the overall problem that /etc/init.d/adblock restart didn't do anything useful.

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 a pull request may close this issue.

1 participant