From 9980d2918a2c7c4f04ed5891b21ade2db65ea093 Mon Sep 17 00:00:00 2001 From: veg Date: Mon, 21 Sep 2026 09:35:39 +0000 Subject: [PATCH] refactor: reuse user_in_group helper for membership checks cmd_join, cmd_invite, and cmd_list each inlined the id -nG | tr | grep pipeline instead of calling the existing user_in_group helper. cmd_list also re-forked id once per party in its loop; now the caller's groups are captured once before the loop. Also fold user_in_party_group (one caller) into require_caller_in_group and drop the wrapper. --- party | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/party b/party index 069c73e..3fbe308 100755 --- a/party +++ b/party @@ -141,11 +141,6 @@ user_in_group() { id -nG "$1" 2>/dev/null | tr ' ' '\n' | grep -qx "$2" } -# Boolean: is the named user in TMUX_PARTY_GROUP? -user_in_party_group() { - user_in_group "$1" "$TMUX_PARTY_GROUP" -} - # Print the first PARTY_GROUP_CANDIDATES entry the caller belongs to; # print nothing and return 1 when the caller is in none of them. pick_host_group() { @@ -164,7 +159,7 @@ pick_host_group() { # are stopped by the FS perimeter itself (EACCES at the per-party dir) # and get the friendlier group-gate message in cmd_join. require_caller_in_group() { - if ! user_in_party_group "$USER"; then + if ! user_in_group "$USER" "$TMUX_PARTY_GROUP"; then cat >&2 </dev/null | tr ' ' '\n' | grep -qx "$party_group"; then + if ! user_in_group "$USER" "$party_group"; then cat >&2 </dev/null | tr ' ' '\n' | grep -qx "$invite_group"; then + if ! user_in_group "$user" "$invite_group"; then cat >&2 </dev/null | tr ' ' '\n') for rec in $(roster_list); do roster_read "$rec" || continue state=$(party_conn_state "$RR_SOCKET") @@ -1544,7 +1542,7 @@ cmd_list() { # whose group the caller isn't in. Confidentiality still rides on # the FS perimeter alone. list_group="${RR_GROUP:-$TMUX_PARTY_GROUP}" - id -nG "$USER" 2>/dev/null | tr ' ' '\n' | grep -qx "$list_group" || continue + printf '%s\n' "$_ls_groups" | grep -qx "$list_group" || continue # The group tag only earns its column when the visible parties # disagree on it. Which group gates a party is decided per host # (auto-selection), so there is no default to compare against: