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

Fix matching of Proc::check_args if cmdline contains non-exe path #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JanLuca
Copy link

@JanLuca JanLuca commented May 25, 2021

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).

Fixes #127.

Signed-off-by: Jan Luca Naumann [email protected]

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]>
@raisjn
Copy link
Member

raisjn commented May 27, 2021

thank you for the patch, I will review it this coming weekend

Comment on lines +116 to +118
auto search_interpreter = known_interpreters.find(base_str)
if search_interpreter != known_interpreters.end():
continue
Copy link
Member

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?)

Copy link
Author

@JanLuca JanLuca Jun 6, 2021

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.

Copy link
Member

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

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 this pull request may close these issues.

[remux] xochitl is not started for new rm2fb version in toltec
2 participants