Bug 69969

Summary: vpopmail default setup doesn't allow use of maildrop filters in virtual domains.
Product: Ports & Packages Reporter: claudiu
Component: Individual Port(s)Assignee: Peter Pentchev <roam>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description claudiu 2004-08-04 01:30:27 UTC
I have FreeBSD box running qmail-1.03, vpopmail-5.4.3, qmailadmin-1.0.20, sqwebmail-4.0.6, maildrop-1.6.3

I want users from virtual domains to be able to use maildrop filtering (configured by each of them from sqwebmail and enabled/disabled by me from qmailadmin.

short version of problem:
maildrop fails delivering a message for a virtual domain user when using mail filters (with to or cc rules) because it wants to run qmail-inject using $SHELL: execle(shell, q, "-c", cmd, (const char *)0, env);
$SHELL seen by maildrop in this case is the shell of the vpopmail user

long version:
the file: /usr/local/share/sqwebmail/maildirfilterconfig contains:
MAILDIRFILTER=../.mailfilter
MAILDIR=./Maildir
this allows one to edit mail filtering rules, located in (e.g.) /usr/local/vpopmail/domains/domain.com/postmaster/.mailfilter

but, vdelivermail from /usr/local/vpopmail/domains/domain.com/.qmail-default ignores the .mailfilter
this is why I activated SPAM_DETECTION in qmailadmin, with the SPAM_COMMAND="| preline /usr/local/bin/maildrop .mailfilter"

so far so good. I add a virtual account test@domain.com from qmailadmin, with spam detection enabled. I login from sqwebmail go to "Edit Mail Filters" and I click on save all changes. this creates the file .mailfilter

when I send a test message to the account I get the following error in qmail logs:
delivery xxx: failure: Unable_to_execute_/nonexistent/

Fix: 

quick fix: pw user mod vpopmail -s /bin/sh

fix #1: empower vpopmail user /bin/sh instead of /nonexistent
root@jerry:/usr/ports/mail/vpopmail# diff pkg-install.orig pkg-install
64c64
<               $result = system ("/usr/sbin/pw useradd $user -g $users{$user} -d \"$ENV{PKG_PREFIX}\" -s /nonexistent $x");
---
>               $result = system ("/usr/sbin/pw useradd $user -g $users{$user} -d \"$ENV{PKG_PREFIX}\" -s /bin/sh $x");

fix #2: modify vdelivermail from vpopmail in order to set env variable SHELL to /bin/sh - in case the program (maildrop) needs to run another program (qmail-inject, in case of to or cc rules), using $SHELL env variable

I know fix #2 is not FreeBSD related; I will send this informations to vpopmail mailing-list also.
but, I guess this is what ports is all about: tweaking software in order to run on FreeBSD without problems.
Comment 1 Volker Stolz freebsd_committer freebsd_triage 2004-08-05 14:02:28 UTC
Responsible Changed
From-To: freebsd-ports-bugs->oliver

Over to maintainer
Comment 2 Oliver Lehmann freebsd_committer freebsd_triage 2004-08-08 10:01:08 UTC
Responsible Changed
From-To: oliver->roam

Assign to the maintainer
Comment 3 Peter Pentchev freebsd_committer freebsd_triage 2005-07-01 17:57:13 UTC
State Changed
From-To: open->closed

The FreeBSD port of vpopmail now has vdelivermail set SHELL to /bin/sh. 
Thanks for the problem report!