Move (BSD-licensed) mkstemp from libdb2 to libkrb5support, and rename
authorKen Raeburn <raeburn@mit.edu>
Wed, 20 Jun 2007 03:53:37 +0000 (03:53 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 20 Jun 2007 03:53:37 +0000 (03:53 +0000)
the function to krb5int_mkstemp.  Generate the symbol export list for
libkrb5support at build time.

Declare krb5int_mkstemp in k5-platform.h.
Change cc_file.c to use mkstemp unconditionally.

Make libdb2.so (built for testing only) link against the
libkrb5support, and use krb5int_mkstemp if mkstemp is not available.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19600 dc483132-0cff-0310-8789-dd5450dbe970

src/configure.in
src/include/k5-platform.h
src/lib/krb5/ccache/cc_file.c
src/plugins/kdb/db2/libdb2/Makefile.in
src/plugins/kdb/db2/libdb2/clib/Makefile.in
src/plugins/kdb/db2/libdb2/configure.in
src/util/support/Makefile.in
src/util/support/libkrb5support-fixed.exports [moved from src/util/support/libkrb5support.exports with 100% similarity]
src/util/support/mkstemp.c [moved from src/plugins/kdb/db2/libdb2/clib/mkstemp.c with 96% similarity]

index 947be9be1fe06c78246396e60cc0570af65fc27d..be7d093075896238fef3d0e246747d398931291b 100644 (file)
@@ -159,6 +159,19 @@ AC_PROG_LEX
 AC_C_CONST
 AC_HEADER_DIRENT
 AC_CHECK_FUNCS(strdup setvbuf inet_ntoa inet_aton seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strftime strptime geteuid setenv unsetenv getenv gethostbyname2 getifaddrs gmtime_r localtime_r pthread_mutex_lock sched_yield bswap16 bswap64 mkstemp getusershell lstat access ftime getcwd srand48 srand srandom stat strchr strerror strerror_r strstr timezone umask waitpid sem_init sem_trywait daemon)
+dnl
+EXTRA_SUPPORT_SYMS=
+AC_CHECK_FUNC(mkstemp,
+[MKSTEMP_ST_OBJ=
+MKSTEMP_OBJ=],
+[MKSTEMP_ST_OBJ='mkstemp.o'
+MKSTEMP_OBJ='$(OUTPRE)mkstemp.$(OBJEXT)'
+EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_mkstemp"
+AC_DEFINE(mkstemp,krb5int_mkstemp,[Define to krb5int_mkstemp if the OS does not provide it.])])
+AC_SUBST(MKSTEMP_OBJ)
+AC_SUBST(MKSTEMP_ST_OBJ)
+AC_SUBST(EXTRA_SUPPORT_SYMS)
+dnl
 AC_HEADER_STDARG
 DECLARE_SYS_ERRLIST
 AC_CHECK_HEADERS(unistd.h paths.h regex.h regexpr.h fcntl.h memory.h ifaddrs.h sys/filio.h sched.h byteswap.h machine/endian.h machine/byte_order.h sys/bswap.h endian.h pwd.h arpa/inet.h alloca.h dlfcn.h limits.h pthread.h semaphore.h krb_db.h kdc.h)
index 6cf446506632f412afcbb2aaf3a5b7bd44d86c73..fe248b34800740d0db10c74ddf43cd3eb55bc495 100644 (file)
@@ -832,5 +832,8 @@ k5_asprintf(char **ret, const char *format, ...)
 }
 #endif
 
+#ifndef HAVE_MKSTEMP
+extern int krb5int_mkstemp(char *);
+#endif
 
 #endif /* K5_PLATFORM_H */
index 84d278765a0d58b39611549256a639b6a9107511..28583233179a45d732185c300ee76885473cc367 100644 (file)
@@ -1964,14 +1964,10 @@ krb5_fcc_generate_new (krb5_context context, krb5_ccache *id)
 
      (void) strcpy(scratch, TKT_ROOT);
      (void) strcat(scratch, "XXXXXX");
-#ifdef HAVE_MKSTEMP
      ret = mkstemp(scratch);
      if (ret == -1) {
         return krb5_fcc_interpret(context, errno);
      } else close(ret);
-#else /*HAVE_MKSTEMP*/
-     mktemp(scratch);
-#endif
 
      lid->data = (krb5_pointer) malloc(sizeof(krb5_fcc_data));
      if (lid->data == NULL) {
index 77326a239247c9431246352c7cb132c2a9997386..83a1180f3f0b39b2139f60bf6a2c355c5b1f5870 100644 (file)
@@ -15,6 +15,11 @@ RELDIR=../plugins/kdb/db2/libdb2
 HDRDIR=$(BUILDTOP)/include
 HDRS = $(HDRDIR)/db.h $(HDRDIR)/db-config.h $(HDRDIR)/db-ndbm.h
 
+SHLIB_EXPDEPS=$(SUPPORT_DEPLIB)
+SHLIB_EXPLIBS=$(SUPPORT_LIB)
+SHLIB_DIRS=-L$(TOPLIBD)
+SHLIB_RDIRS=$(KRB5_LIBDIR)
+
 AUTOCONF_HEADER=$(srcdir)/include/config.h.in
 
 all-unix:: includes all-libs
@@ -40,5 +45,4 @@ $(srcdir)/include/autoconf.stmp: $(srcdir)/configure.in $(SRCTOP)/aclocal.m4
 
 clean-includes::
        $(RM) $(HDRS) include/*.stmp
-@libnodeps_frag@
 @lib_frag@
index 1053b494540aa80703b8794cdf41e16655d10764..7c43c6dc561a00ca35a6d07975b2b5ffc0ee9064 100644 (file)
@@ -2,7 +2,7 @@ thisconfigdir=./..
 myfulldir=plugins/kdb/db2/libdb2/clib
 mydir=clib
 BUILDTOP=$(REL)..$(S)..$(S)..$(S)..$(S)..
-STLIBOBJS=@MEMMOVE_OBJ@ @MKSTEMP_OBJ@ @STRERROR_OBJ@
+STLIBOBJS=@MEMMOVE_OBJ@ @STRERROR_OBJ@
 
 LOCALINCLUDES=-I../include
 
index a1b00d321384082d69d6d160d97de533dbb7f79f..10c3bd752ad4c53dc41cf3b33d29b53aa0b39a46 100644 (file)
@@ -77,9 +77,7 @@ AC_DEFINE(MEMMOVE,1,[Define if memmove.o is compiled in])])
 AC_SUBST(MEMMOVE_OBJ)
 
 AC_CHECK_FUNC(mkstemp, ,
-[MKSTEMP_OBJ=mkstemp.o
-AC_DEFINE(mkstemp, kdb2__mkstemp,[Define to \`kdb2__mkstemp' to provide private mkstemp function])])
-AC_SUBST(MKSTEMP_OBJ)
+[AC_DEFINE(mkstemp, krb5int_mkstemp,[Define to \`krb5int_mkstemp' to use private mkstemp function])])
 
 AC_CHECK_FUNC(strerror, ,
 [STRERROR_OBJ=strerror.o
index 78c322ec00e76254b869a6965e5ac0643df0b80a..a89dd4d4c8aedecb9c545818bd2389b00379f3c4 100644 (file)
@@ -31,7 +31,8 @@ STLIBOBJS= \
        plugins.o \
        errors.o \
        gmt_mktime.o \
-       fake-addrinfo.o
+       fake-addrinfo.o \
+       @MKSTEMP_ST_OBJ@
 
 LIBOBJS= \
        $(OUTPRE)threads.$(OBJEXT) \
@@ -39,7 +40,8 @@ LIBOBJS= \
        $(OUTPRE)plugins.$(OBJEXT) \
        $(OUTPRE)errors.$(OBJEXT) \
        $(OUTPRE)gmt_mktime.$(OBJEXT) \
-       $(OUTPRE)fake-addrinfo.$(OBJEXT)
+       $(OUTPRE)fake-addrinfo.$(OBJEXT) \
+       @MKSTEMP_OBJ@
 
 STOBJLISTS=OBJS.ST
 
@@ -52,7 +54,9 @@ SRCS=\
        $(srcdir)/init-addrinfo.c \
        $(srcdir)/errors.c \
        $(srcdir)/gmt_mktime.c \
-       $(srcdir)/fake-addrinfo.c
+       $(srcdir)/fake-addrinfo.c \
+       $(srcdir)/mkstemp.c
+
 SHLIB_EXPDEPS =
 # Add -lm if dumping thread stats, for sqrt.
 SHLIB_EXPLIBS= $(LIBS) $(DL_LIB)
@@ -76,6 +80,15 @@ $(BUILDTOP)/include/autoconf.h: $(SRCTOP)/include/autoconf.h.in
 t_mktime: gmt_mktime.c
        $(CC) $(ALL_CFLAGS) -DTEST_LEAP -o t_mktime $(srcdir)/gmt_mktime.c
 
+SHLIB_EXPORT_FILE=libkrb5support.exports
+
+libkrb5support.exports: $(srcdir)/libkrb5support-fixed.exports Makefile
+       cat $(srcdir)/libkrb5support-fixed.exports > new-exports
+       for i in @EXTRA_SUPPORT_SYMS@ .; do \
+         if test "$$i" != .; then echo $$i >> new-exports; else :; fi ; \
+       done
+       $(MV) new-exports libkrb5support.exports
+
 @lib_frag@
 @libobj_frag@
 
similarity index 96%
rename from src/plugins/kdb/db2/libdb2/clib/mkstemp.c
rename to src/util/support/mkstemp.c
index 71dc7d17a18af4e056bfbd793a20a7a5ab4e61aa..b671c6b566b5c90c06621c85092e233470c0495b 100644 (file)
@@ -35,9 +35,7 @@
 static char sccsid[] = "@(#)mktemp.c   8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "k5-platform.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -45,14 +43,17 @@ static char sccsid[] = "@(#)mktemp.c        8.1 (Berkeley) 6/4/93";
 #include <errno.h>
 #include <stdio.h>
 #include <ctype.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 #ifndef O_BINARY
 #define O_BINARY 0
 #endif
 
-static int _gettemp();
+static int _gettemp(char *, int *);
 
-mkstemp(path)
+int mkstemp(path)
        char *path;
 {
        int fd;
@@ -60,7 +61,7 @@ mkstemp(path)
        return (_gettemp(path, &fd) ? fd : -1);
 }
 
-static
+static int
 _gettemp(path, doopen)
        char *path;
        register int *doopen;