$BOGOFILTER_DIR has no effect, rc example: bogofilter_dir not recognized
Matthias Andree
matthias.andree at gmx.de
Tue Apr 22 16:55:43 CEST 2025
Am 22.04.25 um 10:45 schrieb Christian Ebert:
> * Matthias Andree via bogofilter on Tuesday, April 22, 2025 at 01:12:20
> +0200:
>> Am 22.04.25 um 00:57 schrieb Christian Ebert:
> [...]
>>> grep -F BOGOFILTER_DIR ~/.bashrc
>>> BOGOFILTER_DIR=${XDG_DATA_HOME}/bogofilter/bogofilter
>>> export BOGOFILTER_DIR
>>> $ echo $BOGOFILTER_DIR
>>> /Users/chris/.local/share/bogofilter/bogofilter
>>> $ bogofilter -QQ | grep -F bogofilter-dir
>>> bogofilter-dir = /Users/chris/.local/share/bogofilter/bogofilter
>>> ls ~/.bogofilter
>>> ls: /Users/chris/.bogofilter: No such file or directory
>>> $ mail chris
>>> Subject: test
>>> test
>>> .
>>> EOT
>>> ~$ ls ~/.bogofilter/
>>> wordlist.lmdb wordlist.lmdb-lock
>>
>> Unless MacOS does Stupid Things™, the mail *delivery* runs through a
>> different user account (some system account) and environment, and that
>> system user will not heed your user's (chris's) local settings and
>> also likely not use bash as a shell (if any at all).
>>
>> You need to check what your mail transfer agent is, how exactly it
>> invokes bogofilter and how that (system) user account is configured. I
>> don't know MacOS, so I have no idea how it delivers mail.
>
> $ postconf mailbox_command
> mailbox_command = /usr/local/bin/maildrop -d ${USER}
>
> (postifx shipped by macos, but own LaunchDaemon(s), also clamdscan)
>
> Which is why I naively tried to set the environment in my maildrop
> mailfilter in my equally naive understanding of the first paragraph of
> the SECURITY section in man 1 maildrop.
Yes, but you are not launching bash as an interactive shell, and the
only remaining variable that could cause it to read environment
variables ($BASH_ENV) is not set in the environment that maildrop in
delivery mode (-d USER) creates.
So in essence, and for posterity
if 1. you use xfilter 'bogofilter -e -p -l' in $HOME/.mailfilter, and
if 2. /bin/bash is your user's (chris's) shell,
then maildrop will execute /bin/bash -c 'bogofilter -e -p -l', with
argv[0] == bash, and no BASH_ENV in bash's environment. bash in that
situation reads no start-up file.
So, in your situation with "maildrop -d chris" as the way to invoke
bogofilter, you can
- either set your variables in bogofilter's configuration file,
- or in .mailfilter.
man maildropfilter documents that all maildrop internal variables get
auto-exported to shell commands.
HTH
Matthias
More information about the bogofilter
mailing list