Fix matching of Proc::check_args if cmdline contains non-exe path#128
Fix matching of Proc::check_args if cmdline contains non-exe path#128JanLuca wants to merge 1 commit intormkit-dev:masterfrom
Conversation
In the current version Proc::check_args matches all arguments of the cmdline to the needle to check if a program is already running. This check returns wrong result if for example the path `/home/root/.local/share/remarkable/xochitl` is somewhere in the cmdline arguments. The new version just matches the first argument of the cmdline and only checks for further args if the first program is a known interpreter (sh, bash, python). Signed-off-by: Jan Luca Naumann <j.naumann@fu-berlin.de>
|
thank you for the patch, I will review it this coming weekend |
| auto search_interpreter = known_interpreters.find(base_str) | ||
| if search_interpreter != known_interpreters.end(): | ||
| continue |
There was a problem hiding this comment.
the logic here is a bit unclear to me. what happens if: "python -n foo.py" is a cmdline and args is { "foo.py" }?
i think this is supposed to only check the rest of cmd_tokens if the first token is the interpreter, right? (but it should check all of the cmdline, not just the second token?)
There was a problem hiding this comment.
Yeah, my main idea was that we just to check the first argument of the cmdline to get the name of the running program. But then I thought about cases like shell or python scripts where the check if bash or python is running is not really meaningful. Therefore the approach was to skip the first token for this kind of interpreter and check until the first token without an leading -. I know this is still buggy in corner cases when the cmdline is something like python -X <some path> <command> but I had no quick idea how to catch these cases in general.
There was a problem hiding this comment.
sorry for the delay, i will revisit this PR this week (and next) and try to fix things (and write some tests:D). for args with '-X' foo, i would just skip over any args that start with '-' until we get to the first one
31de971 to
8d6004d
Compare
In the current version Proc::check_args matches all arguments of the cmdline to
the needle to check if a program is already running. This check returns wrong
result if for example the path
/home/root/.local/share/remarkable/xochitlissomewhere in the cmdline arguments.
The new version just matches the first argument of the cmdline and only checks
for further args if the first program is a known interpreter (sh, bash, python).
Fixes #127.
Signed-off-by: Jan Luca Naumann j.naumann@fu-berlin.de