Hello, I asked about this a few days ago, but since nobody answered in that thread, I'd like to bring it up again as a separate thread. Maybe somebody answers... I have written a policy service for Postfix that checks whether the connecting IP address has currently an IMAP session open. For this, it needs to access the socket /var/run/dovecot/anvil. But by default, this socket is accessible only for root, and I obviously DON'T want my service to run as root: srw------- 1 root root 0 May 22 2020 /var/run/dovecot/anvil By modifying Dovecot configuration I was able to chnge the permissions on that socket to: srw-rw---- 1 root dovecot 0 Aug 21 20:47 /var/run/dovecot/anvil Then my service can run under the user "dovecot" and access the socket. Here's my question: did I create any security risk by changing the socket permissions like above and running my service under "dovecot" user? Or will it be better that I create a special user dedicated only for this service and run the service under that user? -- Regards, Jaroslaw Rafa raj at rafa.eu.org -- "In a million years, when kids go to school, they're gonna know: once there was a Hushpuppy, and she lived with her daddy in the Bathtub."
> srw-rw---- 1 root dovecot 0 Aug 21 20:47 /var/run/dovecot/anvil > Then my service can run under the user "dovecot" and access the socket.My educated guess is, no this doesn't create any extra vulnerability. If someone could exploit the user dovecot, then don't they already have access to dovecot, that socket and everything else? An extra step you can do if you are not comfortable running the policy script as user dovecot is run the policy script under its own user, then add that user to the dovecot group. But i am far from being an expert and doing that might not be adding any extra 'safety'. usermod -a -G policy_user dovecot Now for my 2 cents; Why? Not all clients keep active connections open to IMAP between fetching mail and then sending to submission. Postfix can validate user/pass credentials with dovecot when accepting mail for submission. Why add extra moving parts to your system instead of just using the built in auth checking for submission mail? http://www.postfix.org/postconf.5.html#permit_sasl_authenticated POSTFIX: submission inet n - n - - smtpd ... -o smtpd_sasl_type=dovecot -o smtpd_sasl_path=private/auth -o smtpd_sasl_auth_enable=yes -o smtpd_sasl_security_options=noanonymous -o smtpd_relay_restrictions=permit_sasl_authenticated,reject_unauth_destination ... DOVECOT: service auth { unix_listener /var/spool/postfix/private/auth { mode = 0660 user = postfix group = postfix } }