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

Handling of double-quotes in command-line arguments of log_proxy_wrapper #37

Closed
mk-fg opened this issue Feb 5, 2024 · 0 comments · Fixed by #38
Closed

Handling of double-quotes in command-line arguments of log_proxy_wrapper #37

mk-fg opened this issue Feb 5, 2024 · 0 comments · Fixed by #38

Comments

@mk-fg
Copy link
Contributor

mk-fg commented Feb 5, 2024

Currently log_proxy_wrapper creates log_proxy subprocess like this:

gchar *cli = g_strdup_printf("log_proxy -s %li -t %li -S \"%s\" -n %i %s -r -f \"%s\" \"%s\"", rotation_size, rotation_time, rotation_suffix, rotated_files, use_locks_str, fifo_path, log_path);
gboolean spawn_res = g_spawn_command_line_async(cli, NULL);

Which I think should not work if any of the string values templated there have double-quote characters in them.

For example:

log_proxy_wrapper -S '.%Y%m%d_%H%M%S"' -O /tmp/test.log -- cat <<< test

I'd expect this to work for any valid strftime template, which can include double quotes, but it does not with current release version, with the following error:

(log_proxy_wrapper:121851): log_proxy-CRITICAL **: 03:08:45.541: can't spawn log_proxy -s 104857600 -t 86400 -S ".%Y%m%d_%H%M%S"" -T "(null)" -n 5  -r -f "/tmp/log_proxy_stdout_4c2e654e021d1c1d8acbfadbb111e995.fifo" "/tmp/test.log" => exit

Fix can probably be using a different g_spawn_* call, which passes through individual arguments to underlying exec syscall, instead of parsing them from a shell-like quoted string, which will always be unreliable and depending on that parsing logic.

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