]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
work around Solaris 9 pty-close bug
authorTom Yu <tlyu@mit.edu>
Sat, 6 Dec 2003 00:39:23 +0000 (00:39 +0000)
committerTom Yu <tlyu@mit.edu>
Sat, 6 Dec 2003 00:39:23 +0000 (00:39 +0000)
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
src/config/ChangeLog
src/config/shlib.conf
src/configure.in
src/kadmin/testing/scripts/ChangeLog
src/kadmin/testing/scripts/env-setup.shin
src/util/ChangeLog
src/util/Makefile.in
src/util/exitsleep.c [new file with mode: 0644]

index db152f3c334dc0be8e8d04843c410cf6e90845a2..bb58f6918fa3d7a67fadc6e5c1533e33ee9c4118 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-05  Tom Yu  <tlyu@mit.edu>
+
+       * configure.in: Add support for building an LD_PRELOAD object for
+       Solaris, used by util/Makefile.in.
+
 2003-09-26  Ken Raeburn  <raeburn@mit.edu>
 
        * aclocal.m4 (KRB5_AC_MAINTAINER_MODE): New macro.
index 5662cb9093ee74668b0e7225ea3cccf24d423b6a..73b9e3da1ea2623b22a15b1939a89d867fffb55b 100644 (file)
@@ -1,3 +1,7 @@
+2003-12-05  Tom Yu  <tlyu@mit.edu>
+
+       * shlib.conf: Add Solaris support for LD_PRELOAD.
+
 2003-09-26  Ken Raeburn  <raeburn@mit.edu>
 
        * post.in (configure): Make configure depend on configure.in and
index 7f04155cc810cd6ed8e12c9e701ca10f610d609f..f37a747338a8f074701becbcf305d716df1a16ed 100644 (file)
@@ -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*)
index 30c0a890be2ba7238cf9223e4bad6efebd39e84c..7a9026930dd3cc9acffb82e6cfc77101c1c6270c 100644 (file)
@@ -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)
index 3132c9889df3596ed5a1c16e026b27742b02a3c2..4b49a023cdc49cb6a3bf6bfb135524a138fd535d 100644 (file)
@@ -1,3 +1,7 @@
+2003-12-05  Tom Yu  <tlyu@mit.edu>
+
+       * env-setup.shin: Allow BUILDTOP substitution.
+
 2003-05-13  Ken Raeburn  <raeburn@mit.edu>
 
        * start_servers_local: Set KRB5RCACHEDIR.
index 5dfd0c10a4b5c9c4eee4bb57e52a8f680585545f..e4a8c7e1b50fa7c13db56a36516f8f82039efa09 100644 (file)
@@ -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
index 00f8fc5f6021fb0b8b4b7960948e64e0b1ac2261..7b833a1e1dc02fcef24cd73872bebbefa6cb62a0 100644 (file)
@@ -1,3 +1,12 @@
+2003-12-05  Tom Yu  <tlyu@mit.edu>
+
+       * 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  <raeburn@mit.edu>
 
        * depfix.sed: Don't check for krb524 headers.
index 1176f2a38f4a2a9cff3ea3631f7eaac1bb0edced..bb04ff73d6fc44ba5b73b1df7a8cabca6eb53a5a 100644 (file)
@@ -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 (file)
index 0000000..95232e5
--- /dev/null
@@ -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 <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <link.h>
+
+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);
+}