From 6d259a6e122abed011210e1de749d3b73626d4c7 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Fri, 6 May 2016 09:06:52 -0400 Subject: [PATCH] use "127.0.0.1" throughout rather than mixing use of an IP address and "localhost" On some machines localhost is defined as something other than 127.0.0.1, and if we mix "127.0.0.1" and "localhost" then some connections won't be to to the address a service is actually running on. This was the case with DKIM: It was running on "localhost" but Postfix was connecting to it at 127.0.0.1. (https://discourse.mailinabox.email/t/opendkim-is-not-running-port-8891/1188/12.) I suppose "localhost" could be an alias to an IPv6 address? We don't really want local services binding on IPv6, so use "127.0.0.1" to be explicit and don't use "localhost" to be sure we get an IPv4 address. Fixes #797 --- CHANGELOG.md | 2 +- conf/zpush/backend_caldav.php | 2 +- conf/zpush/backend_carddav.php | 2 +- conf/zpush/backend_imap.php | 4 ++-- management/email_administrator.py | 2 +- setup/dkim.sh | 2 +- setup/owncloud.sh | 4 ++-- setup/start.sh | 2 +- setup/webmail.sh | 6 +++--- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7bfc44..031801e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ Setup: * The system hostname is now set during setup. * A swap file is now created if system memory is less than 2GB, 5GB of free disk space is available, and if no swap file yet exists. * We now install Roundcube from the official GitHub repository instead of our own mirror, which we had previously created to solve problems with SourceForge. - +* DKIM was incorrectly set up on machines where "localhost" was defined as something other than "127.0.0.1". v0.17c (April 1, 2016) ---------------------- diff --git a/conf/zpush/backend_caldav.php b/conf/zpush/backend_caldav.php index 7bddded..b10ebc3 100644 --- a/conf/zpush/backend_caldav.php +++ b/conf/zpush/backend_caldav.php @@ -6,7 +6,7 @@ ************************************************/ define('CALDAV_PROTOCOL', 'https'); -define('CALDAV_SERVER', 'localhost'); +define('CALDAV_SERVER', '127.0.0.1'); define('CALDAV_PORT', '443'); define('CALDAV_PATH', '/caldav/calendars/%u/'); define('CALDAV_PERSONAL', 'PRINCIPAL'); diff --git a/conf/zpush/backend_carddav.php b/conf/zpush/backend_carddav.php index edf3290..4b166ad 100644 --- a/conf/zpush/backend_carddav.php +++ b/conf/zpush/backend_carddav.php @@ -7,7 +7,7 @@ define('CARDDAV_PROTOCOL', 'https'); /* http or https */ -define('CARDDAV_SERVER', 'localhost'); +define('CARDDAV_SERVER', '127.0.0.1'); define('CARDDAV_PORT', '443'); define('CARDDAV_PATH', '/carddav/addressbooks/%u/'); define('CARDDAV_DEFAULT_PATH', '/carddav/addressbooks/%u/contacts/'); /* subdirectory of the main path */ diff --git a/conf/zpush/backend_imap.php b/conf/zpush/backend_imap.php index 3f69f53..84dc735 100644 --- a/conf/zpush/backend_imap.php +++ b/conf/zpush/backend_imap.php @@ -5,7 +5,7 @@ * Descr : IMAP backend configuration file ************************************************/ -define('IMAP_SERVER', 'localhost'); +define('IMAP_SERVER', '127.0.0.1'); define('IMAP_PORT', 993); define('IMAP_OPTIONS', '/ssl/norsh/novalidate-cert'); define('IMAP_DEFAULTFROM', ''); @@ -44,7 +44,7 @@ define('IMAP_FROM_LDAP_FROM', '#givenname #sn <#mail>'); define('IMAP_SMTP_METHOD', 'sendmail'); global $imap_smtp_params; -$imap_smtp_params = array('host' => 'ssl://localhost', 'port' => 587, 'auth' => true, 'username' => 'imap_username', 'password' => 'imap_password'); +$imap_smtp_params = array('host' => 'ssl://127.0.0.1', 'port' => 587, 'auth' => true, 'username' => 'imap_username', 'password' => 'imap_password'); define('MAIL_MIMEPART_CRLF', "\r\n"); diff --git a/management/email_administrator.py b/management/email_administrator.py index 84d2746..b16fda1 100755 --- a/management/email_administrator.py +++ b/management/email_administrator.py @@ -33,7 +33,7 @@ msg['Subject'] = "[%s] %s" % (env['PRIMARY_HOSTNAME'], subject) msg.set_payload(content, "UTF-8") # send -smtpclient = smtplib.SMTP('localhost', 25) +smtpclient = smtplib.SMTP('127.0.0.1', 25) smtpclient.ehlo() smtpclient.sendmail( admin_addr, # MAIL FROM diff --git a/setup/dkim.sh b/setup/dkim.sh index ed56c76..830e9e1 100755 --- a/setup/dkim.sh +++ b/setup/dkim.sh @@ -31,7 +31,7 @@ ExternalIgnoreList refile:/etc/opendkim/TrustedHosts InternalHosts refile:/etc/opendkim/TrustedHosts KeyTable refile:/etc/opendkim/KeyTable SigningTable refile:/etc/opendkim/SigningTable -Socket inet:8891@localhost +Socket inet:8891@127.0.0.1 RequireSafeKeys false EOF fi diff --git a/setup/owncloud.sh b/setup/owncloud.sh index 94dd70b..cc58a5c 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -108,12 +108,12 @@ if [ ! -f $STORAGE_ROOT/owncloud/owncloud.db ]; then 'user_backends' => array( array( 'class'=>'OC_User_IMAP', - 'arguments'=>array('{localhost:993/imap/ssl/novalidate-cert}') + 'arguments'=>array('{127.0.0.1:993/imap/ssl/novalidate-cert}') ) ), 'memcache.local' => '\\OC\\Memcache\\Memcached', "memcached_servers" => array ( - array('localhost', 11211), + array('127.0.0.1', 11211), ), 'mail_smtpmode' => 'sendmail', 'mail_smtpsecure' => '', diff --git a/setup/start.sh b/setup/start.sh index 09dc895..9d19a41 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -112,7 +112,7 @@ source setup/management.sh source setup/munin.sh # Ping the management daemon to write the DNS and nginx configuration files. -until nc -z -w 4 localhost 10222 +until nc -z -w 4 127.0.0.1 10222 do echo Waiting for the Mail-in-a-Box management daemon to start... sleep 2 diff --git a/setup/webmail.sh b/setup/webmail.sh index e643455..a325b1c 100755 --- a/setup/webmail.sh +++ b/setup/webmail.sh @@ -91,10 +91,10 @@ cat > /usr/local/lib/roundcubemail/config/config.inc.php < /usr/local/lib/roundcubemail/plugins/vacation_sieve/config.inc.php < array( 'mode' => 'managesieve', 'ms_activate_script' => true, - 'host' => 'localhost', + 'host' => '127.0.0.1', 'port' => '4190', 'usetls' => false, 'path' => 'vacation',