Patch Name: nss_db-2.2-update-1.patch Submitted By: Randy McMurchy Date: 2004-05-15 Initial Package Version: 2.2 Upstream Status: N/A Origin: Randy McMurchy Description: Fixes building against Glibc-2.3.3 Updates DB calls to use Berkeley-DB-4.x Allows using --localstatedir to point db file location Requires running the following auto-tools before building: aclocal automake -a libtoolize -f autoconf diff -Naur nss_db-2.2-orig/INSTALL nss_db-2.2/INSTALL --- nss_db-2.2-orig/INSTALL 1999-01-24 20:59:16.000000000 +0000 +++ nss_db-2.2/INSTALL 2004-05-17 01:15:41.000000000 +0000 @@ -1,6 +1,39 @@ Basic Installation ================== +#################################################################### +Modifications made by Randy McMurchy : + +--localstatedir is used to create the database files (passwd.db, +group.db, etc.) in a desired location. The recommended location is +/var/lib/nss_db. If --localstatedir is not passed to the configure +command, then the default of /var/db is used. + +A Makefile will be installed in the --localstatedir directory. To +create the db files, issue the following command: + +make -f /localstatedir_path/Makefile + +Examples: + +make -f /var/lib/nss_db/Makefile +make -f /var/db/Makefile + +Update the db files at any time using the same command. + +The autotools included in the package are quite dated, and the package +won't build as is. Run the following commands to update the autotools: + + aclocal + automake -a + libtoolize -f + autoconf + +You may safely disregard any warnings producted by the above commands. + +End modification Note +#################################################################### + These are generic installation instructions. The `configure' shell script attempts to guess correct values for diff -Naur nss_db-2.2-orig/rellns-sh nss_db-2.2/rellns-sh --- nss_db-2.2-orig/rellns-sh 1999-12-18 23:40:25.000000000 +0000 +++ nss_db-2.2/rellns-sh 2004-05-16 18:39:42.000000000 +0000 @@ -71,4 +71,4 @@ from=`echo $from | sed 's%^[^/]*/*%%'` done -ln -s $rfrom$to $2 +ln -sf $rfrom$to $2 diff -Naur nss_db-2.2-orig/configure.in nss_db-2.2/configure.in --- nss_db-2.2-orig/configure.in 2000-11-10 00:56:04.000000000 +0000 +++ nss_db-2.2/configure.in 2004-05-16 22:58:46.000000000 +0000 @@ -94,6 +94,14 @@ slibdir='${libdir}' fi +echo '#define _PATH_VARDB "DBDIR"' >dbdir.h + +if test "$localstatedir" = '${prefix}/var'; then + sed -i -e "s@DBDIR@/var/db/@" dbdir.h +else + sed -i -e "s@DBDIR@${localstatedir}/@" dbdir.h +fi + AC_SUBST(DB_CFLAGS) AC_SUBST(DB_LIBS) AC_SUBST(slibdir) diff -Naur nss_db-2.2-orig/Makefile.am nss_db-2.2/Makefile.am --- nss_db-2.2-orig/Makefile.am 2000-08-15 14:18:16.000000000 +0000 +++ nss_db-2.2/Makefile.am 2004-05-17 00:44:12.000000000 +0000 @@ -14,7 +14,7 @@ noinst_HEADERS = db-compat.h netgroup.h nss_db.h -INCLUDES = @DB_CFLAGS@ -D_LIBC -D_GNU_SOURCE +INCLUDES = @DB_CFLAGS@ -D_GNU_SOURCE slib_LTLIBRARIES = libnss_db.la libnss_db_la_SOURCES = db-alias.c db-ethers.c db-netgrp.c db-grp.c db-proto.c \ @@ -30,18 +30,32 @@ makedb_SOURCES = makedb.c db-compat.c makedb_LDADD = @DB_LIBS@ + # To mimmick the old glibc installation as closely as possible, we # shuffle the installed library and the links to it around a bit, # removing all traces from libtool in the process. install-data-local: $(mkinstalldirs) $(DESTDIR)$(libdir) - rm $(DESTDIR)$(slibdir)/libnss_db.la - rm $(DESTDIR)$(slibdir)/libnss_db.so - mv $(DESTDIR)$(slibdir)/libnss_db.so.$(INTERFACE).0.0 \ - $(DESTDIR)$(slibdir)/libnss_db-$(VERSION).so - rm $(DESTDIR)$(slibdir)/libnss_db.so.$(INTERFACE) + if test -f $(DESTDIR)$(slibdir)/libnss_db.la; then \ + rm $(DESTDIR)$(slibdir)/libnss_db.la; fi + if test -f $(DESTDIR)$(slibdir)/libnss_db.so; then \ + rm $(DESTDIR)$(slibdir)/libnss_db.so; fi + if test -f $(DESTDIR)$(slibdir)/libnss_db.so.$(INTERFACE).0.0; then \ + mv $(DESTDIR)$(slibdir)/libnss_db.so.$(INTERFACE).0.0 \ + $(DESTDIR)$(slibdir)/libnss_db-$(VERSION).so; fi + if test -f $(DESTDIR)$(slibdir)/libnss_db.so.$(INTERFACE); then \ + rm $(DESTDIR)$(slibdir)/libnss_db.so.$(INTERFACE); fi $(srcdir)/rellns-sh $(DESTDIR)$(slibdir)/libnss_db-$(VERSION).so \ $(DESTDIR)$(slibdir)/libnss_db.so.$(INTERFACE) - rm -f $(DESTDIR)$(libdir)/libnss_db.so + if test -f $(DESTDIR)$(libdir)/libnss_db.so; then \ + rm -f $(DESTDIR)$(libdir)/libnss_db.so; fi $(srcdir)/rellns-sh $(DESTDIR)$(slibdir)/libnss_db.so.$(INTERFACE) \ $(DESTDIR)$(libdir)/libnss_db.so + cp db-Makefile db-Makefile.orig + if test "$(localstatedir)" = '$(prefix)/var'; then \ + install -m 644 -D db-Makefile /var/db/Makefile; \ + else \ + sed -i -e "s@/var/db@$(localstatedir)@" db-Makefile; \ + install -m 644 -D db-Makefile $(localstatedir)/Makefile; fi + cp db-Makefile.orig db-Makefile + diff -Naur nss_db-2.2-orig/db-compat.c nss_db-2.2/db-compat.c --- nss_db-2.2-orig/db-compat.c 2000-08-09 13:29:06.000000000 +0000 +++ nss_db-2.2/db-compat.c 2004-05-16 18:12:02.000000000 +0000 @@ -39,7 +39,11 @@ if (err) return err; +#if (DB_VERSION_MAJOR > 4) || ((DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR >= 1)) + err = db->open (db, NULL, file, NULL, type, flags, mode); +#else err = db->open (db, file, NULL, type, flags, mode); +#endif if (err) { db->close (db, 0); diff -Naur nss_db-2.2-orig/db-XXX.c nss_db-2.2/db-XXX.c --- nss_db-2.2-orig/db-XXX.c 2000-08-09 13:46:39.000000000 +0000 +++ nss_db-2.2/db-XXX.c 2004-05-16 21:49:34.000000000 +0000 @@ -24,7 +24,7 @@ #include #include -#include +#include "libc-lock.h" #include "nss_db.h" @@ -40,6 +40,10 @@ #define ENTNAME_r CONCAT(ENTNAME,_r) #include + +#undef _PATH_VARDB +#include "dbdir.h" + #define DBFILE _PATH_VARDB DATABASE ".db" #ifdef NEED_H_ERRNO diff -Naur nss_db-2.2-orig/db-alias.c nss_db-2.2/db-alias.c --- nss_db-2.2-orig/db-alias.c 2000-08-08 16:47:33.000000000 +0000 +++ nss_db-2.2/db-alias.c 2004-05-16 21:50:42.000000000 +0000 @@ -26,10 +26,13 @@ #include #include -#include +#include "libc-lock.h" #include "nss_db.h" +#undef _PATH_VARDB +#include "dbdir.h" + /* Locks the static variables in this file. */ __libc_lock_define_initialized (static, lock) diff -Naur nss_db-2.2-orig/db-netgrp.c nss_db-2.2/db-netgrp.c --- nss_db-2.2-orig/db-netgrp.c 2000-08-08 17:05:01.000000000 +0000 +++ nss_db-2.2/db-netgrp.c 2004-05-16 21:51:22.000000000 +0000 @@ -22,11 +22,13 @@ #include #include #include -#include +#include "libc-lock.h" #include #include "nss_db.h" +#undef _PATH_VARDB +#include "dbdir.h" #define DBFILE _PATH_VARDB "netgroup.db" diff -Naur nss_db-2.2-orig/db-open.c nss_db-2.2/db-open.c --- nss_db-2.2-orig/db-open.c 2000-08-09 13:54:14.000000000 +0000 +++ nss_db-2.2/db-open.c 2004-05-17 03:32:59.000000000 +0000 @@ -26,6 +26,10 @@ #include "nss_db.h" +#ifndef __set_errno +#define __set_errno(x) errno = x +#endif + /* Set the `FD_CLOEXEC' flag of FD. Return 0 on success, or -1 on error with `errno' set. */ static int diff -Naur /dev/null nss_db-2.2/libc-lock.h --- /dev/null 2004-03-14 09:49:25.000000000 +0000 +++ nss_db-2.2/libc-lock.h 2004-05-17 01:33:41.000000000 +0000 @@ -0,0 +1,44 @@ +/* libc-internal interface for mutex locks. LinuxThreads version. + Adapted for nss_db. + Copyright (C) 1996,1997,1998,1999,2000,2001,2002 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef LIBC_LOCK_H +#define LIBC_LOCK_H + +#include + +typedef pthread_mutex_t __libc_lock_t; + +#if __LT_SPINLOCK_INIT == 0 +# define __libc_lock_define_initialized(CLASS,NAME) \ + CLASS pthread_mutex_t NAME; +#else +# define __libc_lock_define_initialized(CLASS,NAME) \ + CLASS pthread_mutex_t NAME = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* Lock the named lock variable. */ +#define __libc_lock_lock(NAME) pthread_mutex_lock (&(NAME)); + +/* Unlock the named lock variable. */ +#define __libc_lock_unlock(NAME) pthread_mutex_unlock (&(NAME)); + +#endif +