From: Ken Raeburn Date: Wed, 20 Jun 2007 03:53:37 +0000 (+0000) Subject: Move (BSD-licensed) mkstemp from libdb2 to libkrb5support, and rename X-Git-Tag: krb5-1.7-alpha1~1081 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=56da8ce661eaf5b6555db9be3a572cf27ce8894f;p=krb5.git Move (BSD-licensed) mkstemp from libdb2 to libkrb5support, and rename 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 --- diff --git a/src/configure.in b/src/configure.in index 947be9be1..be7d09307 100644 --- a/src/configure.in +++ b/src/configure.in @@ -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) diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h index 6cf446506..fe248b348 100644 --- a/src/include/k5-platform.h +++ b/src/include/k5-platform.h @@ -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 */ diff --git a/src/lib/krb5/ccache/cc_file.c b/src/lib/krb5/ccache/cc_file.c index 84d278765..285832331 100644 --- a/src/lib/krb5/ccache/cc_file.c +++ b/src/lib/krb5/ccache/cc_file.c @@ -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) { diff --git a/src/plugins/kdb/db2/libdb2/Makefile.in b/src/plugins/kdb/db2/libdb2/Makefile.in index 77326a239..83a1180f3 100644 --- a/src/plugins/kdb/db2/libdb2/Makefile.in +++ b/src/plugins/kdb/db2/libdb2/Makefile.in @@ -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@ diff --git a/src/plugins/kdb/db2/libdb2/clib/Makefile.in b/src/plugins/kdb/db2/libdb2/clib/Makefile.in index 1053b4945..7c43c6dc5 100644 --- a/src/plugins/kdb/db2/libdb2/clib/Makefile.in +++ b/src/plugins/kdb/db2/libdb2/clib/Makefile.in @@ -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 diff --git a/src/plugins/kdb/db2/libdb2/configure.in b/src/plugins/kdb/db2/libdb2/configure.in index a1b00d321..10c3bd752 100644 --- a/src/plugins/kdb/db2/libdb2/configure.in +++ b/src/plugins/kdb/db2/libdb2/configure.in @@ -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 diff --git a/src/util/support/Makefile.in b/src/util/support/Makefile.in index 78c322ec0..a89dd4d4c 100644 --- a/src/util/support/Makefile.in +++ b/src/util/support/Makefile.in @@ -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@ diff --git a/src/util/support/libkrb5support.exports b/src/util/support/libkrb5support-fixed.exports similarity index 100% rename from src/util/support/libkrb5support.exports rename to src/util/support/libkrb5support-fixed.exports diff --git a/src/plugins/kdb/db2/libdb2/clib/mkstemp.c b/src/util/support/mkstemp.c similarity index 96% rename from src/plugins/kdb/db2/libdb2/clib/mkstemp.c rename to src/util/support/mkstemp.c index 71dc7d17a..b671c6b56 100644 --- a/src/plugins/kdb/db2/libdb2/clib/mkstemp.c +++ b/src/util/support/mkstemp.c @@ -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 #include @@ -45,14 +43,17 @@ static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; #include #include #include +#ifdef HAVE_UNISTD_H +#include +#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;