refactor: fold is_party_alive into party_conn_state
One liveness primitive instead of two. The PID argument was a vestige (format-checked, never probed, since the kill -0 removal); dropping it means a roster with a garbage SERVER_PID can no longer mask a live socket in host/moderation/role resolution.
This commit is contained in:
parent
be3fb049d2
commit
6b94255245
5 changed files with 51 additions and 88 deletions
|
|
@ -82,32 +82,22 @@ setup() {
|
|||
# liveness
|
||||
# ========
|
||||
#
|
||||
# is_party_alive must not probe the PID with kill -0. POSIX kill(2) is
|
||||
# party_conn_state must not probe PIDs with kill -0. POSIX kill(2) is
|
||||
# allowed to return EPERM when the caller can't signal the target, and
|
||||
# illumos/BSD/macOS honor that — so kill -0 against another user's PID
|
||||
# illumos/BSD/macOS honor that, so kill -0 against another user's PID
|
||||
# returns nonzero even when the process exists. Linux and Linux-ABI
|
||||
# zones (LX-branded) are the outliers that return 0; that's why the
|
||||
# bug hid in the test matrix until a native illumos run surfaced it.
|
||||
# Discovery now relies on `tmux -S list-clients` alone, which is
|
||||
# strictly stronger (filters PID-reuse, dead servers, AF_UNIX impostors).
|
||||
# Liveness rides on `tmux -S list-clients` alone, which is strictly
|
||||
# stronger (filters PID-reuse, dead servers, AF_UNIX impostors).
|
||||
|
||||
@test "is_party_alive does not reach for kill -0 (cross-user discovery)" {
|
||||
body=$(declare -f is_party_alive)
|
||||
@test "party_conn_state does not reach for kill -0 (cross-user discovery)" {
|
||||
body=$(declare -f party_conn_state)
|
||||
[[ "$body" != *"kill "* ]] || { echo "$body"; false; }
|
||||
}
|
||||
|
||||
@test "is_party_alive rejects non-numeric PID without invoking tmux" {
|
||||
! PARTY_TMUX=/nonexistent/should-not-be-called \
|
||||
is_party_alive "" /tmp/should-not-matter
|
||||
! PARTY_TMUX=/nonexistent/should-not-be-called \
|
||||
is_party_alive "abc" /tmp/should-not-matter
|
||||
}
|
||||
|
||||
@test "is_party_alive returns nonzero when tmux server is absent" {
|
||||
# Numeric PID, but no live tmux server at the socket path: tmux call
|
||||
# fails the handshake and the function returns nonzero. Uses PID 1
|
||||
# to also confirm a foreign-uid PID is not preventing the result.
|
||||
! is_party_alive 1 "$PARTY_TMP/no-such-sock"
|
||||
@test "party_conn_state answers dead when no tmux server is at the socket" {
|
||||
[ "$(party_conn_state "$PARTY_TMP/no-such-sock")" = dead ]
|
||||
}
|
||||
|
||||
@test "validate_socket_dir_parent refuses whitespace in PARTY_SOCKET_DIR" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue