Updated to Dovecot - Problem with home dir

jw00dy

Verified User
Joined
Dec 6, 2004
Messages
368
Location
Utah, USA
My update to dovecot went well. No problem there.

However, I have both a /home and /home2 directories and something in the script isn't allowing dovecot or exim (not sure which) to detect where the users home dir really is.

For example:

User [email protected] is located in /home/smith1/ -- This works fine
user [email protected] is located in /home2/smith2/ -- This one doesn't.

So when exim or dovecot (not sure which one to be honest) tries to create the new MailDir directory for [email protected] it is actually trying to create the directory in the /home path instead of the /home2 path.

Error in Exim log:
2007-04-07 04:20:46 [email protected] <[email protected]> R=virtual_user T=virtual_localdelivery defer (13): Permission denied: cannot create /home/smith2/imap/smith2.com/jsmith/Maildir

Anyone know of a fix for this?
 
DirectAdmin never did support multiple home directories; the fix was a kluge allowing new domains to be created in a new directory.

As long as mail wasn't stored in the home directory, this wasn't a problem.

But I don't see an easy fix to the use of /home/ in the exim.conf file for mail delivery.

Except perhaps to create a /home directory mail path for all domains, with perhaps a symbolic link. to the actual path in /home2.

Anyone else have any ideas?

Jeff
 
Good news. 1) Only one of my domains in /home2 actually uses local mail. 2) the symbolic link from /home/smith2 to /home2/smith2 worked like a charm!

Thanks for the idea Jeff.
 
I'm glad it worked. I beleve you can create a post-domain-creation script to add it in all domains being added to the /home2 directory.

Jeff
 
No worries, as I'm not adding domains to the home2 dir any more and those that are there now work. So we're good.
 
A correct fix for that would be rather "long", but would work. The way to do it would be to query /etc/virtual/domainowners to figure out the owner of the receiving domain, then do a lookup on /etc/passwd to get the 6th column (which I believe exim knows how to do), thus giving you a valid home directory.

So anywhere you see:
Code:
/home/${lookup{$domain}lsearch{/etc/virtual/domainowners}{$value}}
You'd replace it with:
Code:
${extract{5}{:}{${lookup {${lookup{$domain}lsearch{/etc/virtual/domainowners}{$value}}} lsearch {/etc/passwd}}}
Note.. not tested, just written in 3 minutes, but should give the basic concept.

We will likely not include this as a default as 98% of all systems only use /home, and the extra lookup on the /etc/passwd file won't help reduce the load any. It can be added for any system with multiple homes.

John
 
Thanks John. I'm going to just stick with the alias for now as I don't believe it adds much overhead and it's been working well to this point.
 
I had exact same problem and wanted to modify it to work but had little luck. When I finally think I got it, it had domain in my query and all mail actually went there. The problem with the expression is that it doesn't have $domain variable set since it returns empty string.
Code:
 T=local_delivery defer (13): Permission denied: cannot create /Maildir/

So by that I assume domain name doesn't get into expression and thus it returns nothing. I've tested it with manual domain entry:
Code:
# exim -be
> ${extract{5}{:}{${lookup {${lookup{xyzt.net}lsearch*{/etc/virtual/domainowners}{$value}}} lsearch {/etc/passwd}}}}/Maildir/
/home/xyzt/Maildir/
>

works fine as you can see. Can someone help me out how to get it right ? Here are my local and virtual transports:

Code:
local_delivery:
  driver = appendfile
  delivery_date_add
  envelope_to_add
  directory = ${extract{5}{:}{${lookup {${lookup{$domain}lsearch*{/etc/virtual/domainowners}{$value}}} lsearch {/etc/passwd}}}}/Maildir/
  directory_mode = 770
  create_directory = true
  maildir_format
  group = mail
  mode = 0660
  return_path_add
  user = ${local_part}

## for delivering virtual domains to their own mail spool

virtual_localdelivery:
  driver = appendfile
  create_directory
  delivery_date_add
  directory_mode = 770
  envelope_to_add
  directory = ${extract{5}{:}{${lookup {${lookup{$domain}lsearch*{/etc/virtual/domainowners}{$value}}} lsearch {/etc/passwd}}}}/imap/${domain}/${local_part}/Maildir
  maildir_format
  group = mail
  mode = 660
  return_path_add
  user = "${lookup{$domain}lsearch*{/etc/virtual/domainowners}{$value}}"
  quota = ${if exists{/etc/virtual/${domain}/quota}{${lookup{$local_part}lsearch*{/etc/virtual/${domain}/quota}{$value}{0}}}{0}}
 
Last edited:
Shouldnt it be ${extract{6} not ${extract{5} since its the 6th field you want?
 
In an ideal world yes, but as you may know computers calculate from 0 and not from one:D
 
Ok I have a solution for this now (borrowed from cPanel exim.conf :D)

Code:
local_delivery:
  driver = appendfile
  delivery_date_add
  envelope_to_add
  directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/passwd}{$value}}}}/Maildir"
  directory_mode = 770
  create_directory = true
  maildir_format
  group = mail
  mode = 0660
  return_path_add
  user = ${local_part}

## for delivering virtual domains to their own mail spool

virtual_localdelivery:
  driver = appendfile
  create_directory
  delivery_date_add
  directory_mode = 770
  envelope_to_add
  directory = "${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/virtual/domainowners}{$value}}}lsearch{/etc/passwd}{$value}}}}/imap/${domain}/${local_part}/Maildir"
  maildir_format
  group = mail
  mode = 660
  return_path_add
  user = "${lookup{$domain}lsearch*{/etc/virtual/domainowners}{$value}}"
  quota = ${if exists{/etc/virtual/${domain}/quota}{${lookup{$local_part}lsearch*{/etc/virtual/${domain}/quota}{$value}{0}}}{0}}

seems to be working now finally! Hope this saves someone the trouble.
 
Back
Top