fix: classify unauthorized tmux connections; stop misreporting membership

tmux answers non-allowlisted users with 'access not allowed' on stderr
and exit 0 for every command (verified 3.3a/3.5a, two users), so
has-session reports any target as existing. party status claimed
uninvited group members were joined, party leave silently 'succeeded',
and party list printed bogus '0 attendee(s)' rows. New party_conn_state
(ok/unauthorized/dead) classifies by message content; list now shows
'invite-only (ask <host>)'.
This commit is contained in:
veg 2026-07-04 09:55:47 +00:00
parent 6cac86bb15
commit f3209e39d1
3 changed files with 157 additions and 14 deletions

View file

@ -136,3 +136,22 @@ setup() {
[ "$status" -ne 0 ]
[[ "$output" == *"pass a name"* ]]
}
@test "party_conn_state classifies ok / unauthorized / dead" {
stub="$PARTY_TMP/conn-stub"
cat > "$stub" <<'S'
#!/bin/sh
case "${MODE:-}" in
ok) exit 0 ;;
deny) echo "access not allowed" >&2; exit 0 ;;
*) echo "error connecting to /x (No such file or directory)" >&2; exit 1 ;;
esac
S
chmod +x "$stub"
export PARTY_TMUX="$stub"
export MODE=ok; [ "$(party_conn_state /x)" = "ok" ]
# The trap this function exists for: tmux answers unauthorized users
# with EXIT 0 + a stderr message, so rc alone says "authorized".
export MODE=deny; [ "$(party_conn_state /x)" = "unauthorized" ]
export MODE=dead; [ "$(party_conn_state /x)" = "dead" ]
}