fluent-ctl sends the signal to its own process group when the PID is 0 or has a newline
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
Hướng nghiên cứu
Bắt đầu với phần xác thực PID trong lib/fluent/command/ctl.rb quanh dòng 95 và 176, sau đó đọc test_invalid_pid trong test/command/test_ctl.rb. Kiểm tra rằng PID 0 và một đối số nhiều dòng như "abc\n123" bị từ chối mà không gửi tín hiệu, trong khi các PID dương hợp lệ vẫn hoạt động. Issue cho biết bài kiểm thử hiện có có thể bao quát cả hai trường hợp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Ruby
- Star
- 13.6k
- Fork
- 1.4k
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 79
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fluent/fluentd
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
A <secondary> output cannot roll back a chunk: rollback_write always raises ArgumentErrorCó thể đã có người làm @lbarrosby đã nhận 18 ngày trước. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
parser_syslog: message_format auto parses RFC 3164 messages with an RFC 3339 timestamp as RFC 5424Có thể đã có người làm @rafayqayyum đã nhận 17 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
fluent/fluentd#5631 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
parser_syslog: the regexp engine for RFC 5424 can match the header later in the message and corrupt the recordCó thể đã có người làm @rafayqayyum đã nhận 17 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
fluent/fluentd#5630 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
in_tail with the multiline parser stops reading a file at a non-ASCII line when format_firstline is a UTF-8 regexpCó thể đã có người làm @RjyavardhanSingh đã nhận hôm nay. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
fluent/fluentd#5714 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của fluent/fluentd
Issue tương tự
-
🐛 bug 👩💻 équipe CE
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
betagouv/conseillers-entreprises#4835 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Action: a `test` glob with a gem older than 1.9.0 fails with `no such file` and no version hintĐang mởbacklog enhancement github_actions priority: low risk: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
davidteren/mutineer#646 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
metanorma/isodoc#965 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
verified
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
zammad/zammad#6636 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày