1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-05 22:43:24 +00:00
freebsd-ports/net/ascend-radius/files/patch-ag
Steve Price ead4ead456 Update to the June 18, 1998 version.
PR:		4405
Submitted by:	Yukihiro Nakai <nakai@TokyoNet.AD.JP>
1999-01-04 04:56:48 +00:00

104 lines
2.4 KiB
Plaintext

--- builddbm.c.orig Tue Jun 2 09:32:29 1998
+++ builddbm.c Thu Dec 3 13:18:30 1998
@@ -32,6 +32,10 @@
static char sccsid[] =
"@(#)builddbm.c 1.4 Copyright 1992 Livingston Enterprises Inc";
+#if defined(_HAVE_PARAM_H)
+#include <sys/param.h>
+#endif
+
#if defined(SOLARIS)
# include <sys/uio.h>
# include <unistd.h>
@@ -39,7 +43,11 @@
# include <fcntl.h>
# include </usr/ucbinclude/dbm.h>
#else
+#if defined(USE_NDBM)
+# include <ndbm.h>
+#else
# include <dbm.h>
+#endif
#endif /* SOLARIS */
#include <sys/types.h>
@@ -61,8 +69,13 @@
char *progname;
char *radius_dir;
char *radius_users;
+#if defined(USE_NDBM)
+char dbfile[256];
+DBM *dbp;
+#else
char pagfile[256];
char dirfile[256];
+#endif
char dbmname[256];
FILE *userfp;
FILE *errf;
@@ -126,6 +139,20 @@
}
}
+#if defined(USE_NDBM)
+ sprintf(dbfile, "%s/%s.db", radius_dir, radius_users);
+ if((fd = open(dbfile, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) {
+ fprintf(errf, "%s: Couldn't open %s for writing\n",
+ progname, dbfile);
+ exit(-1);
+ }
+ close(fd);
+ sprintf(dbmname, "%s/%s", radius_dir, radius_users);
+ if(!(dbp=dbm_open(dbmname, O_RDWR | O_CREAT | O_TRUNC, 0600))) {
+ fprintf(errf, "%s: Couldn't dbm_open(%s)\n",
+ progname, dbmname);
+ }
+#else
sprintf(pagfile, "%s/%s.pag", radius_dir, radius_users);
if((fd = open(pagfile, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) {
fprintf(errf, "%s: Couldn't open %s for writing\n",
@@ -145,7 +172,7 @@
fprintf(errf, "%s: Couldn't dbminit(%s)\n", progname, dbmname);
exit(-1);
}
-
+#endif
userfp = (FILE *)NULL;
curParseLine = 0;
while(user_read(&userfp, name, content) == 0) {
@@ -155,7 +182,11 @@
}
named.dptr = name;
named.dsize = strlen(name)+1;
+#if defined(USE_NDBM)
+ contentd = dbm_fetch(dbp,named);
+#else
contentd = fetch(named);
+#endif
if(contentd.dsize != 0) { /* name found */
warn("Skipping duplicate record\n\tfor user '%s'", name);
continue;
@@ -164,13 +195,21 @@
named.dsize = strlen(name)+1;
contentd.dptr = content;
contentd.dsize = strlen(content)+1;
+#if defined(USE_NDBM)
+ if(dbm_store(dbp, named, contentd, DBM_INSERT) < 0) {
+#else
if(store(named, contentd) != 0) {
+#endif
fprintf(errf, "%s: Couldn't store datum for %s\n",
progname, name);
exit(-1);
}
}
+#if defined(USE_NDBM)
+ dbm_close(dbp);
+#else
dbmclose();
+#endif
exit(0);
}