-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fix matching of Proc::check_args if cmdline contains non-exe path #128
base: master
Are you sure you want to change the base?
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 <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/xochitl
issomewhere 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 [email protected]