From 6d7ae260af69f3ed6540a0cc5807497b5b9b1ee1 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Sat, 6 Dec 2003 00:39:23 +0000 Subject: [PATCH] work around Solaris 9 pty-close bug Create a LD_PRELOAD object, exitsleep, that will sleep for a short time prior to calling the real exit() function. This attempts to work around a Solaris 9 kernel bug where output will get lost if it is written to a pty immediately prior to the pty close. ticket: new component: krb5-build git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15864 dc483132-0cff-0310-8789-dd5450dbe970 --- src/ChangeLog | 5 +++ src/config/ChangeLog | 4 ++ src/config/shlib.conf | 12 ++++++ src/configure.in | 16 ++++++++ src/kadmin/testing/scripts/ChangeLog | 4 ++ src/kadmin/testing/scripts/env-setup.shin | 1 + src/util/ChangeLog | 9 +++++ src/util/Makefile.in | 8 +++- src/util/exitsleep.c | 47 +++++++++++++++++++++++ 9 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/util/exitsleep.c diff --git a/src/ChangeLog b/src/ChangeLog index db152f3c3..bb58f6918 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-12-05 Tom Yu + + * configure.in: Add support for building an LD_PRELOAD object for + Solaris, used by util/Makefile.in. + 2003-09-26 Ken Raeburn * aclocal.m4 (KRB5_AC_MAINTAINER_MODE): New macro. diff --git a/src/config/ChangeLog b/src/config/ChangeLog index 5662cb909..73b9e3da1 100644 --- a/src/config/ChangeLog +++ b/src/config/ChangeLog @@ -1,3 +1,7 @@ +2003-12-05 Tom Yu + + * shlib.conf: Add Solaris support for LD_PRELOAD. + 2003-09-26 Ken Raeburn * post.in (configure): Make configure depend on configure.in and diff --git a/src/config/shlib.conf b/src/config/shlib.conf index 7f04155cc..f37a74733 100644 --- a/src/config/shlib.conf +++ b/src/config/shlib.conf @@ -236,6 +236,18 @@ mips-*-netbsd*) CC_LINK_SHARED='$(PURE) $(CC) $(PROG_LIBPATH) $(RPATH_FLAG)$(PROG_RPATH) $(CFLAGS) $(LDFLAGS)' CC_LINK_STATIC='$(PURE) $(CC) $(PROG_LIBPATH) $(CFLAGS) $(LDFLAGS)' RUN_ENV='LD_LIBRARY_PATH=`echo $(PROG_LIBPATH) | sed -e "s/-L//g" -e "s/ /:/g"`; export LD_LIBRARY_PATH;' + case $krb5_cv_host in + *-*-solaris2.9*) + case $krb5_cv_prog_cc in + # XXX need better test for 64-bit compilation + *xarch=v9*) + RUN_ENV="$RUN_ENV"' LD_PRELOAD_64=$(BUILDTOP)/util/exitsleep; export LD_PRELOAD_64;' + ;; + *) + RUN_ENV="$RUN_ENV"' LD_PRELOAD_32=$(BUILDTOP)/util/exitsleep; export LD_PRELOAD_32;' + ;; + esac + esac ;; *-*-sunos*) diff --git a/src/configure.in b/src/configure.in index 30c0a890b..7a9026930 100644 --- a/src/configure.in +++ b/src/configure.in @@ -74,6 +74,22 @@ AC_CONFIG_SUBDIRS(lib/kdb lib/gssapi lib/rpc lib/kadm5) if test -n "$KRB4_LIB"; then AC_CONFIG_SUBDIRS(krb524) fi +case $krb5_cv_host in +*-*-solaris2.9*) + if test "$krb5_cv_prog_gcc" = yes; then + DL_COMPILE='$(CC) -fpic -G -nostdlib' + DL_COMPILE_TAIL='-lc -ldl' + else + DL_COMPILE='$(CC) -Kpic -G' + DL_COMPILE_TAIL='-ldl' + fi + EXITSLEEP_TARG=exitsleep + ;; +esac +AC_SUBST(DL_COMPILE) +AC_SUBST(DL_COMPILE_TAIL) +AC_SUBST(EXITSLEEP_TARG) + AC_CONFIG_SUBDIRS(kdc kadmin slave clients appl tests) AC_CONFIG_FILES(krb5-config, [chmod +x krb5-config]) V5_AC_OUTPUT_MAKEFILE(. util util/send-pr lib config-files gen-manpages) diff --git a/src/kadmin/testing/scripts/ChangeLog b/src/kadmin/testing/scripts/ChangeLog index 3132c9889..4b49a023c 100644 --- a/src/kadmin/testing/scripts/ChangeLog +++ b/src/kadmin/testing/scripts/ChangeLog @@ -1,3 +1,7 @@ +2003-12-05 Tom Yu + + * env-setup.shin: Allow BUILDTOP substitution. + 2003-05-13 Ken Raeburn * start_servers_local: Set KRB5RCACHEDIR. diff --git a/src/kadmin/testing/scripts/env-setup.shin b/src/kadmin/testing/scripts/env-setup.shin index 5dfd0c10a..e4a8c7e1b 100644 --- a/src/kadmin/testing/scripts/env-setup.shin +++ b/src/kadmin/testing/scripts/env-setup.shin @@ -19,6 +19,7 @@ export STOP # The shared library run time setup TOPLIBD=@RBUILD@/lib PROG_LIBPATH=-L@RBUILD@/lib +BUILDTOP=@RBUILD@ # XXX kludge! PROG_RPATH=@RBUILD@/lib # This converts $(TOPLIBD) to $TOPLIBD diff --git a/src/util/ChangeLog b/src/util/ChangeLog index 00f8fc5f6..7b833a1e1 100644 --- a/src/util/ChangeLog +++ b/src/util/ChangeLog @@ -1,3 +1,12 @@ +2003-12-05 Tom Yu + + * Makefile.in (DL_COMPILE, DL_COMPILE_TAIL): New variables to + support compilation of the exitsleep LD_PRELOAD object. + + * exitsleep.c: New file. LD_PRELOAD object for Solaris, to work + around a kernel bug where final output prior to a pty close gets + lost. + 2003-05-23 Ken Raeburn * depfix.sed: Don't check for krb524 headers. diff --git a/src/util/Makefile.in b/src/util/Makefile.in index 1176f2a38..bb04ff73d 100644 --- a/src/util/Makefile.in +++ b/src/util/Makefile.in @@ -25,7 +25,10 @@ HOST_TYPE=@HOST_TYPE@ HAVE_GCC=@HAVE_GCC@ SLIBSH=sed -e 's|@''CC''@|$(CC)|g' -e 's,@''HOST_TYPE''@,$(HOST_TYPE),g' -e 's,@''HAVE_GCC''@,$(HAVE_GCC),g' -all-recurse: libupdate makeshlib +DL_COMPILE=@DL_COMPILE@ +DL_COMPILE_TAIL=@DL_COMPILE_TAIL@ + +all-recurse: libupdate makeshlib @EXITSLEEP_TARG@ all-mac:: NO_OUTDIR=1 @@ -61,6 +64,9 @@ makeshlib: $(srcdir)/makeshlib.sh Makefile $(RM) $@ $@.tmp $(SLIBSH) $(srcdir)/makeshlib.sh >$@.tmp&&chmod a+x $@.tmp&&mv $@.tmp $@ +exitsleep: $(srcdir)/exitsleep.c + $(DL_COMPILE) -oexitsleep $(srcdir)/exitsleep.c $(DL_COMPILE_TAIL) + clean:: $(RM) libupdate makeshlib diff --git a/src/util/exitsleep.c b/src/util/exitsleep.c new file mode 100644 index 000000000..95232e5b3 --- /dev/null +++ b/src/util/exitsleep.c @@ -0,0 +1,47 @@ +/* + * util/exitsleep.c + * + * Copyright (C) 2003 by the Massachusetts Institute of Technology. + * All rights reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * Kludge to sleep 100ms prior to exit on Solaris 9 to work around a + * pty bug. + */ + +#include +#include +#include +#include +#include + +void +exit(int status) +{ + void (*realexit)(int); + struct timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = 100000; + realexit = (void (*)(int))dlsym(RTLD_NEXT, "exit"); + select(0, 0, 0, 0, &tv); + realexit(status); +} -- 2.26.2