From a17df3e475822332b4bdaee70992b44042316d32 Mon Sep 17 00:00:00 2001 From: David Parrish Date: Mon, 26 Jul 2004 00:20:41 +0000 Subject: [PATCH] Makefile fix and config radius port patches from JK --- Changes | 3 +++ Docs/manual.html | 2 +- Makefile | 19 ++++++++++++++++--- l2tpns.c | 20 ++++++++++++++++++-- l2tpns.h | 4 ++-- radius.c | 11 +++++++++-- 6 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Changes b/Changes index 872165f..f1e9da9 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ * ??? 2.0.2 - Apply patch to fix -v option from Juergen Kammer. +- Makefile fix from Juergen Kammer to not overwrite existing config files on + make install +- Configurable radius port patch from Juergen Kammer. * Tue Jul 13 2004 Brendan O'Dea 2.0.1 - Update INSTALL, Docs/manual.html documentation. diff --git a/Docs/manual.html b/Docs/manual.html index d1ce33c..0227ac3 100644 --- a/Docs/manual.html +++ b/Docs/manual.html @@ -983,6 +983,6 @@ That's really what it looks like.


David Parrish
-david@dparrish.com +david@dparrish.com diff --git a/Makefile b/Makefile index 6cdd6fe..b9007fa 100644 --- a/Makefile +++ b/Makefile @@ -41,12 +41,25 @@ depend: mv Makefile Makefile.bak mv Makefile.tmp Makefile +# install config files only if a startup-config does not exist yet JK 20040713 +# this does not interfere when building rpms or debs and makes +# fast upgrading via make install possible + install: all $(INSTALL) -D -o root -g root -m 0755 l2tpns $(bindir)/l2tpns $(INSTALL) -D -o root -g root -m 0755 nsctl $(bindir)/nsctl - $(INSTALL) -D -o root -g root -m 0600 etc/startup-config.default $(etcdir)/startup-config - $(INSTALL) -D -o root -g root -m 0644 etc/ip_pool.default $(etcdir)/l2tpns.ip_pool - $(INSTALL) -D -o root -g root -m 0600 etc/users.default $(etcdir)/l2tpns.users + @if [ -f $(etcdir)/startup-config ]; then \ + echo '***' Installing default config files in $(etcdir) as .defaults; \ + $(INSTALL) -D -o root -g root -m 0600 etc/startup-config.default $(etcdir)/startup-config.default; \ + $(INSTALL) -D -o root -g root -m 0644 etc/ip_pool.default $(etcdir)/ip_pool.default; \ + $(INSTALL) -D -o root -g root -m 0600 etc/users.default $(etcdir)/users.default; \ + else \ + echo '***' Installing default config files in $(etcdir) - remember to adjust them; \ + $(INSTALL) -D -o root -g root -m 0600 etc/startup-config.default $(etcdir)/startup-config; \ + $(INSTALL) -D -o root -g root -m 0644 etc/ip_pool.default $(etcdir)/l2tpns.ip_pool; \ + $(INSTALL) -D -o root -g root -m 0600 etc/users.default $(etcdir)/l2tpns.users; \ + fi + for plugin in $(PLUGINS); do \ $(INSTALL) -D -o root -g root -m 0755 $$plugin $(libdir)/$$plugin; \ done diff --git a/l2tpns.c b/l2tpns.c index 5f005a0..1e5b46c 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -4,7 +4,7 @@ // Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced // vim: sw=8 ts=8 -char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.15 2004-07-12 15:16:27 bodea Exp $"; +char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.16 2004-07-26 00:20:41 fred_nerk Exp $"; #include #include @@ -100,6 +100,8 @@ struct config_descriptt config_values[] = { CONFIG("save_state", save_state, BOOL), CONFIG("primary_radius", radiusserver[0], IP), CONFIG("secondary_radius", radiusserver[1], IP), + CONFIG("primary_radius_port",radiusport[0], SHORT), + CONFIG("secondary_radius_port",radiusport[1], SHORT), CONFIG("radius_accounting", radius_accounting, BOOL), CONFIG("radius_secret", radiussecret, STRING), CONFIG("bind_address", bind_address, IP), @@ -3325,7 +3327,21 @@ void update_config() // Update radius config->numradiusservers = 0; for (i = 0; i < MAXRADSERVER; i++) - if (config->radiusserver[i]) config->numradiusservers++; + if (config->radiusserver[i]) + { + config->numradiusservers++; + // Set radius port: if not set, take the port from the + // first radius server. For the first radius server, + // take the #defined default value from l2tpns.h + + // test twice, In case someone works with + // a secondary radius server without defining + // a primary one, this will work even then. + if (i>0 && !config->radiusport[i]) + config->radiusport[i] = config->radiusport[i-1]; + if (!config->radiusport[i]) + config->radiusport[i] = RADPORT; + } if (!config->numradiusservers) { diff --git a/l2tpns.h b/l2tpns.h index 56cb9a5..2cf1797 100644 --- a/l2tpns.h +++ b/l2tpns.h @@ -1,5 +1,5 @@ // L2TPNS Global Stuff -// $Id: l2tpns.h,v 1.12 2004-07-12 08:21:45 bodea Exp $ +// $Id: l2tpns.h,v 1.13 2004-07-26 00:20:41 fred_nerk Exp $ #ifndef __L2TPNS_H__ #define __L2TPNS_H__ @@ -67,7 +67,6 @@ #define ACCT_TIME 3000 // 5 minute accounting interval #define L2TPPORT 1701 // L2TP port #define RADPORT 1645 // old radius port... -#define RADAPORT 1646 // old radius accounting port #define PKTARP 0x0806 // ARP packet type #define PKTIP 0x0800 // IP packet type #define PSEUDOMAC 0x0200 // pseudo MAC prefix (local significant MAC) @@ -396,6 +395,7 @@ struct configt char radiussecret[64]; int radius_accounting; ipt radiusserver[MAXRADSERVER]; // radius servers + u16 radiusport[MAXRADSERVER]; // radius base ports u8 numradiusservers; // radius server count short num_radfds; // Number of radius filehandles allocated diff --git a/radius.c b/radius.c index 7453211..ea3597f 100644 --- a/radius.c +++ b/radius.c @@ -1,6 +1,6 @@ // L2TPNS Radius Stuff -char const *cvs_id_radius = "$Id: radius.c,v 1.8 2004-07-11 07:57:35 bodea Exp $"; +char const *cvs_id_radius = "$Id: radius.c,v 1.9 2004-07-26 00:20:41 fred_nerk Exp $"; #include #include @@ -345,7 +345,14 @@ void radiussend(u16 r, u8 state) memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; *(u32 *) & addr.sin_addr = config->radiusserver[(radius[r].try - 1) % config->numradiusservers]; - addr.sin_port = htons((state == RADIUSAUTH) ? RADPORT : RADAPORT); + { + // get radius port + u16 port = config->radiusport[(radius[r].try - 1) % config->numradiusservers]; + // no need to define the accounting port for itself: + // the accounting port is as far as I know always one more + // than the auth port JK 20040713 + addr.sin_port = htons((state == RADIUSAUTH) ? port : port+1); + } log_hex(5, "RADIUS Send", b, (p - b)); sendto(radfds[r & RADIUS_MASK], b, p - b, 0, (void *) &addr, sizeof(addr)); -- 2.20.1