modem: fix missing call log entries and rejected calls still ringing

On a freshly flashed image the root-run dual-SIM daemon created
~/.local/share/sxmo/modem as root. sxmo_modemcall.sh runs under set -e,
so its failed modemlog.tsv write aborted hangup() before the call was
ended on the network (the caller kept ringing), and no call was ever
logged for xcalllog.

- dsds-daemon: create the log and call state directories owned by user,
  append to modemlog.tsv through a helper that keeps it user-owned, and
  repair root-owned leftovers on start; never create /run/user/10000.
- sxmo_modemcall.sh: make log_event non-fatal and hang up on the network
  before logging and running the hangup/discard hooks.
- sxmo_modemmonitor.sh: only fall back to an unprivileged dsds-daemon
  when doas is unavailable, not whenever the root instance exits.
- apply-bananarchy-overlay.sh: pre-create the modem and block log
  directories in the image.
This commit is contained in:
Luxferre committed 2026-10-28 20:07:42 +02:00
1 parent 99e2280590
commit a4dbf71af9
5 files changed
+119 -33

No files matched your search

+33 -15
View File
@@ -34,8 +34,14 @@ log_event() {
NUM="$(vid_to_number "$EVT_VID" 2>/dev/null || true)"
TIME="$(date +%FT%H:%M:%S%z)"
mkdir -p "$SXMO_LOGDIR"
printf %b "$TIME\t$EVT_HANDLE\t$NUM\n" >> "$SXMO_LOGDIR/modemlog.tsv"
# Logging must never abort call control under `set -e` (for example when
# the log directory is not writable): a failed write would otherwise skip
# the actual accept/hangup that follows.
{
mkdir -p "$SXMO_LOGDIR" &&
printf %b "$TIME\t$EVT_HANDLE\t$NUM\n" >> "$SXMO_LOGDIR/modemlog.tsv"
} 2>/dev/null || sxmo_log "Could not write $EVT_HANDLE to $SXMO_LOGDIR/modemlog.tsv"
return 0
}
pickup() {
@@ -134,33 +140,45 @@ hangup() {
;;
esac
# Mark the call as hung up / discarded first (sxmo_modem.sh reads these
# markers when ModemManager reports the call as terminated), then end the
# call on the network right away, and only afterwards log and run hooks so
# a failing log write or hook can never leave the caller ringing.
WAS_PICKED_UP=0
if [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.pickedupcall" ] || \
[ -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.initiatedcall" ]; then
WAS_PICKED_UP=1
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.pickedupcall" \
"$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.initiatedcall"
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.hangedupcall"
log_event "call_hangup" "$CALLID"
sxmo_log "sxmo_modemcall: Invoking hangup hook"
sxmo_hook_hangup.sh
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.hangedupcall" || true
else
# this call was never picked up and hung up immediately, so it is a discarded call
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.discardedcall"
log_event "call_discard" "$CALLID"
sxmo_log "sxmo_modemcall: Invoking discard hook"
sxmo_hook_discard.sh
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.discardedcall" || true
fi
HANGUP_FAILED=0
if ! mmcli -m any -o "$CALLID" --hangup 2>/dev/null && \
! doas -n /usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1; then
# we ignore already closed calls
if list_active_calls | grep -q "/$CALLID "; then
sxmo_notify_user.sh --urgency=critical "We failed to hangup the call"
return 1
HANGUP_FAILED=1
fi
fi
if [ "$WAS_PICKED_UP" = "1" ]; then
log_event "call_hangup" "$CALLID"
sxmo_log "sxmo_modemcall: Invoking hangup hook"
sxmo_hook_hangup.sh || true
else
log_event "call_discard" "$CALLID"
sxmo_log "sxmo_modemcall: Invoking discard hook"
sxmo_hook_discard.sh || true
fi
if [ "$HANGUP_FAILED" = "1" ]; then
sxmo_notify_user.sh --urgency=critical "We failed to hangup the call"
return 1
fi
}
# We shallow muted/blocked and terminated calls