summaryrefslogtreecommitdiff
path: root/net/ascend-radius/files/patch-ag
blob: 88679b3feafe98c2c779efa73000d35d25fe6c12 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
--- 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);
 }