-.TH NASLIST 5 "15 September 1997"
+.TH NASLIST 5 "12 August 2005"
.SH NAME
naslist \- RADIUS naslist file
.SH DESCRIPTION
-The \fInaslist\fP file resides in the radius database directory,
-by default \fI/etc/raddb\fP. It contains a list of RADIUS network access
-servers (NASes).
-Every line starting with a hash sign
-.RB (' # ')
-is treated as comment and ignored.
-.PP
-Each line of the file contains three white-space delimited fields.
-.IP client hostname
-The NAS hostname. This may be a plain hostname, or a
-dotted-quad IP address.
-.IP shortname
-This field is optional, and declares a short alias for the NAS.
-.IP NAStype
-Type of NAS (terminalserver). This can be \fIlivingston\fP, \fIcisco\fP,
-\fIportslave\fP or \fIother\fP. This is passed to the external \fBchecklogin\fP
-program when it is called to detect double logins.
-.PP
-The
-.I naslist
-file is read by \fBradiusd\fP on startup only.
-.SH FILES
-.I /etc/raddb/naslist
+naslist \- FreeRADIUS configuration file.
+.SH DESCRIPTION
+This configuration file is no longer used by the server, and will not
+be read by the server. See the "scripts/clients.pl" program for a way
+to migrate this file to the new format.
.SH "SEE ALSO"
-.BR radiusd (8),
-.BR clients (5)
+.BR clients.conf (5)
+++ /dev/null
-#
-# THIS FILE IS DEPRECATED.
-#
-# You should NOT be using this file to configure the server.
-# It is here ONLY for backwards compatibility.
-#
-# See 'clients.conf' for the new configuration.
+++ /dev/null
-#
-# THIS FILE IS DEPRECATED.
-#
-# You should NOT be using this file to configure the server.
-# It is here ONLY for backwards compatibility.
-#
-# See 'clients.conf' for the new configuration.
-#
-#
-# naslist This file contains a list of NASes (Network Access Servers,
-# also known as terminal servers) which we know.
-#
-# Description of the fields:
-#
-# * The first field is a valid hostname or IP address
-# for the client.
-# * The second field (seperated by blanks or tabs) is the
-# short name we use in the logfiles for this NAS.
-# * The third field defines what type of device it is. Valid
-# values are "cisco", "computone", "livingston", "max40xx",
-# "multitech", "netserver", "pathras", "patton", "portslave",
-# "tc", "usrhiper" or "other".
-#
-# This is used to find out how to detect double logins.
-#
-
-# NAS Name Short Name Type
-#---------------- ---------- ----
-#portmaster1.isp.com pm1.NY livingston
-#portmaster2.isp.com pm1.LA livingston
-localhost local portslave
#
# Convert old-style "clients" file to new "clients.conf" format.
#
-# Usage: clients.pl clients new-clients.conf
-# The "new-clients.conf" will be over-written.
+# Usage: clients.pl clients [naslist] new-clients.conf
+# The "new-clients.conf" will be created if it does not exist.
+# If it does exist, it will be over-written.
#
#
# $Id$
#
-if ($#ARGV != 1) {
- print "Usage: clients.pl clients new-clients.conf\n";
+if (($#ARGV < 1) || ($#ARGV > 2)) {
+ print "Usage: clients.pl clients [naslist] new-clients.conf\n";
print " The \"new-clients.conf\" will be created if it does not exist.\n";
- print " If it does exist, it will be over-written.";
+ print " If it does exist, it will be over-written.\n";
exit(1);
}
$old = shift;
$new = shift;
-open OLD, "< $old"or die "Failed to open $old: $!\n";
-open NEW, "> $new" or die "Failed to open $new: $!\n";
+if ($new =~ /naslist/) {
+ $naslist = $new;
+ $new = shift;
+}
+
+open OLD, "< $old" or die "Failed to open $old: $!\n";
while (<OLD>) {
next if (/^\s*\#/);
+ next if (/^\s*$/);
split;
- print NEW "client $_[0] {\n";
- print NEW "\tsecret = $_[1]\n";
+ $clients{$_[0]}{"secret"} = $_[1];
+}
+close OLD;
+
+if (defined $naslist) {
+ open OLD, "< $naslist" or die "Failed to open $naslist: $!\n";
+
+ while (<OLD>) {
+ next if (/^\s*\#/);
+ next if (/^\s*$/);
+
+ split;
+
+ if (!defined $clients{$_[0]}) {
+ print "WARNING! client $_[0] is defined in naslist, but not in clients!";
+ next;
+ }
+
+ $clients{$_[0]}{"shortname"} = $_[1];
+ $clients{$_[0]}{"nastype"} = $_[2];
+ }
+}
+
+open NEW, "> $new" or die "Failed to open $new: $!\n";
+foreach $client (keys %clients) {
+ print NEW "client $client {\n";
+ print NEW "\tsecret = ", $clients{$client}{"secret"}, "\n";
+ if (defined $clients{$client}{"shortname"}) {
+ print NEW "\tshortname = ", $clients{$client}{"shortname"}, "\n";
+ print NEW "\tnastype = ", $clients{$client}{"nastype"}, "\n";
+ }
print NEW "}\n";
+ print NEW "\n";
}
typedef struct radclient_list RADCLIENT_LIST;
-typedef struct nas {
- uint32_t ipaddr;
- char longname[256];
- char shortname[32];
- char nastype[32];
- struct nas *next;
-} NAS;
-
typedef struct _realm {
char realm[64];
char server[64];
int read_config_files(void);
int read_realms_file(const char *file);
-/* nas.c */
-int read_naslist_file(char *);
-NAS *nas_find(uint32_t ipno);
-
/* version.c */
void version(void);
include ../../Make.inc
-SERVER_SRCS = radiusd.c files.c util.c acct.c nas.c log.c valuepair.c \
+SERVER_SRCS = radiusd.c files.c util.c acct.c log.c valuepair.c \
version.c proxy.c auth.c conffile.c modules.c modcall.c \
session.c xlat.c threads.c smux.c radius_snmp.c client.c \
request_list.c mainconfig.c listen.c request_process.c
util.o: util.c
$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c util.c
-nas.o: nas.c
- $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c nas.c
-
log.o: log.c
$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c log.c
if (listener != NULL) {
RADCLIENT_LIST *clients, *old_clients;
- /* old-style naslist file */
- snprintf(buffer, sizeof(buffer), "%.200s/%.50s", radius_dir, RADIUS_NASLIST);
- DEBUG2("read_config_files: reading naslist");
- if (read_naslist_file(buffer) < 0) {
- radlog(L_ERR|L_CONS, "Errors reading naslist");
- return -1;
- }
-
/*
* Create the new clients first, and add them
* to the CONF_SECTION, where they're automagically
+++ /dev/null
-/*
- * nas.c Functions to do with a NASLIST. This is here because
- * radzap needs it as well.
- *
- * Version: $Id$
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Copyright 2000 The FreeRADIUS server project
- * Copyright 2000 Miquel van Smoorenburg <miquels@cistron.nl>
- * Copyright 2000 Alan DeKok <aland@ox.org>
- */
-
-static const char rcsid[] = "$Id$";
-
-#include "autoconf.h"
-
-#include <sys/stat.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "radiusd.h"
-
-static NAS *naslist = NULL;
-
-/*
- * Free a NAS list.
- */
-static void nas_free(NAS *cl)
-{
- NAS *next;
-
- while(cl) {
- next = cl->next;
- free(cl);
- cl = next;
- }
-}
-
-/*
- * Read the nas file.
- */
-int read_naslist_file(char *file)
-{
- FILE *fp;
- char buffer[256];
- char hostnm[256];
- char shortnm[256];
- char nastype[256];
- int lineno = 0;
- char *p;
- NAS *nas;
-
- nas_free(naslist);
- naslist = NULL;
-
- if ((fp = fopen(file, "r")) == NULL) {
- /* The naslist file is no longer required. All configuration
- information comes from radiusd.conf. If naslist exists it
- will be used, but if it doesn't exist it will be silently
- ignored. */
- return 0;
- }
- while(fgets(buffer, 256, fp) != NULL) {
- lineno++;
- if (!feof(fp) && (strchr(buffer, '\n') == NULL)) {
- radlog(L_ERR, "%s[%d]: line too long", file, lineno);
- return -1;
- }
- if (buffer[0] == '#' || buffer[0] == '\n')
- continue;
-
- p = buffer;
- if (!getword(&p, hostnm, sizeof(hostnm)) ||
- !getword(&p, shortnm, sizeof(shortnm))) {
- radlog(L_ERR, "%s[%d]: unexpected end of line",
- file, lineno);
- continue;
- }
- (void)getword(&p, nastype, sizeof(nastype));
-
- /*
- * Double-check lengths to be sure they're sane
- */
- if (strlen(hostnm) >= sizeof(nas->longname)) {
- radlog(L_ERR, "%s[%d]: host name of length %d is greater than the allowed maximum of %d.",
- file, lineno,
- (int) strlen(hostnm),
- (int) sizeof(nas->longname) - 1);
- return -1;
- }
- if (strlen(shortnm) > sizeof(nas->shortname)) {
- radlog(L_ERR, "%s[%d]: short name of length %d is greater than the allowed maximum of %d.",
- file, lineno,
- (int) strlen(shortnm),
- (int) sizeof(nas->shortname) - 1);
- return -1;
- }
- if (strlen(nastype) >= sizeof(nas->nastype)) {
- radlog(L_ERR, "%s[%d]: NAS type of length %d is greater than the allowed maximum of %d.",
- file, lineno,
- (int) strlen(nastype),
- (int) sizeof(nas->nastype) - 1);
- return -1;
- }
-
- /*
- * It should be OK now, let's create the buffer.
- */
- nas = rad_malloc(sizeof(NAS));
- memset(nas, 0, sizeof(*nas));
-
- strcpy(nas->nastype, nastype);
- strcpy(nas->shortname, shortnm);
-
- if (strcmp(hostnm, "DEFAULT") == 0) {
- nas->ipaddr = 0;
- strcpy(nas->longname, hostnm);
- } else {
- nas->ipaddr = ip_getaddr(hostnm);
- ip_hostname(nas->longname, sizeof(nas->longname),
- nas->ipaddr);
- }
-
- nas->next = naslist;
- naslist = nas;
- }
- fclose(fp);
-
- if (naslist) {
- radlog(L_INFO, "Using deprecated naslist file. Support for this will go away soon.");
- }
-
- return 0;
-}
-
-
-/*
- * Find a nas by IP address.
- * If it can't be found, return the DEFAULT nas, instead.
- */
-NAS *nas_find(uint32_t ipaddr)
-{
- NAS *nas;
- NAS *default_nas;
-
- default_nas = NULL;
-
- for (nas = naslist; nas; nas = nas->next) {
- if (ipaddr == nas->ipaddr)
- return nas;
- if (strcmp(nas->longname, "DEFAULT") == 0)
- default_nas = nas;
- }
-
- return default_nas;
-}