Re: Radius querying utility?

John Capo (jc@irbs.com)
Thu, 21 Sep 1995 11:52:01 -0400 (EDT)

Chris Woods writes:
>
> On Wed, 20 Sep 1995, Dick St.Peters wrote:
>
> > Is there a utility/tool for querying radius daemons ?
> >
> > I'm having trouble getting radiusd.dbm to work. Running it live and
> > having users not able to get in is getting old real fast ...
>
> Ditto, ditto ditto! I am about to embark on the radius.dbm journey, but
> cannot afford to do this on the main radius server and have users unable
> to login.
>
> There are other reasons why a radius "client" would be nice, too...
>

I have one. I intend to flesh it out quite a bit but no time right
now. It only works with "UNIX" passwords at this time. It uses
the secret from the clients file for authorization and must be run
as root. It grabs the first line in the secrets file so that one
must be for the machine you run this on.

Suggestions for enhancements and bug fixes gladly accepted.

Around line 1031 in radiusd.c you will find:

if(strcmp(check_item->strvalue, "UNIX") == 0) {
if(unix_pass(namepair->strvalue,
string) != 0) {
result = -1;
user_msg = (char *)NULL;
}
}

Add this code:

if(strcmp(check_item->strvalue, "UNIX") == 0) {
if(strcmp(string, authreq->secret) != 0) {
if(unix_pass(namepair->strvalue,
string) != 0) {
result = -1;
user_msg = (char *)NULL;
}
}
}

Sorry but I can't generate a usable patch.

I have been calling this thing auth and the code is below. It is
derived from radpass.c.

Add these lines to your Makefile in the appropriate places and make
auth should work.

AUTH_OBJS = auth.o dict.o md5.o attrprint.o util.o

auth: $(AUTH_OBJS)
$(CC) -o $@ $(AUTH_OBJS)

After auth.c you will find my ndbm patches to radius-1.16. If you
don't have radius working with dbm, you may want to start with these.
There is a bug in buildbm.c that must be fixed for gdbm or ndbm to work.
Look at 139,145 in the patches below.

John Capo
IRBS Engineering

------------------ auth.c -------------------
/*
*
* RADIUS
* Remote Authentication Dial In User Service
*
*
* Livingston Enterprises, Inc.
* 6920 Koll Center Parkway
* Pleasanton, CA 94566
*
* Copyright 1992 Livingston Enterprises, Inc.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose and without fee is hereby granted, provided that this
* copyright and permission notice appear on all copies and supporting
* documentation, the name of Livingston Enterprises, Inc. not be used
* in advertising or publicity pertaining to distribution of the
* program without specific prior permission, and notice be given
* in supporting documentation that copying and distribution is by
* permission of Livingston Enterprises, Inc.
*
* Livingston Enterprises, Inc. makes no representations about
* the suitability of this software for any purpose. It is
* provided "as is" without express or implied warranty.
*
*/

static char sccsid[] =
"@(#)radpass.c 1.5 Copyright 1992 Livingston Enterprises Inc";

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

#include <stdio.h>
#include <unistd.h>
#include <netdb.h>
#include <pwd.h>

#include "radius.h"

#define MAXPWNAM 8
#define MAXPASS 16

u_char recv_buffer[4096];
u_char send_buffer[4096];
u_char *progname;
int sockfd;
u_char vector[AUTH_VECTOR_LEN];
u_char password[AUTH_PASS_LEN];
u_char secret[AUTH_PASS_LEN];
char *radius_dir = RADIUS_DIR;

void
debug_pair(fd, pair)
FILE *fd;
VALUE_PAIR *pair;
{
fputs(" ", fd);
fprint_attr_val(fd, pair);
fputs("\n", fd);
}

void
result_recv(host, udp_port, buffer, length)
UINT4 host;
u_short udp_port;
u_char *buffer;
int length;
{
AUTH_HDR *auth;
int totallen;
char *ip_hostname();
u_char reply_digest[AUTH_VECTOR_LEN];
u_char calc_digest[AUTH_VECTOR_LEN];
int secretlen;
u_char *ptr;
VALUE_PAIR *prev;
VALUE_PAIR *pair;
VALUE_PAIR *first_pair;
int attribute;
int attrlen;
DICT_ATTR *attr;
DICT_ATTR *dict_attrget();
char string[64];
UINT4 lvalue;
char *ip_hostname();

dict_init();

auth = (AUTH_HDR *)buffer;
totallen = ntohs(auth->length);
length = totallen;

/* Verify the reply digest */
memcpy(reply_digest, auth->vector, AUTH_VECTOR_LEN);
memcpy(auth->vector, vector, AUTH_VECTOR_LEN);
secretlen = strlen(secret);
memcpy(buffer + totallen, secret, secretlen);
md5_calc(calc_digest, (char *)auth, totallen + secretlen);

if(memcmp(reply_digest, calc_digest, AUTH_VECTOR_LEN) != 0) {
printf("Warning: Received invalid reply digest from server\n");
return;
}

if(auth->code != PW_AUTHENTICATION_ACK) {
printf("Request Denied\n");
return;
}

/*
* Extract attribute-value pairs
*/
ptr = auth->data;
length -= AUTH_HDR_LEN;
first_pair = (VALUE_PAIR *)NULL;
prev = (VALUE_PAIR *)NULL;

while(length > 0) {

attribute = *ptr++;
attrlen = *ptr++;
if(attrlen < 2) {
length = 0;
continue;
}
attrlen -= 2;
if((attr = dict_attrget(attribute)) == (DICT_ATTR *)NULL) {
printf("Received unknown attribute %d\n", attribute);
}
else if ( attrlen >= AUTH_STRING_LEN ) {
printf("attribute %d too long, %d >= %d\n", attribute,
attrlen, AUTH_STRING_LEN);
}
else {
if((pair = (VALUE_PAIR *)malloc(sizeof(VALUE_PAIR))) ==
(VALUE_PAIR *)NULL) {
fprintf(stderr, "%s: no memory\n",
progname);
exit(-1);
}
strcpy(pair->name, attr->name);
pair->attribute = attr->value;
pair->type = attr->type;
pair->next = (VALUE_PAIR *)NULL;

switch(attr->type) {

case PW_TYPE_STRING:
memcpy(pair->strvalue, ptr, attrlen);
pair->strvalue[attrlen] = '\0';
debug_pair(stdout, pair);
if(first_pair == (VALUE_PAIR *)NULL) {
first_pair = pair;
}
else {
prev->next = pair;
}
prev = pair;
break;

case PW_TYPE_INTEGER:
case PW_TYPE_IPADDR:
memcpy(&lvalue, ptr, sizeof(UINT4));
pair->lvalue = ntohl(lvalue);
debug_pair(stdout, pair);
if(first_pair == (VALUE_PAIR *)NULL) {
first_pair = pair;
}
else {
prev->next = pair;
}
prev = pair;
break;

default:
printf(" %s (Unknown Type %d)\n", attr->name,attr->type);
free(pair);
break;
}

}
ptr += attrlen;
length -= attrlen + 2;
}
}
main(argc, argv)
int argc;
u_char *argv[];
{
int salen;
int result;
struct sockaddr salocal;
struct sockaddr saremote;
struct sockaddr_in *sin;
struct servent *svp;
u_short svc_port;
AUTH_HDR *auth;
u_char *username;
u_char passbuf[AUTH_PASS_LEN];
u_char md5buf[256];
UINT4 get_ipaddr();
UINT4 auth_ipaddr;
u_short local_port;
int total_length;
u_char *ptr;
int length;
int secretlen;
int i;
char *getpass();
FILE *clientfd;
u_char buffer[128];
u_char secret_buffer[64];
char hostnm[256];
UINT4 ipaddr;
UINT4 this_ipaddr;
UINT4 get_ipaddr();

progname = argv[0];

if(argc != 2) {
usage();
}

gethostname(buffer, sizeof (buffer));
this_ipaddr = get_ipaddr(buffer);

/* Find this client in the database */
sprintf(buffer, "%s/%s", radius_dir, RADIUS_CLIENTS);
if((clientfd = fopen(buffer, "r")) == (FILE *)NULL) {
fprintf(stderr, "%s: couldn't open %s to find clients\n",
progname, buffer);
return(-1);
}
ipaddr = (UINT4)0;
while(fgets(buffer, sizeof(buffer), clientfd) != (char *)NULL) {
if(*buffer == '#') {
continue;
}
if(sscanf(buffer, "%s%s", hostnm, secret_buffer) != 2) {
continue;
}
ipaddr = get_ipaddr(hostnm);
if(ipaddr ==this_ipaddr) {
break;
}
}
fclose(clientfd);
memset(buffer, 0, sizeof(buffer));

/* Get the user name */
username = argv[1];

svp = getservbyname ("radius", "udp");
if (svp == (struct servent *) 0) {
fprintf (stderr, "No such service: %s/%s\n", "radius", "udp");
exit(-1);
}
svc_port = ntohs((u_short) svp->s_port);

/* Get the IP address of the authentication server */
if((auth_ipaddr = get_ipaddr("radius-server")) == (UINT4)0) {
fprintf(stderr, "Couldn't find host radius-server\n");
exit(-1);
}

sockfd = socket (AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0) {
(void) perror ("socket");
exit(-1);
}

sin = (struct sockaddr_in *) & salocal;
memset ((char *) sin, '\0', sizeof (salocal));
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = INADDR_ANY;

local_port = 1025;
do {
local_port++;
sin->sin_port = htons((u_short)local_port);
} while((bind(sockfd, &salocal, sizeof (struct sockaddr_in)) < 0) &&
local_port < 64000);
if(local_port >= 64000) {
close(sockfd);
(void) perror ("bind");
exit(-1);
}

strncpy(password, secret_buffer, AUTH_PASS_LEN);
strncpy(secret, secret_buffer, AUTH_PASS_LEN);

/* Build a password change request */

auth = (AUTH_HDR *)send_buffer;
auth->code = PW_AUTHENTICATION_REQUEST;
auth->id = getpid();
random_vector(vector);
memcpy(auth->vector, vector, AUTH_VECTOR_LEN);
total_length = AUTH_HDR_LEN;
ptr = auth->data;

/* User Name */
*ptr++ = PW_USER_NAME;
length = strlen(username);
if(length > MAXPWNAM) {
length = MAXPWNAM;
}
*ptr++ = length + 2;
memcpy(ptr, username, length);
ptr += length;
total_length += length + 2;

/* New Password */
*ptr++ = PW_PASSWORD;
*ptr++ = AUTH_PASS_LEN + 2;

/* Encrypt the Password */
length = strlen(password);
if(length > MAXPASS) {
length = MAXPASS;
}
memset(passbuf, 0, AUTH_PASS_LEN);
memcpy(passbuf, password, length);
/* Calculate the MD5 Digest */
secretlen = strlen(secret);
strcpy(md5buf, secret);
memcpy(md5buf + secretlen, auth->vector, AUTH_VECTOR_LEN);
md5_calc(ptr, md5buf, secretlen + AUTH_VECTOR_LEN);
/* Xor the password into the MD5 digest */
for(i = 0;i < AUTH_PASS_LEN;i++) {
*ptr++ ^= passbuf[i];
}
total_length += AUTH_PASS_LEN + 2;
auth->length = htonl(total_length);

sin = (struct sockaddr_in *) & saremote;
memset ((char *) sin, '\0', sizeof (saremote));
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = htonl(auth_ipaddr);
sin->sin_port = htons(svc_port);

sendto(sockfd, (char *)auth, (int)total_length, (int)0,
&saremote, sizeof(struct sockaddr_in));

salen = sizeof (saremote);
result = recvfrom (sockfd, (char *) recv_buffer,
(int) sizeof(recv_buffer),
(int) 0, & saremote, & salen);

if(result > 0) {
result_recv(sin->sin_addr.s_addr,
sin->sin_port, recv_buffer, result);
exit(0);
}
(void) perror ("recv");
close(sockfd);
exit(0);
}

usage()
{
printf("Usage: %s username\n", progname);
exit(-1);
}

random_vector(vector)
u_char *vector;
{
int randno;
int i;

srand(time(0));
for(i = 0;i < AUTH_VECTOR_LEN;) {
randno = rand();
memcpy(vector, &randno, sizeof(int));
vector += sizeof(int);
i += sizeof(int);
}
}
------------------ end auth.c -------------------

These patches are against a fresh copy of radius-1.16.

A few things about the DBM implementation. The password change
mechanism does not know about DBM. The radpass program will talk
to radiusd and radiusd will change the password in the users file
rather than the DBM file. The DBM file has to be rebuilt for the
new password to be seen.

The ndbm routines do not have a file.dir and file.pag, they generate
a file.db instead.

There is no locking mechanism. Rebuilding the DBM file while
radiusd is accessing will probably cause the radiusd lookup to fail
or even core.

The builddbm program expects to find the users file in "." so you
must be in /etc/raddb when you build the DBM file.

I used to have a set of sources that took care of locking and dealt
with password changes correctly. Its a long story... :-(

John Capo
IRBS Engineering

diff -rc ../radius-1.16/src/Makefile ./src/Makefile
*** ../radius-1.16/src/Makefile Tue Dec 27 12:32:28 1994
--- ./src/Makefile Mon Sep 18 16:38:24 1995
***************
*** 17,23 ****
CFLAGS= -O -DNOSHADOW
LDFLAGS=
CC= cc
! LIBS=
SERVER_OBJS=radiusd.o dict.o users.o util.o md5.o attrprint.o acct.o version.o
SERVERDBM_OBJS=radiusd.o dict.o usersdbm.o util.o md5.o attrprint.o acct.o versiondbm.o
SERVER_SRCS=radiusd.c dict.c users.c util.c md5.c attrprint.c acct.c version.c
--- 17,23 ----
CFLAGS= -O -DNOSHADOW
LDFLAGS=
CC= cc
! LIBS= -lcrypt
SERVER_OBJS=radiusd.o dict.o users.o util.o md5.o attrprint.o acct.o version.o
SERVERDBM_OBJS=radiusd.o dict.o usersdbm.o util.o md5.o attrprint.o acct.o versiondbm.o
SERVER_SRCS=radiusd.c dict.c users.c util.c md5.c attrprint.c acct.c version.c
***************
*** 31,37 ****
$(CC) $(CFLAGS) -o radiusd $(SERVER_OBJS) $(LIBS)

radiusd.dbm: $(SERVERDBM_OBJS)
! $(CC) $(CFLAGS) -o radiusd.dbm $(SERVERDBM_OBJS) -ldbm $(LIBS)

radiusd.o: $(SRCDIR)/radiusd.c $(INCLUDES)
$(CC) $(CFLAGS) -c $(SRCDIR)/radiusd.c
--- 31,37 ----
$(CC) $(CFLAGS) -o radiusd $(SERVER_OBJS) $(LIBS)

radiusd.dbm: $(SERVERDBM_OBJS)
! $(CC) $(CFLAGS) -o radiusd.dbm $(SERVERDBM_OBJS) $(LIBS)

radiusd.o: $(SRCDIR)/radiusd.c $(INCLUDES)
$(CC) $(CFLAGS) -c $(SRCDIR)/radiusd.c
***************
*** 49,55 ****
$(CC) $(CFLAGS) -c $(SRCDIR)/users.c

usersdbm.o: $(SRCDIR)/users.c $(INCLUDES)
! $(CC) $(CFLAGS) -DDBM -o usersdbm.o -c $(SRCDIR)/users.c

util.o: $(SRCDIR)/util.c $(INCLUDES)
$(CC) $(CFLAGS) -c $(SRCDIR)/util.c
--- 49,55 ----
$(CC) $(CFLAGS) -c $(SRCDIR)/users.c

usersdbm.o: $(SRCDIR)/users.c $(INCLUDES)
! $(CC) $(CFLAGS) -DUSE_DBM -o usersdbm.o -c $(SRCDIR)/users.c

util.o: $(SRCDIR)/util.c $(INCLUDES)
$(CC) $(CFLAGS) -c $(SRCDIR)/util.c
***************
*** 58,64 ****
$(CC) $(CFLAGS) -o version.o -c $(SRCDIR)/version.c

versiondbm.o: $(SRCDIR)/version.c $(INCLUDES)
! $(CC) $(CFLAGS) -DDBM -o versiondbm.o -c $(SRCDIR)/version.c

radpass: radpass.o md5.o util.o
$(CC) $(CFLAGS) -o radpass radpass.o md5.o util.o $(LIBS)
--- 58,64 ----
$(CC) $(CFLAGS) -o version.o -c $(SRCDIR)/version.c

versiondbm.o: $(SRCDIR)/version.c $(INCLUDES)
! $(CC) $(CFLAGS) -DUSE_DBM -o versiondbm.o -c $(SRCDIR)/version.c

radpass: radpass.o md5.o util.o
$(CC) $(CFLAGS) -o radpass radpass.o md5.o util.o $(LIBS)
***************
*** 70,76 ****
$(CC) $(CFLAGS) -c $(SRCDIR)/md5.c

builddbm: builddbm.o
! $(CC) $(CFLAGS) -o builddbm builddbm.o -ldbm $(LIBS)

builddbm.o: $(SRCDIR)/builddbm.c
$(CC) $(CFLAGS) -c $(SRCDIR)/builddbm.c
--- 70,76 ----
$(CC) $(CFLAGS) -c $(SRCDIR)/md5.c

builddbm: builddbm.o
! $(CC) $(CFLAGS) -o builddbm builddbm.o $(LIBS)

builddbm.o: $(SRCDIR)/builddbm.c
$(CC) $(CFLAGS) -c $(SRCDIR)/builddbm.c
diff -rc ../radius-1.16/src/builddbm.c ./src/builddbm.c
*** ../radius-1.16/src/builddbm.c Tue Dec 27 12:32:29 1994
--- ./src/builddbm.c Mon Sep 18 16:37:44 1995
***************
*** 40,46 ****
#include <pwd.h>
#include <time.h>
#include <ctype.h>
! #include <dbm.h>

#include "radius.h"

--- 40,47 ----
#include <pwd.h>
#include <time.h>
#include <ctype.h>
! #include <fcntl.h>
! #include <ndbm.h>

#include "radius.h"

***************
*** 65,85 ****
int fd;
datum named;
datum contentd;

progname = *argv;

- if((fd = open("users.pag", O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) {
- fprintf(stderr, "%s: Couldn't open users.pag for writing\n",progname);
- exit(-1);
- }
- close(fd);
- if((fd = open("users.dir", O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) {
- fprintf(stderr, "%s: Couldn't open users.dir for writing\n",progname);
- exit(-1);
- }
- close(fd);
radius_dir = ".";
! if(dbminit("users") != 0) {
fprintf(stderr, "%: Couldn't init dbm\n",progname);
exit(-1);
}
--- 66,77 ----
int fd;
datum named;
datum contentd;
+ DBM *db;

progname = *argv;

radius_dir = ".";
! if((db = dbm_open("users", O_RDWR | O_CREAT | O_TRUNC, 0600)) == 0) {
fprintf(stderr, "%: Couldn't init dbm\n",progname);
exit(-1);
}
***************
*** 89,101 ****
named.dsize = strlen(name);
contentd.dptr = content;
contentd.dsize = strlen(content);
! if(store(named, contentd) != 0) {
fprintf(stderr, "%s: Couldn't store datum for %s\n",
progname,name);
exit(-1);
}
}
! dbmclose();
exit(0);
}

--- 81,93 ----
named.dsize = strlen(name);
contentd.dptr = content;
contentd.dsize = strlen(content);
! if(dbm_store(db, named, contentd, DBM_INSERT) != 0) {
fprintf(stderr, "%s: Couldn't store datum for %s\n",
progname,name);
exit(-1);
}
}
! dbm_close(db);
exit(0);
}

***************
*** 139,145 ****
/*
* Find the entry starting with the users name
*/
! if(*buffer != '#' && *buffer != '\t') {
ptr = buffer;
while(*ptr != ' ' && *ptr != '\t' &&
*ptr != '\0') {
--- 131,137 ----
/*
* Find the entry starting with the users name
*/
! if(*buffer != '#' && *buffer != '\t' && *buffer != '\n') {
ptr = buffer;
while(*ptr != ' ' && *ptr != '\t' &&
*ptr != '\0') {
diff -rc ../radius-1.16/src/conf.h ./src/conf.h
*** ../radius-1.16/src/conf.h Tue Dec 27 12:32:29 1994
--- ./src/conf.h Mon Sep 18 16:39:32 1995
***************
*** 45,51 ****
--- 45,53 ----
#include <machine/inline.h>
#include <machine/endian.h>
#else /* bsdi */
+ #ifndef __FreeBSD__
#include <malloc.h>
+ #endif
#endif /* bsdi */

#if defined(aix)
Only in ./src: holdusers
Only in ./src: logfile
diff -rc ../radius-1.16/src/radiusd.c ./src/radiusd.c
*** ../radius-1.16/src/radiusd.c Fri Jan 6 16:58:16 1995
--- ./src/radiusd.c Mon Sep 18 16:41:44 1995
***************
*** 1426,1432 ****
encrypted_pass = pwd->pw_passwd;

#if !defined(NOSHADOW)
! if(strcmp(pwd->pw_passwd, "x") == 0) {
if((spwd = getspnam(name)) == NULL) {
return(-1);
}
--- 1426,1433 ----
encrypted_pass = pwd->pw_passwd;

#if !defined(NOSHADOW)
! if((strcmp(pwd->pw_passwd, "x") == 0) ||
! (strcmp(pwd->pw_passwd, "*") == 0)) {
if((spwd = getspnam(name)) == NULL) {
return(-1);
}
Only in ./src: radiusd.c.auth
diff -rc ../radius-1.16/src/users.c ./src/users.c
*** ../radius-1.16/src/users.c Fri Jan 6 16:58:16 1995
--- ./src/users.c Mon Sep 18 15:10:08 1995
***************
*** 39,49 ****
#include <time.h>
#include <ctype.h>

! #ifdef DBM

! #include <dbm.h>

! #endif /* DBM */

#include "radius.h"

--- 39,50 ----
#include <time.h>
#include <ctype.h>

! #ifdef USE_DBM

! #include <ndbm.h>
! #include <fcntl.h>

! #endif /* USE_DBM */

#include "radius.h"

***************
*** 82,91 ****
int mode;
VALUE_PAIR *check_first;
VALUE_PAIR *reply_first;
! #ifdef DBM
datum named;
datum contentd;
! #endif /* DBM */

/*
* Check for valid input, zero length names not permitted
--- 83,93 ----
int mode;
VALUE_PAIR *check_first;
VALUE_PAIR *reply_first;
! #ifdef USE_DBM
datum named;
datum contentd;
! DB *db;
! #endif /* USE_DBM */

/*
* Check for valid input, zero length names not permitted
***************
*** 114,124 ****
* Open the user table
*/
sprintf(buffer, "%s/%s", radius_dir, RADIUS_USERS);
! #ifdef DBM
! if(dbminit(buffer) != 0) {
! #else /* DBM */
if((userfd = fopen(buffer, "r")) == (FILE *)NULL) {
! #endif /* DBM */
fprintf(stderr, "%s:Couldn't open %s for reading\n",
progname, buffer);
return(-1);
--- 116,126 ----
* Open the user table
*/
sprintf(buffer, "%s/%s", radius_dir, RADIUS_USERS);
! #ifdef USE_DBM
! if((db = dbm_open(buffer, O_RDONLY, 0)) == 0) {
! #else /* USE_DBM */
if((userfd = fopen(buffer, "r")) == (FILE *)NULL) {
! #endif /* USE_DBM */
fprintf(stderr, "%s:Couldn't open %s for reading\n",
progname, buffer);
return(-1);
***************
*** 128,144 ****
reply_first = (VALUE_PAIR *)NULL;


! #ifdef DBM
named.dptr = name;
named.dsize = strlen(name);
! contentd = fetch(named);

if(contentd.dsize == 0) {
named.dptr = "DEFAULT";
named.dsize = strlen("DEFAULT");
! contentd = fetch(named);
if(contentd.dsize == 0) {
! dbmclose();
return(-1);
}
}
--- 130,146 ----
reply_first = (VALUE_PAIR *)NULL;


! #ifdef USE_DBM
named.dptr = name;
named.dsize = strlen(name);
! contentd = dbm_fetch(db, named);

if(contentd.dsize == 0) {
named.dptr = "DEFAULT";
named.dsize = strlen("DEFAULT");
! contentd = dbm_fetch(db, named);
if(contentd.dsize == 0) {
! dbm_close(db);
return(-1);
}
}
***************
*** 155,161 ****
fprintf(stderr, msg);
log_err(msg);
pairfree(check_first);
! dbmclose();
return(-1);
}
while(*ptr != '\n' && *ptr != '\0') {
--- 157,163 ----
fprintf(stderr, msg);
log_err(msg);
pairfree(check_first);
! dbm_close(db);
return(-1);
}
while(*ptr != '\n' && *ptr != '\0') {
***************
*** 163,169 ****
}
if(*ptr != '\n') {
pairfree(check_first);
! dbmclose();
return(-1);
}
ptr++;
--- 165,171 ----
}
if(*ptr != '\n') {
pairfree(check_first);
! dbm_close(db);
return(-1);
}
ptr++;
***************
*** 175,186 ****
progname, name);
pairfree(check_first);
pairfree(reply_first);
! dbmclose();
return(-1);
}
! dbmclose();

! #else /* DBM */

while(fgets(buffer, sizeof(buffer), userfd) != (char *)NULL) {
if(mode == FIND_MODE_NAME) {
--- 177,188 ----
progname, name);
pairfree(check_first);
pairfree(reply_first);
! dbm_close(db);
return(-1);
}
! dbm_close(db);

! #else /* USE_DBM */

while(fgets(buffer, sizeof(buffer), userfd) != (char *)NULL) {
if(mode == FIND_MODE_NAME) {
***************
*** 236,242 ****
}
}
fclose(userfd);
! #endif /* DBM */

/* Update the callers pointers */
if(reply_first != (VALUE_PAIR *)NULL) {
--- 238,244 ----
}
}
fclose(userfd);
! #endif /* USE_DBM */

/* Update the callers pointers */
if(reply_first != (VALUE_PAIR *)NULL) {
diff -rc ../radius-1.16/src/version.c ./src/version.c
*** ../radius-1.16/src/version.c Fri Jan 6 16:58:16 1995
--- ./src/version.c Mon Sep 18 14:26:28 1995
***************
*** 55,61 ****
fprintf(stderr, "%s: RADIUS version %s\n", progname, VERSION);

/* here are all the conditional feature flags */
! #if defined(DBM)
fprintf(stderr," DBM");
#endif
#if defined(NOSHADOW)
--- 55,61 ----
fprintf(stderr, "%s: RADIUS version %s\n", progname, VERSION);

/* here are all the conditional feature flags */
! #if defined(USE_DBM)
fprintf(stderr," DBM");
#endif
#if defined(NOSHADOW)