#1043362 mw-mailsync: guard to check for logged in user is flawed

#1043362#5
Date:
2023-08-09 14:22:58 UTC
From:
To:
The following guard is used towards the top of mw-mailsync:

   pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;}

This is inadequate, because USER and LOGNAME might not be defined in the
running environment even if the user is logged in. For example, in a
container context:

   conf=/some/path/to/stick/muttwizard/conf/in
   podman run --rm -ti \
       --mount type=bind,ro=false,chown=true,src=$conf,dst=$HOME \
       mutt-wizard \
       neomutt

(where 'mutt-wizard' is the name of a debian:bookworm container
with mutt-wizard and its dependencies installed.)

Furthermore, the behaviour when this fails - ${USER:=$LOGNAME}
expands to the empty string, so the script invokes
"pgrep -u >/dev/null", which is at least benign and just dumps
the pgrep invocation output on the user's terminal.

(Why run mutt-wizard in a container? To mitigate against it not
isolating its own configuration from any pre-existing configuration
belonging to the user. See:
<https://github.com/LukeSmithxyz/mutt-wizard/issues/917>)