about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2009-08-31 19:42:59 +0200
committerFlorian Westphal <fw@strlen.de>2009-08-31 22:08:35 +0200
commitcf7e19193b79af0711c5a03ac7da33bd84947b16 (patch)
tree1de9d196c777b5cdb1b2fbae8ec1c9c857c32b20 /src
parent5f1e43416a7ff8185928ce8538b8d0826c61b93f (diff)
downloadngircd-cf7e19193b79af0711c5a03ac7da33bd84947b16.tar.gz
ngircd-cf7e19193b79af0711c5a03ac7da33bd84947b16.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/conf.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index eccf13cc..1d1bb482 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -543,6 +543,16 @@ Set_Defaults( bool InitServers )
 
 
 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 )
 {
 	/* Read configuration file. */
@@ -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)