repo: ngircd
action: commit
revision: 
path_from: 
revision_from: cf7e19193b79af0711c5a03ac7da33bd84947b16:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit cf7e19193b79af0711c5a03ac7da33bd84947b16
Author: Florian Westphal 
Date:   Mon Aug 31 19:42:59 2009 +0200

    do not add default listening port if ssl ports were specified

    Cosmo Kastemaa reported that its impossible to create an ssl-only setup,
    as ngircd binds to port 6667 by default, even if setting "Ports =".

    Only add the default port if _both_ "Ports" and "SSLPorts" are
    unspecified.

    Fixes bugzilla #98.

diff --git a/man/ngircd.conf.5.tmpl b/man/ngircd.conf.5.tmpl
index 8e5b254aa04d2bdb69a487c72651b3d59e8bf456..
index ..a725af65342c469dd330600f46299b1eabea1987 100644
--- a/man/ngircd.conf.5.tmpl
+++ b/man/ngircd.conf.5.tmpl
@@ -75,7 +75,8 @@ command.
 .TP
 \fBPorts\fR
 Ports on which the server should listen. There may be more than one port,
-separated with commas (","). Default: 6667.
+separated with commas (","). Default: 6667, unless \fBSSL_Ports\fR are also
+specified.
 .TP
 \fBSSLPorts\fR
 Same as \fBPorts\fR , except that ngIRCd will expect incoming connections
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index eccf13cc3edec2a78d533287c2d92a18ce2345ce..
index ..1d1bb482d43cc4c3f5da606ac540cf40cd75afca 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -542,6 +542,16 @@ Set_Defaults( bool InitServers )
 } /* Set_Defaults */


+static bool
+no_listenports(void)
+{
+	unsigned int cnt = array_bytes(&Conf_ListenPorts);
+#ifdef SSL_SUPPORT
+	cnt += array_bytes(&Conf_SSLOptions.ListenPorts);
+#endif
+	return cnt == 0;
+}
+
 static bool
 Read_Config( bool ngircd_starting )
 {
@@ -698,12 +708,14 @@ Read_Config( bool ngircd_starting )
 		Conf_Server[New_Server_Idx] = New_Server;
 	}

-	if (0 == array_length(&Conf_ListenPorts, sizeof(UINT16))) {
-		if (!array_copyb(&Conf_ListenPorts, (char*) &defaultport, sizeof defaultport)) {
-			Config_Error( LOG_ALERT, "Could not add default listening Port %u: %s",
-							(unsigned int) defaultport, strerror(errno));
-			exit( 1 );
-		}
+	/* not a single listening port? Add default. */
+	if (no_listenports() &&
+		!array_copyb(&Conf_ListenPorts, (char*) &defaultport, sizeof defaultport))
+	{
+		Config_Error(LOG_ALERT, "Could not add default listening Port %u: %s",
+					(unsigned int) defaultport, strerror(errno));
+
+		exit(1);
 	}

 	if (!Conf_ListenAddress)

-----END OF PAGE-----