fix: lowercase the host name in the loopback check; point the orphan cleanup comments to JobExtension.cs:891-939; drop a stale comment in proc.go
- commit
- b60a661f688b0f4d81937e9452175ff8305e3da8
- author
- brice · · 2026-10-12 20:14 UTC
- parent
- 799f55c
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +6 -4
M internal/executor/proc.go +3 -3
| @@ -237,7 +237,7 @@ func runProcess(spec procSpec) (procResult, error) { | |||
| 237 | 237 | // is named "KillProcessTree" but does not kill the tree). What the shell | |
| 238 | 238 | // started is left to the shell: bash forwards nothing to a foreground | |
| 239 | 239 | // child it waits for, and the children that outlive the step are | |
| 240 | - | // killed by "Complete job" (the orphan cleanup, JobExtension.cs:132). | |
| 240 | + | // killed by "Complete job" (the orphan cleanup, JobExtension.cs:891-939). | |
| 241 | 241 | // The step is still started in its own process group, so that a signal | |
| 242 | 242 | // sent to the executor's group (init forwarding a SIGTERM) does not reach | |
| 243 | 243 | // it before the executor decides. | |
| @@ -280,7 +280,7 @@ func runProcess(spec procSpec) (procResult, error) { | |||
| 280 | 280 | return func() { | |
| 281 | 281 | mu.Lock() | |
| 282 | 282 | defer mu.Unlock() | |
| 283 | - | if !done { // the group id could be reused once the shell is reaped | |
| 283 | + | if !done { | |
| 284 | 284 | spec.Signal(pid, sig) | |
| 285 | 285 | } | |
| 286 | 286 | } | |
| @@ -394,7 +394,7 @@ func processTrackingValue(pid int) string { | |||
| 394 | 394 | } | |
| 395 | 395 | ||
| 396 | 396 | // killOrphans kills the processes that carry the tracking id and were not | |
| 397 | - | // there before the job (JobExtension.FinalizeJob, JobExtension.cs:132-180). | |
| 397 | + | // there before the job (JobExtension.FinalizeJob, JobExtension.cs:891-939). | |
| 398 | 398 | // logf receives the "Terminate orphan process" lines. | |
| 399 | 399 | func killOrphans(id string, before map[string]bool, logf func(string)) { | |
| 400 | 400 | self := os.Getpid() | |
| @@ -237,7 +237,7 @@ func runProcess(spec procSpec) (procResult, error) { | |||||
| 237 | // is named "KillProcessTree" but does not kill the tree). What the shell | 237 | // is named "KillProcessTree" but does not kill the tree). What the shell | ||
| 238 | // started is left to the shell: bash forwards nothing to a foreground | 238 | // started is left to the shell: bash forwards nothing to a foreground | ||
| 239 | // child it waits for, and the children that outlive the step are | 239 | // child it waits for, and the children that outlive the step are | ||
| 240 | - | // killed by "Complete job" (the orphan cleanup, JobExtension.cs:132). | 240 | + | // killed by "Complete job" (the orphan cleanup, JobExtension.cs:891-939). |
| 241 | // The step is still started in its own process group, so that a signal | 241 | // The step is still started in its own process group, so that a signal | ||
| 242 | // sent to the executor's group (init forwarding a SIGTERM) does not reach | 242 | // sent to the executor's group (init forwarding a SIGTERM) does not reach | ||
| 243 | // it before the executor decides. | 243 | // it before the executor decides. | ||
| @@ -280,7 +280,7 @@ func runProcess(spec procSpec) (procResult, error) { | |||||
| 280 | return func() { | 280 | return func() { | ||
| 281 | mu.Lock() | 281 | mu.Lock() | ||
| 282 | defer mu.Unlock() | 282 | defer mu.Unlock() | ||
| 283 | - | if !done { // the group id could be reused once the shell is reaped | 283 | + | if !done { |
| 284 | spec.Signal(pid, sig) | 284 | spec.Signal(pid, sig) | ||
| 285 | } | 285 | } | ||
| 286 | } | 286 | } | ||
| @@ -394,7 +394,7 @@ func processTrackingValue(pid int) string { | |||||
| 394 | } | 394 | } | ||
| 395 | 395 | ||||
| 396 | // killOrphans kills the processes that carry the tracking id and were not | 396 | // killOrphans kills the processes that carry the tracking id and were not | ||
| 397 | - | // there before the job (JobExtension.FinalizeJob, JobExtension.cs:132-180). | 397 | + | // there before the job (JobExtension.FinalizeJob, JobExtension.cs:891-939). |
| 398 | // logf receives the "Terminate orphan process" lines. | 398 | // logf receives the "Terminate orphan process" lines. | ||
| 399 | func killOrphans(id string, before map[string]bool, logf func(string)) { | 399 | func killOrphans(id string, before map[string]bool, logf func(string)) { | ||
| 400 | self := os.Getpid() | 400 | self := os.Getpid() | ||
M internal/host/rpc.go +2 -1
| @@ -58,7 +58,8 @@ func CheckURL(raw string, allowInsecure bool) error { | |||
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | 60 | func isLoopback(host string) bool { | |
| 61 | - | if host == "localhost" { | |
| 61 | + | // Host names are not case sensitive (LOCALHOST, Localhost). | |
| 62 | + | if strings.EqualFold(host, "localhost") { | |
| 62 | 63 | return true | |
| 63 | 64 | } | |
| 64 | 65 | ip, err := netip.ParseAddr(host) | |
| @@ -58,7 +58,8 @@ func CheckURL(raw string, allowInsecure bool) error { | |||||
| 58 | } | 58 | } | ||
| 59 | 59 | ||||
| 60 | func isLoopback(host string) bool { | 60 | func isLoopback(host string) bool { | ||
| 61 | - | if host == "localhost" { | 61 | + | // Host names are not case sensitive (LOCALHOST, Localhost). |
| 62 | + | if strings.EqualFold(host, "localhost") { | |||
| 62 | return true | 63 | return true | ||
| 63 | } | 64 | } | ||
| 64 | ip, err := netip.ParseAddr(host) | 65 | ip, err := netip.ParseAddr(host) | ||
M internal/host/rpc_test.go +1 -0
| @@ -24,6 +24,7 @@ func TestCheckURL(t *testing.T) { | |||
| 24 | 24 | {"https://ermite.example.org", false, ""}, | |
| 25 | 25 | {"https://ermite.example.org:8443/base", false, ""}, | |
| 26 | 26 | {"http://localhost:8080", false, ""}, | |
| 27 | + | {"http://LOCALHOST:8080", false, ""}, | |
| 27 | 28 | {"http://127.0.0.1:8080", false, ""}, | |
| 28 | 29 | {"http://[::1]:8080", false, ""}, | |
| 29 | 30 | {"http://ermite.example.org", false, "must be https"}, | |
| @@ -24,6 +24,7 @@ func TestCheckURL(t *testing.T) { | |||||
| 24 | {"https://ermite.example.org", false, ""}, | 24 | {"https://ermite.example.org", false, ""}, | ||
| 25 | {"https://ermite.example.org:8443/base", false, ""}, | 25 | {"https://ermite.example.org:8443/base", false, ""}, | ||
| 26 | {"http://localhost:8080", false, ""}, | 26 | {"http://localhost:8080", false, ""}, | ||
| 27 | + | {"http://LOCALHOST:8080", false, ""}, | |||
| 27 | {"http://127.0.0.1:8080", false, ""}, | 28 | {"http://127.0.0.1:8080", false, ""}, | ||
| 28 | {"http://[::1]:8080", false, ""}, | 29 | {"http://[::1]:8080", false, ""}, | ||
| 29 | {"http://ermite.example.org", false, "must be https"}, | 30 | {"http://ermite.example.org", false, "must be https"}, | ||