Radiusd will try to open UDP listen, even without auth{} or acct{} block

Maurice Makaay <[email protected]> Tue, 4 Nov 2003 01:57:26 +0100
Newsgroups gmane.comp.gnu.radius.bugs
Organization InterNLnet BV
Message-ID <[email protected]>
Hi,

I am trying to build an accounting-only gnu-radius server. For doing so,
I created a configuration file without an "auth{ ... }" block in it.
This should work, but I see that the radiusd will on startup try to
open the default UDP radius authentication port. This is a bug, because
it might cause trouble on systems where people are running two separate
radiusservers for authentication and accounting. 

Imagine: 
server 1 starts with only an acct block in the configuration, but alongside 
listening on the accounting UDP port, it'll also start listening on the 
authentication UDP port.
server 2 starts with only an authentication block in the configuration.
Binding the auth port will fail, because server 1 already did so.
Result: broken radius service.

Workaround:
Always create an auth{} and an acct{} block in the configuration and if
one of them is not used, assign a bogus port using the listen statement.

Solution:
I think the attached patch will fix this.


Regards,

-- Maurice Makaay

_______________________________________________
Bug-gnu-radius mailing list
[email protected]
http://mail.gnu.org/mailman/listinfo/bug-gnu-radius
patch.config.udp.listen (text/plain, 1.7 KB)
Index: radiusd.c
===================================================================
RCS file: /cvsroot/radius/radius/radiusd/radiusd.c,v
retrieving revision 1.147
diff -u -r1.147 radiusd.c
--- radiusd.c	3 Nov 2003 13:23:26 -0000	1.147
+++ radiusd.c	4 Nov 2003 00:43:04 -0000
@@ -1151,7 +1151,14 @@
 {
 	if (!finish) 
 		_opened_auth_sockets = 0;
-	else if (radius_mode == MODE_DAEMON && !_opened_auth_sockets) 
+	return 0;
+}
+
+int
+auth_stmt_end(int finish, void *block_data, void *handler_data)
+{
+	if (handler_data != NULL) 
+	    if (radius_mode == MODE_DAEMON && !_opened_auth_sockets) 
 		udp_open(R_AUTH, INADDR_ANY, auth_port, 0);
 	return 0;
 }
@@ -1185,7 +1192,14 @@
 {
 	if (!finish) 
 		_opened_acct_sockets = 0;
-	else if (radius_mode == MODE_DAEMON && !_opened_acct_sockets) 
+	return 0;
+}
+
+int
+acct_stmt_end(int finish, void *block_data, void *handler_data)
+{
+	if (handler_data != NULL)
+	    if (radius_mode == MODE_DAEMON && !_opened_acct_sockets) 
 		udp_open(R_ACCT, INADDR_ANY, acct_port, 0);
 	return 0;
 }
@@ -1319,8 +1333,10 @@
 	{ "message", CS_BLOCK, NULL, NULL, NULL, message_stmt, NULL },
 	{ "logging", CS_BLOCK, logging_stmt_begin, logging_stmt_handler, NULL,
 	  logging_stmt, logging_stmt_end },
-	{ "auth", CS_BLOCK, auth_stmt_begin, NULL, NULL, auth_stmt, NULL },
-	{ "acct", CS_BLOCK, acct_stmt_begin, NULL, NULL, acct_stmt, NULL  },
+	{ "auth", CS_BLOCK, auth_stmt_begin, NULL, NULL, 
+	  auth_stmt, auth_stmt_end },
+	{ "acct", CS_BLOCK, acct_stmt_begin, NULL, NULL, 
+	  acct_stmt, acct_stmt_end },
 	{ "proxy", CS_BLOCK, NULL, NULL, NULL, proxy_stmt, NULL  },
 	{ "rewrite", CS_BLOCK, rewrite_stmt_term, NULL, NULL, rewrite_stmt, NULL },
 	{ "filters", CS_BLOCK, filters_stmt_term, NULL, NULL, filters_stmt,