#454595 spamassassin: create preferences for virtual users doesn't work by default

Package:
spamassassin
Source:
spamassassin
Submitter:
Jon Daley
Date:
2026-06-14 19:29:02 UTC
Severity:
normal
Tags:
#454595#5
Date:
2007-12-06 13:50:14 UTC
From:
To:
I run spamc/spamd in a virtual user setting.  I have the --create-prefs setting
set, and it works for the non-virtual users, but not for my virtual users.

I run a second spamd daemon with these options:
OPTIONS="--port=784 --create-prefs --max-children 12 --nouser-config --helper-home-dir
  --virtual-config-dir=/home/vmail/mail/%d/%l/.spamassassin --username=vmail"

I had to add this line to get the default preferences created.

~>diff /usr/sbin/spamd /usr/local/sbin/spamd-virtual
2122c2122
<     info("spamd: using default config for $username: $prefsfile");
---
2124a2125,2128

#454595#10
Date:
2008-03-04 06:23:39 UTC
From:
To:
tags 454595 +unreproducible
thanks

I haven't been able to duplicate this bug.  The user prefs dir is
created as expected.  Note that the actual user dir needs to be created
by hand; this is not created by SA.  So, e.g. if the virtual-config-dir
option is set to /vhome/users/%d/%l/spamassassin, %d and %l must
reference existing directories.  Only the spamassassin subdir will be
automatically created.

noah

#454595#17
Date:
2011-03-28 01:01:22 UTC
From:
To:
tags 454595 + confirmed - unreproducible
thanks

Hello,

I'm using version 3.3.1-1 and the bug still appends (some times ago, it
worked on etch for sure and maybe lenny):
I currently have the following config:
A dedicated user for spamassassin and a dedicated directory:
mkdir -p /var/lib/spamassassin/users
useradd spamassassin
usermod -d /var/lib/spamassassin spamassassin
chown -R spamassassin. /var/lib/spamassassin

In /etc/default/spamassassin:
ENABLED=1
OPTIONS="--create-prefs -x --max-children 5
--helper-home-dir=/var/lib/spamassassin 
--virtual-config-dir=/var/lib/spamassassin/users/%u -u spamassassin"

If I quote the man page of spamd:
--virtual-config-dir: [...] This path must be a writable directory.  It 
will be created if it does not already exist.

The directory should be created but unfortunately, it's not :/.
Everything works if I create by hand the directory but it's not quite
simple when using virtual users ...

As you suggest, I also tried with
virtual-config-dir=/var/lib/spamassassin/users/%u/spamassassin and
created /var/lib/spamassassin/users/test (with spamassassin as owner)
but spamd doesn't create the folder work neither.

For my test, I used (on the spamd host) the following protocol:
spamc -d 127.0.0.1 -u test <<EOF
From: test
To: test
Subject: test

test
EOF

The mail.log tells me:
# First case
spamd[24346]: spamd: using default config for test:
/var/lib/spamassassin/users/test/user_prefs
# Second case
spamd[2494]: spamd: using default config for test:
/var/lib/spamassassin/users/test/spamassassin/user_prefs

This also make per-users bayes DB unusable (the bayes plugin scream that
it can't create the lock (in the nonexistent folder))

Feel free to contact me if you need further informations.

Regards,
Damien

#454595#22
Date:
2019-09-01 19:48:29 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?
Testing a new install of SpamAssassing
   * What exactly did you do (or not do) that was effective (or
     ineffective)?
Submtted mail to a user without a config folder

   * What was the outcome of this action?
No new folder, and an error in the log:

 spamd[18039]: config: mkdir /home/vmail/mail/osric/sa failed: Insecure
 dependency in mkdir while running with -T switch at
 /usr/share/perl/5.28/File/Path.pm line 198, <GEN8> line 2

My perl-fu is not strong, but I tried basic untainting, replacing

  mkpath($fname, 0, 0700);

with

  my $clean = $fname ~= /^(*.)$/;
  mkpath($clean, 0, 0700);

(around line 1925 in /usr/share/perl5/Mail/SpamAssassin.pm)

but there was no change (no new folder)

   * What outcome did you expect instead?
The folder specified in --virtual-config-dir to be created per
the manpage for spamd.

#454595#31
Date:
2025-01-06 22:27:48 UTC
From:
To:
I've confirmed that this is still present in 4.0.1.  I've pinged
upstream via https://bz.apache.org/SpamAssassin/show_bug.cgi?id=5663 and
we'll see if they have anything to say...

noah

#454595#38
Date:
2026-06-14 09:37:20 UTC
From:
To:
The code has changed since the original report, the same bug still exists.

New patch:

/usr/local/sbin#diff spamd /usr/sbin/spamd                                                                                          5:15am
2794,2798c2794,2795
<     if ( ! -f $prefsfile ) {
< 	info("spamd: using default config for $username: $prefsfile");
< 	handle_user_set_user_prefs(File::Basename::dirname($userdir), $username);
---

(line numbers are slightly off due to some removed comments and the
combined patch with #1139978)


The behavior from the original bug report remains the same, and this
patch replaces the original patch.

#454595#51
Date:
2026-06-14 19:01:38 UTC
From:
To:
This was closed upstream with 4.0.2

close 454595 4.0.2-1
thanks