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

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

> Solution:
> I think the attached patch will fix this.

There was a little prototyping error in the fix. Here's a new one.

Regards,

-- Maurice Makaay

_______________________________________________
Bug-gnu-radius mailing list
[email protected]
http://mail.gnu.org/mailman/listinfo/bug-gnu-radius
patch.new (text/plain, 2 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 07:56:45 -0000
@@ -1149,10 +1149,18 @@
 int
 auth_stmt_begin(int finish, void *block_data, void *handler_data)
 {
-	if (!finish) 
-		_opened_auth_sockets = 0;
-	else if (radius_mode == MODE_DAEMON && !_opened_auth_sockets) 
-		udp_open(R_AUTH, INADDR_ANY, auth_port, 0);
+	if (!finish)
+	    _opened_auth_sockets = 0;
+	return 0;
+}
+
+int
+auth_stmt_end(void *block_data, void *handler_data)
+{
+	if (radius_mode == MODE_DAEMON && !_opened_auth_sockets) {
+	    radlog(L_ERR, "Open AUTH port");
+	    udp_open(R_AUTH, INADDR_ANY, auth_port, 0);
+	}
 	return 0;
 }
 
@@ -1183,10 +1191,16 @@
 int
 acct_stmt_begin(int finish, void *block_data, void *handler_data)
 {
-	if (!finish) 
-		_opened_acct_sockets = 0;
-	else if (radius_mode == MODE_DAEMON && !_opened_acct_sockets) 
-		udp_open(R_ACCT, INADDR_ANY, acct_port, 0);
+	if (!finish)
+	    _opened_acct_sockets = 0;
+	return 0;
+}
+
+int
+acct_stmt_end(void *block_data, void *handler_data)
+{
+	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,