fluent-ctl sends the signal to its own process group when the PID is 0 or has a newline
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
Direzione di ricerca
Inizia dalla convalida del PID in lib/fluent/command/ctl.rb, intorno alle righe 95 e 176, poi leggi test_invalid_pid in test/command/test_ctl.rb. Verifica che PID 0 e un argomento su più righe come "abc\n123" vengano rifiutati senza inviare un segnale, mentre i PID positivi validi continuino a funzionare. L’issue dice che il test esistente può coprire entrambi i casi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Ruby
- Stelle
- 13.6k
- Fork
- 1.4k
- Merge medio
- 1g 10h
- PR unite (30g)
- 79
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di fluent/fluentd
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
A <secondary> output cannot roll back a chunk: rollback_write always raises ArgumentErrorForse già presa @lbarrosby l’ha presa 18 giorni fa. Apertabug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
parser_syslog: message_format auto parses RFC 3164 messages with an RFC 3339 timestamp as RFC 5424Forse già presa @rafayqayyum l’ha presa 17 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
fluent/fluentd#5631 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
parser_syslog: the regexp engine for RFC 5424 can match the header later in the message and corrupt the recordForse già presa @rafayqayyum l’ha presa 17 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
fluent/fluentd#5630 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
in_tail with the multiline parser stops reading a file at a non-ASCII line when format_firstline is a UTF-8 regexpForse già presa @RjyavardhanSingh l’ha presa oggi. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
fluent/fluentd#5714 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di fluent/fluentd
Issue simili
-
🐛 bug 👩💻 équipe CE
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
betagouv/conseillers-entreprises#4835 ·
I maintainer di solito rispondono entro 1 giorno
-
Action: a `test` glob with a gem older than 1.9.0 fails with `no such file` and no version hintApertabacklog enhancement github_actions priority: low risk: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
davidteren/mutineer#646 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
metanorma/isodoc#965 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
verified
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
zammad/zammad#6636 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno