15

I'm configuring Postfix to use external smtp. For this, I used this tutorial

After following it, I found in the logs that /etc/postfix/sasl_passwd.db couldn't be read. The file didn't exist. I used postmap hash:/etc/postfix/sasl_passwd (http://postfix.state-of-mind.de/patrick.koetter/smtpauth/smtp_auth_mailservers.html) as root, but I get:

postmap: fatal: open database /etc/postfix/sasl_passwd.db: Permission denied

Why do I get this?

OS: Fedora 14
User "postfix" exists.

Update:

sudo ls -l /etc/postfix/sasl_passwd.db ls:

cannot access /etc/postfix/sasl_passwd.db: No such file or directory

touch /etc/postfix/sasl_passwd.db
chmod 640 /etc/postfix/sasl_passwd.db
chown postfix:root /etc/postfix/sasl_passwd.db

sudo ls -l /etc/postfix/sasl_passwd.db

-rwxr--r--. 1 postfix root 0 Feb 19 04:16 /etc/postfix/sasl_passwd.db
-rw-r-----. 1 postfix root 0 Feb 19 04:16 /etc/postfix/sasl_passwd.db

postmap hash:/etc/postfix/sasl_passwd

postmap: fatal: cannot remove zero-length database file /etc/postfix/sasl_passwd.db: Permission denied.

chmod 777 gives the same error as above.

Yaron
  • 221
James Benders
  • 153
  • 1
  • 1
  • 5

5 Answers5

27

You need to make sure that postfix user is able to read that file. You can post the output of $ sudo ls -l /etc/postfix/sasl_passwd.db to get more help.

To create this file, you can use the command:

$ sudo postmap sasl_passwd

This will create the .db file.

Khaled
  • 37,789
11

This issue, at least on Ubuntu 12.04, is caused by the /etc/postfix folder not being owned by the postfix user. (as inferred above).

The error message is caused because you should not directly create the .db file yourself. If you did, delete it.

postmap: fatal: cannot remove zero-length database file /etc/postfix/sasl_passwd.db: Permission denied.

The simple fix to the original issue is:

sudo chown postfix /etc/postfix

After that, you can run this

sudo postmap sasl_passwd

Where it is assumed your clear text passwords are in the file sasl_passwd

Tom Carchrae
  • 219
  • 2
  • 6
0

For me, to fix I had to:

1st) change the owner of the config directory of postfix to postfixs. Did this by calling:

sudo chown -R postfix:postfix /etc/postfix

2nd) called postmap:

sudo postmap /etc/postfix/sasl_passwd

And it worked. sasl_passwd.db was created.

3rd) reload postfix

sudo /etc/init.d/postfix start
sudo /etc/init.d/postfix reload

Previously I had deleted the old sasl_passwd.db file and I also stopped postfix by calling service postfix stop. Not sure if it makes any difference, but worth trying if you get any error.

Joao Leme
  • 101
0

Normally you should have system user postfix and group created on your system. He must be able to read /etc/postfix files.

For me the best way of doing it is to make files belong to root since is standard thing, but group should be postfix this way postfix user can read those.

chown root:postfix /etc/postfix -R

So if i do ls -l i got this

drwxr-xr-x. 1 root    postfix    0  2 janv. 01:00 dynamicmaps.cf.d/
drwxr-xr-x. 1 root    postfix    0  2 janv. 01:00 postfix-files.d/
-rw-r--r--. 1 root    postfix  21K 20 déc.   2021 access
-rw-r--r--. 1 root    postfix  13K 20 déc.   2021 canonical
-rw-r--r--. 1 root    postfix   60  2 janv. 01:00 dynamicmaps.cf
-rw-r--r--. 1 root    postfix  11K 20 déc.   2021 generic
-rw-r--r--. 1 root    postfix  24K  9 oct.   2016 header_checks
-rw-r--r--. 1 root    postfix  31K 14 avril 07:26 main.cf
-rw-r--r--. 1 root    postfix  29K  2 janv. 01:00 main.cf.proto
-rw-r--r--. 1 root    postfix 7,8K 26 mars  22:37 master.cf
-rw-r--r--. 1 root    postfix 7,0K  2 janv. 01:00 master.cf.proto
-rw-r--r--. 1 root    postfix 1,1K 26 mars  17:28 my-clamd.pp
-rw-r--r--. 1 root    postfix  274 26 mars  17:28 my-clamd.te
-rw-r--r--. 1 root    postfix  21K  2 janv. 01:00 postfix-files
-rw-r--r--. 1 root    postfix 7,0K 20 déc.   2021 relocated
-rw-r--r--. 1 root    postfix  14K 20 déc.   2021 transport
-rw-r--r--. 1 root    postfix  14K 25 mars   2022 virtual
-rw-r--r--. 1 root    postfix   38 14 avril 07:34 virtual-mailbox
-rw-r--r--. 1 root    postfix  12K 14 avril 11:42 virtual-mailbox.db
gori
  • 109
0

Change the owner

chown root:wheel policy_file