fluent-ctl sends the signal to its own process group when the PID is 0 or has a newline
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
lib/fluent/command/ctl.rb の95行目と176行目付近にある PID の検証から始め、次に test/command/test_ctl.rb の test_invalid_pid を読んでください。PID 0 と "abc\n123" のような複数行の引数が、シグナルを送信せずに拒否される一方、有効な正の PID は引き続き機能することを確認してください。Issue によると、既存のテストで両方のケースをカバーできます。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
fluent-ctl accepts 0 as a PID. It also accepts an argument that has a line with only digits, such as "abc\n123". Both become PID 0, and Process.kill(:TERM, 0) sends the signal to every process in the caller's process group. So fluent-ctl shutdown 0 stops the shell script that runs it, and the other processes in the same group, instead of reporting an invalid PID.
The PID check uses ^ and $, which match at line boundaries, and allows 0 (ctl.rb L176):
usage("Invalid PID: #{@pid_or_svcname}") unless /^[0-9]+$/.match?(@pid_or_svcname)
call_signal then converts the argument with to_i (ctl.rb L113), which gives 0 for both "0" and "abc\n123". restart, flush, reload and dump work the same way with other signals. On Windows, the same regular expression decides whether the argument is a PID or a service name (ctl.rb L95).
To Reproduce
Run each command in its own session, so that only a throwaway process group gets the signal:
setsid bash -c 'sleep 5 & fluent-ctl shutdown 0; echo "fluent-ctl rc=$?"; wait'; echo "group rc=$?"
setsid bash -c 'sleep 5 & fluent-ctl shutdown "$1"; echo "fluent-ctl rc=$?"; wait' _ $'abc\n123'; echo "group rc=$?"
# For comparison, a PID that does not exist
setsid bash -c 'sleep 5 & fluent-ctl shutdown 999999; echo "fluent-ctl rc=$?"; wait'; echo "group rc=$?"
Results on master (31157cba) and v1.20.1:
| Argument | Result |
|---|---|
0 |
The whole group gets SIGTERM (exit status 143). Nothing after fluent-ctl runs. |
$'abc\n123' |
Same as 0. |
999999 (for comparison) |
fluent-ctl fails with Errno::ESRCH. The rest of the group keeps running. |
Expected behavior
fluent-ctl rejects these arguments with Error: Invalid PID, as it does for abc, and sends no signal.
Your Environment
- Fluentd version: master (31157cba) and v1.20.1
- Package version: -
- Operating system: Ubuntu 24.04.5 LTS
- Kernel version: 6.8.0-151-generic
- Ruby: 4.0.10
Your Configuration
No configuration is needed. Only fluent-ctl is used.
Your Error Log
No error is logged. The calling shell is terminated:
Terminated
group rc=143
Additional context
A possible fix is to use /\A[1-9][0-9]*\z/ at L176 and L95. With this change, both arguments fail with Error: Invalid PID, the process group keeps running, and test/command/test_ctl.rb passes. test_invalid_pid, added in #5661, can take "0" and "abc\n123" as more data.
- 主要言語
- Ruby
- スター
- 13.6k
- フォーク
- 1.4k
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 79
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fluent/fluentd のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
A <secondary> output cannot roll back a chunk: rollback_write always raises ArgumentError対応中かも @lbarrosby が 18 日前に担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
parser_syslog: message_format auto parses RFC 3164 messages with an RFC 3339 timestamp as RFC 5424対応中かも @rafayqayyum が 17 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
fluent/fluentd#5631 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
parser_syslog: the regexp engine for RFC 5424 can match the header later in the message and corrupt the record対応中かも @rafayqayyum が 17 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
fluent/fluentd#5630 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
in_tail with the multiline parser stops reading a file at a non-ASCII line when format_firstline is a UTF-8 regexp対応中かも @RjyavardhanSingh が今日担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
fluent/fluentd#5714 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
🐛 bug 👩💻 équipe CE
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
betagouv/conseillers-entreprises#4835 ·
メンテナーはふだん 1 日以内に返信
-
Action: a `test` glob with a gem older than 1.9.0 fails with `no such file` and no version hintオープンbacklog enhancement github_actions priority: low risk: low
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
davidteren/mutineer#646 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
metanorma/isodoc#965 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
verified
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
zammad/zammad#6636 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信