From ed023aafdae707bcd675f27813ca33f5ad1c23ba Mon Sep 17 00:00:00 2001 From: Paul Park Date: Fri, 30 Jun 1995 20:11:46 +0000 Subject: [PATCH] Add ability to switch between Berkeley and DBM for both aname and KDC database git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6204 dc483132-0cff-0310-8789-dd5450dbe970 --- src/admin/aname/ChangeLog | 8 ++++++++ src/admin/aname/Makefile.in | 3 ++- src/admin/aname/configure.in | 36 ++++++++++++++++++++++++++++++++++-- src/admin/aname/kdb5_anadd.c | 35 +++++++++++++++++++++++++++++------ 4 files changed, 73 insertions(+), 9 deletions(-) diff --git a/src/admin/aname/ChangeLog b/src/admin/aname/ChangeLog index fdfbfc1a3..a8239d450 100644 --- a/src/admin/aname/ChangeLog +++ b/src/admin/aname/ChangeLog @@ -1,4 +1,12 @@ +Fri Jun 30 14:28:20 EDT 1995 Paul Park (pjpark@mit.edu) + * kdb5_anadd.c - Add ability to select between Berkeley and DBM format + at compile time. + * configure.in - Add --with-dbm and --with-aname-dbm and check/set + appropriate definitions and libraries. + * Makefile.in - Use DBFLAGS set by configure.in. + + Thu Jun 15 15:22:33 EDT 1995 Paul Park (pjpark@mit.edu) * Makefile.in - Change explicit library names to -l form, and change target link line to use $(LD) and associated flags. diff --git a/src/admin/aname/Makefile.in b/src/admin/aname/Makefile.in index cb607a927..7e25cbf78 100644 --- a/src/admin/aname/Makefile.in +++ b/src/admin/aname/Makefile.in @@ -1,4 +1,5 @@ -CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE) +DBFLAGS=@DBFLAGS@ +CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE) $(DBFLAGS) LDFLAGS = -g COMERRLIB=$(BUILDTOP)/util/et/libcom_err.a diff --git a/src/admin/aname/configure.in b/src/admin/aname/configure.in index 630bb2361..6164b5784 100644 --- a/src/admin/aname/configure.in +++ b/src/admin/aname/configure.in @@ -1,7 +1,39 @@ AC_INIT(kdb5_anadd.c) CONFIG_RULES AC_PROG_INSTALL -AC_CHECK_LIB(ndbm,main) -AC_CHECK_LIB(dbm,main) +AC_ARG_WITH([aname-dbm], +[ --with-aname-dbm use native dbm for aname_to_lname database + --without-aname-dbm use included version of Berkeley db (default)], +, +withval=no)dnl +did_dbm_lib=no +if test "$withval" = yes; then + AC_MSG_RESULT(Using native dbm for aname_to_lname database) + DBFLAGS= + AC_CHECK_LIB(ndbm,main) + AC_CHECK_LIB(dbm,main) + did_dbm_lib=yes +else + AC_MSG_RESULT(Using Berkeley db for aname_to_lname database) + DBFLAGS=-DBERK_DB_DBM +fi +AC_SUBST(DBFLAGS)dnl +dnl +AC_ARG_WITH([dbm], +[ --with-dbm use native dbm for kdc database + --without-dbm use included version of Berkeley db (default)], +, +withval=no)dnl +if test "$withval" = yes; then + AC_MSG_RESULT(Using native dbm) + if test "$did_dbm_lib" = no; then + AC_CHECK_LIB(ndbm,main) + AC_CHECK_LIB(dbm,main) + fi +else + AC_MSG_RESULT(Using Berkeley db) +fi +AC_SUBST(DBFLAGS)dnl +dnl V5_USE_SHARED_LIB V5_AC_OUTPUT_MAKEFILE diff --git a/src/admin/aname/kdb5_anadd.c b/src/admin/aname/kdb5_anadd.c index 2849abc97..4a841ecf9 100644 --- a/src/admin/aname/kdb5_anadd.c +++ b/src/admin/aname/kdb5_anadd.c @@ -30,6 +30,29 @@ #include #include +#ifdef BERK_DB_DBM +/* + * Use Berkeley database code. + */ +extern DBM *db_dbm_open PROTOTYPE((char *, int, int)); +extern void db_dbm_close PROTOTYPE((DBM *)); +extern int db_dbm_delete PROTOTYPE((DBM *, datum)); +extern int db_dbm_store PROTOTYPE((DBM *, datum, datum, int)); + +#define KDBM_OPEN(db, fl, mo) db_dbm_open(db, fl, mo) +#define KDBM_CLOSE(db) db_dbm_close(db) +#define KDBM_DELETE(db, key) db_dbm_delete(db, key) +#define KDBM_STORE(db,key,c,f) db_dbm_store(db, key, c, f) +#else /* BERK_DB_DBM */ +/* + * Use stock DBM code. + */ +#define KDBM_OPEN(db, fl, mo) dbm_open(db, fl, mo) +#define KDBM_CLOSE(db) dbm_close(db) +#define KDBM_DELETE(db, key) dbm_delete(db, key) +#define KDBM_STORE(db,key,c,f) dbm_store(db, key, c, f) +#endif /* BERK_DB_DBM */ + extern int errno; void @@ -97,7 +120,7 @@ char *argv[]; pname = argv[optind]; lname = argv[optind+1]; - if (!(db = dbm_open(andbname, O_RDWR|O_CREAT, 0644))) { + if (!(db = KDBM_OPEN(andbname, O_RDWR|O_CREAT, 0644))) { com_err(argv[0], errno, "while opening/creating %s", andbname); exit(1); @@ -106,22 +129,22 @@ char *argv[]; key.dsize = strlen(pname)+1; /* include the null */ if (del) { - if (dbm_delete(db, key)) { + if (KDBM_DELETE(db, key)) { com_err(argv[0], 0, "No such entry while deleting %s from %s", pname, andbname); - dbm_close(db); + KDBM_CLOSE(db); exit(1); } } else if (add) { contents.dptr = lname; contents.dsize = strlen(lname)+1; - if (dbm_store(db, key, contents, DBM_REPLACE)) { + if (KDBM_STORE(db, key, contents, DBM_REPLACE)) { com_err(argv[0], errno, "while inserting/replacing %s in %s", pname, andbname); - dbm_close(db); + KDBM_CLOSE(db); exit(1); } } - dbm_close(db); + KDBM_CLOSE(db); exit(0); } -- 2.26.2