The format of /var/qmail/users/assign is fairly simple. It's a sequence of lines with two slightly different formats, one for an exact match and one for wildcards. An exact match line starts with an equals sign: =local:user:uid:gid:homedir:dash:ext: This means that mail to address local is delivered to user with user and group IDs uid and gid and home directory homedir, using a qmail file named .qmail dashext. (Usually dash and ext are null.) A wildcard line starts with a plus sign: +loc:user:uid:gid:homedir:dash:pre: In this case, any address that starts with loc is handled by the given user, with pre inserted in front of the rest of the address to determine the name of the qmail file. (In this case dash is usually a dash, and pre is usually null.) Here's a snippet from a real assign file: +:alias:121:105:/var/qmail/alias:-:: =carol:carol:108:102:/usr/home/carol::: +carol-:carol:108:102:/usr/home/carol:-:: In this case, mail to carol is handled by the second line, and delivered using /usr/home/carol/.qmail, while mail to carol-ina is handled by the third line and delivered using /usr/home/carol/.qmail-ina. Any address not starting with carol is handled by the first catchall line so that mail to, say, fred is delivered using /var/qmail/alias/.qmail-fred. Note the hyphen in the third line in carol-, so that line matches any of carol's subaddresses, but not plain carol. Usually the list of users in assign is more or less the same as the list in /etc/passwd, so qmail provides the qmail-pw2u utility to create your assign file. I use this Makefile to control the process: cdb: assign ../bin/qmail-newu assign: /etc/passwd append exclude cp assign assign.old ../bin/qmail-pw2u < /etc/passwd > assign When creating assign, qmail-pw2u uses approximately the same rules as qmail-getpw, ignoring any users that have a zero uid, don't own their home directory, or contain capital letters. For each user, the output contains two lines, with the username, user and group IDs, and home directory from the password file, as in the "carol" example. Several command-line flags to qmail-pw2u modify the default behavior and are documented in the manpage, but I've never found the flags very useful. The only ones I've ever used are -h, fail if a user's home directory doesn't exist, and -c, change the separator character from a hyphen to something else, usually a plus sign for compatibility with the subaddressing in sendmail and postfix. What is useful is a set of auxiliary files in /var/qmail/users that modify the generated assign file:
Assuming you use the Makefile shown previously, you just need to run make in /var/qmail/users every time to add or delete a user to or from the password file. Qmail rechecks cdb for every local delivery so there's no need to restart qmail. |