[gridengine] - Update to svn 131 - Add upstream env-code-injection security patch

Orion Poplawski orion at fedoraproject.org
Tue Apr 17 15:24:32 UTC 2012


commit b74fe774bd8ef27a961f47e5efcd32feb1bdfe70
Author: Orion Poplawski <orion at cora.nwra.com>
Date:   Tue Apr 17 09:24:28 2012 -0600

    - Update to svn 131
    - Add upstream env-code-injection security patch

 env-code-injection-GE2011.11p1.patch |  126 +
 gridengine-ssl.patch                 |   12 -
 gridengine-svn.patch                 | 4007 ---------------------
 gridengine-svn131.patch              | 6319 ++++++++++++++++++++++++++++++++++
 gridengine.spec                      |   14 +-
 5 files changed, 6454 insertions(+), 4024 deletions(-)
---
diff --git a/env-code-injection-GE2011.11p1.patch b/env-code-injection-GE2011.11p1.patch
new file mode 100644
index 0000000..0713063
--- /dev/null
+++ b/env-code-injection-GE2011.11p1.patch
@@ -0,0 +1,126 @@
+Index: source/daemons/shepherd/shepherd.c
+===================================================================
+--- source/daemons/shepherd/shepherd.c	(revision 131)
++++ source/daemons/shepherd/shepherd.c	(working copy)
+@@ -1234,7 +1234,7 @@
+             shepherd_trace("calling fork_no_pty()");
+             pid = fork_no_pty(fd_pipe_in, fd_pipe_out, fd_pipe_err, &err_msg);
+          }
+-      } 
++      }
+ 
+       if (pid==0)
+       {
+@@ -2472,7 +2472,7 @@
+       {
+          /* received any other signal */
+ #if defined(INTERIX)
+-         sge_set_environment();
++         sge_set_environment(true);
+          if (strcmp(childname, "job") == 0 &&
+              wl_get_GUI_mode(get_conf_val("display_win_gui")) == true)
+          {
+@@ -2654,7 +2654,7 @@
+ 
+ #if defined(INTERIX)
+       /* <Windows_GUI> */
+-      sge_set_environment();
++      sge_set_environment(true);
+       if (strcmp(childname, "job") == 0 &&
+          wl_get_GUI_mode(get_conf_val("display_win_gui")) == true) {
+          if (npid != -1) {      
+@@ -2923,7 +2923,7 @@
+       pid = getpid();
+       setpgid(pid, pid);  
+       setrlimits(0);
+-      sge_set_environment();
++      sge_set_environment(true);
+       umask(022);
+ 
+       tmp_str = search_conf_val("qsub_gid");
+Index: source/daemons/shepherd/builtin_starter.c
+===================================================================
+--- source/daemons/shepherd/builtin_starter.c	(revision 131)
++++ source/daemons/shepherd/builtin_starter.c	(working copy)
+@@ -49,6 +49,7 @@
+ #include "uti/sge_arch.h"
+ #include "setosjobid.h"
+ #include "sge_fileio.h"
++#include "sge_var.h"
+ 
+ #include "msg_common.h"
+ 
+@@ -418,7 +419,7 @@
+    setrlimits(!strcmp(childname, "job"));
+ 
+    shepherd_trace("setting environment");
+-   sge_set_environment();
++   sge_set_environment(strcmp(childname, "job") || ( is_qlogin && !g_new_interactive_job_support));
+ 
+   /* Create the "error" and the "exit" status file here.
+    * The "exit_status" file indicates that the son is started.
+@@ -997,7 +998,7 @@
+ *     and store it in the appropriate environment, inherited or internal.
+ *
+ *  SYNOPSIS
+-*      int sge_set_environment(void)
++*      int sge_set_environment(int)
+ *
+ *  FUNCTION
+ *     This function reads the "environment" file written out by the execd and
+@@ -1010,7 +1011,7 @@
+ *  NOTES
+ *      MT-NOTE: sge_set_environment() is not MT safe
+ *******************************************************************************/
+-int sge_set_environment()
++int sge_set_environment(int cleanenv)
+ {
+    const char *const filename = "environment";
+    FILE *fp;
+@@ -1048,7 +1049,7 @@
+ 
+    while (fgets(buf, sizeof(buf), fp))
+    {
+-      char *name, *value;
++      char *name, *value, new_name[128];
+       const char *new_value;
+ 
+       line++;
+@@ -1062,6 +1063,24 @@
+          FCLOSE(fp);
+          shepherd_error(1, "error reading environment file: line=%d, contents:%s", line, buf);
+       }
++      else if (cleanenv)
++      {
++        #if   defined(AIX)
++          if (strncmp(name, "LD_", 3) == 0 || strncmp(name, "LIBPATH", 7) == 0 || strncmp(name, "LDR_PRELOAD", 11) == 0)
++        #elif defined(DARWIN)
++          if (strncmp(name, "LD_", 3) == 0 || strncmp(name, "DYLD_", 5) == 0)
++        #elif defined(HP11)
++          if (strncmp(name, "LD_", 3) == 0 || strncmp(name, "SHLIB_PATH", 10) == 0)
++        #elif defined(LINUX)
++          if (strncmp(name, "LD_", 3) == 0 || strncmp(name, "MALLOC_TRACE", 12) == 0)
++        #else
++          if (strncmp(name, "LD_", 3) == 0)
++        #endif
++          {
++             snprintf(new_name, sizeof(new_name), "SGE_WRAP_%s", name);
++             name = new_name;
++          }
++      }
+ 
+       value = strtok(NULL, "\n");
+       if (value == NULL)
+Index: source/daemons/shepherd/builtin_starter.h
+===================================================================
+--- source/daemons/shepherd/builtin_starter.h	(revision 131)
++++ source/daemons/shepherd/builtin_starter.h	(working copy)
+@@ -34,7 +34,7 @@
+ 
+ 
+ void son(const char *childname, char *script_file, int truncate_stderr_out);
+-int sge_set_environment(void);
++int sge_set_environment(int);
+ char **sge_get_environment(void);
+ int sge_set_env_value(const char *, const char *);
+ const char *sge_get_env_value(const char *);
diff --git a/gridengine-svn131.patch b/gridengine-svn131.patch
new file mode 100644
index 0000000..d7f80f7
--- /dev/null
+++ b/gridengine-svn131.patch
@@ -0,0 +1,6319 @@
+diff -ruN --exclude .svn GE2011.11/Changelog gridscheduler-trunk/Changelog
+--- GE2011.11/Changelog	2011-11-14 12:01:27.000000000 -0700
++++ gridscheduler-trunk/Changelog	2012-04-17 09:13:37.462300617 -0600
+@@ -6,6 +6,82 @@
+           1         2         3         4         5         6         7
+ 01234567890123456789012345678901234567890123456789012345678901234567890123456789
+ 
++RH-2012-04-15-0:  Bugfix:     file descriptors closed too soon in shepherd
++                              (from Brooks Davis, with cleanup from Ron Chen)
++
++RH-2012-04-13-2:  Cleanup     Remove arch.dist
++
++RH-2012-04-13-1:  Enhancem.   hwloc build changes
++
++RH-2012-04-13-0:  Enhancem.   Misc GUI Installer cleanup - part 1
++
++RH-2012-04-11-0:  Enhancem.   Preparing for the GE 2011.11 patch 1 release
++
++RH-2012-04-10-0:  Bugfix:     Merge in Sun's JG-2010-01-13-0:
++                              - execd does not verify the pe task start user in
++                                non CSP mode
++
++RH-2012-03-20-3:  Misc.       -Wno-strict-aliasing is needed for -Werror
++
++RH-2012-03-20-2:  Enhancem.   qmon is now optional
++
++RH-2012-03-20-1:  Enhancem.   LessTif support (from Fedora)
++
++RH-2012-03-20-0:  Enhancem.   Quick fix for Solaris 11
++
++RH-2012-03-18-0:  Enhancem.   Reduce the no. of X11 libs for libXltree link line
++
++RH-2012-03-17-5:  Bugfix:     Changes for OpenSSL API diff. 
++
++RH-2012-03-17-4:  Enhancem.   Fine-grained CheckBinaries()
++
++RH-2012-03-17-3:  Enhancem.   remove unused -R compiler flag in qtcsh
++
++RH-2012-03-17-2:  Enhancem.   include header file for NetBSD & FreeBSD
++
++RH-2012-03-17-1:  Enhancem.   Break warn extra error into a separate flag
++
++RH-2012-03-17-0:  Enhancem.   More aimk improvements
++
++RH-2012-03-16-3:  Enhancem.   improve sys #ifdef
++
++RH-2012-03-16-2:  Enhancem.   minor aimk cleanup
++
++RH-2012-03-16-1:  Enhancem.   added aimk flag: -sys-libssl
++
++RH-2012-03-16-0:  Enhancem.   Set $PATH in bdb_checkpoint.sh
++
++RH-2012-03-15-2:  Enhancem.   Misc. cleanup
++
++RH-2012-03-15-1:  Enhancem.   Cygwin cleanup
++
++RH-2012-03-15-0:  Enhancem.   sge_edit cleanup
++
++RH-2012-03-12-0:  Enhancem.   aimk cleanup
++
++RH-2012-02-15-0:  Enhancem.:  - cleanup inst_sge
++                              - added -sys-jemalloc
++
++RH-2012-01-21-1:  Bugfix:     lx -> linux in arch
++
++RH-2012-01-21-0:  Enhancem.   64-bit OSX port + OSX cleanup
++
++RH-2011-11-21-1:  Enhancem.   add -y option to auto-accept prompts
++                  From:       Justin Riley (with some minor changes by RH)
++
++RH-2011-11-21-0:  Enhancem.   set JAVA_LIB_ARCH to i386 if -32 flag was passed
++                  From:       Justin Riley
++
++RH-2011-11-19-0:  Bugfix:     Exported bash functions causes erroneous
++                              "environment" file
++                  Issue:      2173
++
++RH-2011-11-16-1:  Enhancem.   Cygwin port - Part 1
++
++-------------------------------------------------------------------------------
++
++RH-2011-11-16-0:  SVN:        Grid Engine 2011.11
++
+ RH-2011-11-14-1:  Enhancem.   manpage update
+ 
+ RH-2011-11-13-6:  Bugfix:     Minor fix for Hadoop setup.pl (from Kevin Squire)
+@@ -97,7 +173,7 @@
+ 
+ -------------------------------------------------------------------------------
+ 
+-RH-2011-04-01-0: CVS:         OGS 6.2u5p2
++RH-2011-04-01-0: SVN:         OGS 6.2u5p2
+ 
+ RC-2011-03-27-0: Cleanup:     more cleanups
+ 
+@@ -132,7 +208,7 @@
+ 
+ -------------------------------------------------------------------------------
+ 
+-RH-2011-02-25-0: CVS:         created trunk, tags, branches (OGS 6.2u5p1)
++RH-2011-02-25-0: SVN:         created trunk, tags, branches (OGS 6.2u5p1)
+ 
+ SD-2010-09-15-0: Bugfix:      slotwise preemption fails to unsuspend one job 
+                               per host
+@@ -146,4 +222,4 @@
+ 
+ -------------------------------------------------------
+ 
+-RC-2010-08-18-0: CVS:         created from V62u5_TAG
++RC-2010-08-18-0: SVN:         created from V62u5_TAG
+diff -ruN --exclude .svn GE2011.11/source/3rdparty/qmon/iconlist/IconList.c gridscheduler-trunk/source/3rdparty/qmon/iconlist/IconList.c
+--- GE2011.11/source/3rdparty/qmon/iconlist/IconList.c	2011-11-14 12:01:02.000000000 -0700
++++ gridscheduler-trunk/source/3rdparty/qmon/iconlist/IconList.c	2012-03-21 09:25:10.292927761 -0600
+@@ -50,9 +50,7 @@
+ #include <Xm/Traversal.h>
+ #endif
+ 
+-#ifdef LesstifVersion
+-#undef NeedWidePrototypes
+-#endif
++#ifndef LesstifVersion
+ 
+ #ifndef SOLARIS
+ #if XmVersion >= 2000
+@@ -97,6 +95,7 @@
+ 
+ #endif
+ #endif
++#endif
+ 
+ #include "DumbClip.h"
+ #include "IconListP.h"
+diff -ruN --exclude .svn GE2011.11/source/3rdparty/qmon/ltree/Makefile.aimk gridscheduler-trunk/source/3rdparty/qmon/ltree/Makefile.aimk
+--- GE2011.11/source/3rdparty/qmon/ltree/Makefile.aimk	2011-11-14 12:01:02.000000000 -0700
++++ gridscheduler-trunk/source/3rdparty/qmon/ltree/Makefile.aimk	2012-03-21 09:25:10.341926017 -0600
+@@ -27,7 +27,7 @@
+ 	$(RANLIB) libXltree.a
+ 
+ libXltree$(SHAREDEXT): $(XLTREE_OBJS)
+-	$(SHAREDLD) $(XLFLAGS) $(GSHARED_LFLAGS) -o libXltree$(SHAREDEXT) $(XLTREE_OBJS) $(XLIBS)
++	$(SHAREDLD) $(XLFLAGS) $(GSHARED_LFLAGS) -o libXltree$(SHAREDEXT) $(XLTREE_OBJS) $(XMLIBS)
+ 
+ Xltree_clean:
+ 	$(RM) $(XLTREE_OBJS) libXltree.a libXltree$(SHAREDEXT)
+diff -ruN --exclude .svn GE2011.11/source/3rdparty/qmon/spinbox/Spinbox.c gridscheduler-trunk/source/3rdparty/qmon/spinbox/Spinbox.c
+--- GE2011.11/source/3rdparty/qmon/spinbox/Spinbox.c	2011-11-14 12:01:02.000000000 -0700
++++ gridscheduler-trunk/source/3rdparty/qmon/spinbox/Spinbox.c	2012-03-21 09:25:10.089934986 -0600
+@@ -1797,7 +1797,7 @@
+ #ifdef CRAY
+    errno = 0;
+ #elif !defined(LINUX) && !defined(SOLARIS) && !defined(DARWIN) && !defined(FREEBSD) && !defined(NETBSD) && \
+-   !defined(AIX51) && !defined(AIX43) && !defined(ALPHA) && !defined(HP1164) && !defined(HPUX) && !defined(IRIX) 
++   !defined(AIX) && !defined(ALPHA) && !defined(HP1164) && !defined(HPUX) && !defined(IRIX) 
+    int errno = 0; 
+ #endif
+    *value = strtol ( buffer, NULL, 10 );
+diff -ruN --exclude .svn GE2011.11/source/3rdparty/qmon/Xmt310/Xmt/Layout.c gridscheduler-trunk/source/3rdparty/qmon/Xmt310/Xmt/Layout.c
+--- GE2011.11/source/3rdparty/qmon/Xmt310/Xmt/Layout.c	2011-11-14 12:01:04.000000000 -0700
++++ gridscheduler-trunk/source/3rdparty/qmon/Xmt310/Xmt/Layout.c	2012-03-21 09:25:10.423923097 -0600
+@@ -490,8 +490,16 @@
+      * the renderTable.
+      */
+     if (!lw->layout.font)
+-        XmeRenderTableGetDefaultFont(lw->layout.render_table,
+-                                     &lw->layout.font);
++        XmeRenderTableGetDefaultFont(lw->layout.render_table, &lw->layout.font);
++
++#ifdef LesstifVersion
++     /*
++      * The previous fails with lesstif, try again...
++      */
++     if (!lw->layout.font)
++         _XmFontListGetDefaultFont(lw->layout.font_list, &lw->layout.font);
++#endif /* LesstifVersion */
++
+ #endif
+     
+     /* figure out resolution independence values */
+diff -ruN --exclude .svn GE2011.11/source/3rdparty/qmon/Xmt310/Xmt/PixmapCvt.c gridscheduler-trunk/source/3rdparty/qmon/Xmt310/Xmt/PixmapCvt.c
+--- GE2011.11/source/3rdparty/qmon/Xmt310/Xmt/PixmapCvt.c	2011-11-14 12:01:04.000000000 -0700
++++ gridscheduler-trunk/source/3rdparty/qmon/Xmt310/Xmt/PixmapCvt.c	2012-03-21 09:25:10.425923027 -0600
+@@ -72,12 +72,14 @@
+     XmRPrimForegroundPixmap,
+     XmRManForegroundPixmap,
+     XmRGadgetPixmap
++#ifndef LesstifVersion
+ #if XmVersion >= 2000
+     ,
+     XmRLargeIconPixmap ,
+     XmRSmallIconPixmap,
+     XmRDynamicPixmap
+ #endif
++#endif /* LesstifVersion */
+     
+ };
+ 
+diff -ruN --exclude .svn GE2011.11/source/3rdparty/qtcsh/configure gridscheduler-trunk/source/3rdparty/qtcsh/configure
+--- GE2011.11/source/3rdparty/qtcsh/configure	2011-11-14 12:00:57.000000000 -0700
++++ gridscheduler-trunk/source/3rdparty/qtcsh/configure	2012-03-21 09:25:10.005937973 -0600
+@@ -2691,7 +2691,7 @@
+ fi;
+ if test "$sge" != no; then
+    GRDDEF="-I../../../libs/gdi"
+-   GRDLIB="-L../../../$sge -R${SGE_ROOT}/lib/${SGE_ARCH} \$(SGE_LIBS) ${LDFLAGS}"
++   GRDLIB="-L../../../$sge \$(SGE_LIBS) ${LDFLAGS}"
+    CFLAGS="$CFLAGS -DPROG_NAME='\"qtcsh\"' -D$sge"
+ fi
+ 
+diff -ruN --exclude .svn GE2011.11/source/3rdparty/qtcsh/configure.in gridscheduler-trunk/source/3rdparty/qtcsh/configure.in
+--- GE2011.11/source/3rdparty/qtcsh/configure.in	2011-11-14 12:00:57.000000000 -0700
++++ gridscheduler-trunk/source/3rdparty/qtcsh/configure.in	2012-03-21 09:25:09.983938759 -0600
+@@ -265,7 +265,7 @@
+             [grd="$withval"], [grd=no])
+ if test "$grd" != no; then
+    GRDDEF="-I../../../libs/gdi"
+-   GRDLIB="-L../../../$grd -R${SGE_ROOT}/lib/${SGE_ARCH} \$(SGE_LIBS) ${LDFLAGS}"
++   GRDLIB="-L../../../$grd \$(SGE_LIBS) ${LDFLAGS}"
+    CFLAGS="$CFLAGS -DPROG_NAME='\"qtcsh\"' -D$grd"
+ fi
+ AC_SUBST(GRDDEF)
+diff -ruN --exclude .svn GE2011.11/source/3rdparty/qtcsh/tc.alloc.c gridscheduler-trunk/source/3rdparty/qtcsh/tc.alloc.c
+--- GE2011.11/source/3rdparty/qtcsh/tc.alloc.c	2011-11-14 12:00:57.000000000 -0700
++++ gridscheduler-trunk/source/3rdparty/qtcsh/tc.alloc.c	2012-03-21 09:25:10.003938049 -0600
+@@ -65,7 +65,7 @@
+ # define realloc	frealloc
+ #endif /* WINNT */
+ 
+-#if defined(AIX51) || defined(AIX43)
++#if defined(AIX)
+ #define SYSMALLOC
+ #endif
+ 
+diff -ruN --exclude .svn GE2011.11/source/3rdparty/qtcsh/tc.who.c gridscheduler-trunk/source/3rdparty/qtcsh/tc.who.c
+--- GE2011.11/source/3rdparty/qtcsh/tc.who.c	2011-11-14 12:00:57.000000000 -0700
++++ gridscheduler-trunk/source/3rdparty/qtcsh/tc.who.c	2012-03-21 09:25:10.002938087 -0600
+@@ -45,6 +45,12 @@
+  */
+ #include <ctype.h>
+ 
++#ifdef __SunOS
++  #ifdef _PATH_UTMP
++    #undef _PATH_UTMP
++  #endif
++#endif
++
+ #ifdef HAVEUTMPX
+ # include <utmpx.h>
+ /* I just redefine a few words here.  Changing every occurrence below
+diff -ruN --exclude .svn GE2011.11/source/aimk gridscheduler-trunk/source/aimk
+--- GE2011.11/source/aimk	2011-11-14 12:01:16.000000000 -0700
++++ gridscheduler-trunk/source/aimk	2012-03-21 09:25:10.584917368 -0600
+@@ -58,6 +58,7 @@
+ set UNMODIFIED_ARGUMENTS = ( $argv )
+ set FORCE_32BIT = 0
+ set WERR        = 0
++set WEXTRA      = 0
+ set STACKPROTECT = 0
+ 
+ if ( -f dist/util/arch ) then
+@@ -149,81 +150,87 @@
+    echo "usage: aimk <OPTIONS>"
+    echo "OPTIONS are: "
+    echo ""
+-   echo "-32               -> create 32 bit binaries (where supported)"
+-   echo "-64               -> create 64 bit binaries (where supported)"
+-   echo "-D*               -> include a macro definition in CFLAGS"
+-   echo "-add-copyright    -> insert a special copyright string in each binary"
+-   echo "-add-sun-copyright-> insert a Sun copyright string in each binary" 
+-   echo "-adoc             -> create source code documentation in adoc format"
+-   echo "-catman           -> generate man pages in catman format"
+-   echo "-cc               -> use cc/CC to compile c/c++ code"
+-   echo "-cov              -> complile for code coverage analysis"
+-   echo "-dce              -> enable dce security"
+-   echo "-debug            -> compile with debug information"
+-   echo "-efence           -> compile in debug mode and detect memory leaks"
+-   echo "-f                -> specify other Makefile instead of common/Makefile"
+-   echo "-flags            -> print C_FLAGS and INCLUDE_FLAGS to stdout, used by gelint"
+-   echo "-gcc              -> use gcc instead of system compiler (where supported)"
+-   echo "-gettext          -> build the gettext libraries"
+-   echo "-gprof            -> enable gprof profiling"
+-   echo "-gss              -> enable gss security"
+-   echo "-help             -> show this help"
+-   echo "-htmlman          -> generate man and html pages"
+-   echo "-htmlmankv        -> generate man and html pages checked out with '-kv' flag"
+-   echo "-insure           -> compile in debug mode and detect memory leaks"
+-   echo "-intl             -> compile with internationalization library (libintl)"
+-   echo "-javadoc          -> create source code documentation in Javadoc[TM] tool format"
+-   echo "-kerberos         -> enable kerberos authentication"
+-   echo "-man              -> generate man pages"
+-   echo "-mankv            -> generate man pages checked out with '-kv' flag"
+-   echo "-mo               -> generate the message catalogues (Solaris only)"
+-   echo "-no-core          -> don't compile the core system"
+-   echo "-no-java          -> don't compile Java[TM] class files"
+-   echo "-no-gui-inst      -> don't compile Java[TM] GUI installer"
+-   echo "-no-jni           -> don't compile JNI library"
+-   echo "-no-intl          -> do not compile with internationalization library"
+-   echo "-no-mk            -> only return the specific architecture string"
+-   echo "-no-opt           -> compile with no optimization"
+-   echo "-no-perfstat      -> don't use Perfstat Library on AIX"
+-   echo "-no-qmake         -> don't compile qmake"
+-   echo "-no-qmon          -> don't compile qmon 3rdparty libs and qmon client"
+-   echo "-no-qtcsh         -> don't compile qtcsh"
+-   echo "-no-remote        -> don't compile 3rdparty remote module (rsh, rshd, rlogin)"
+-   echo "-no-rmon          -> disable rmon debug output"
+-   echo "-no-secure        -> disable ssl security (enabled by default)"
+-   echo "-no-jemalloc      -> disable jemalloc (enabled by default on Linux hosts)"
+-   echo "-no-mtmalloc      -> disable mtmalloc (this is needed for dbx debugging)"
+-   echo "-only-core        -> build only the core system"
+-   echo "-only-depend      -> only compile 3rdparty/sge_depend"
+-   echo "-only-java        -> only compile Java[TM] class files"
+-   echo "-only-gui-inst    -> only compile Java[TM] GUI installer"
+-   echo "-only-jemalloc    -> build only the jemalloc library"
+-   echo "-only-qmake       -> build only qmake"
+-   echo "-only-qmon        -> build only qmon 3rdparty libs and qmon client"
+-   echo "-only-qtcsh       -> build only qtcsh"
+-   echo "-only-remote      -> build only 3rdparty remote module (rsh, rshd, rlogin)"
+-   echo "-only-64          -> build only 64 bit shared libraries for SOLARIS64, don't build 32 bit shared libraries"
+-   echo "-parallel n       -> spawn multiple make processes by passing option -j n to make"
+-   echo "-po               -> merge gridengine .pot with translations (Linux)"
+-   echo "-pot              -> extract message template to gridengine .pot file (Linux)"
+-   echo "-protected        -> create complete class file documentation"
+-   echo "-purify           -> instrument code with purify (implies -debug)"
+-   echo "-qmake            -> use qmake instead of make"
+-   echo "-shared-libs      -> create libraries as shared libs"
+-   echo "-spool-berkeleydb -> use berkeleydb spooling"
+-   echo "-spool-classic    -> use classic flatfile spooling"
+-   echo "-spool-targets    -> only create qmaster, spooldefaults and spoolinit"
+-   echo "-sunman           -> create man pages for Sun branded man pages (with -man[kv])"
+-   echo "-tight-ssh        -> compile SSH daemon with tight SGE integration"
+-   echo "-umap             -> compile with usermapping and hostgroup feature"
+-   echo "-werror           -> turn all compiler warnings into errors"
+-   echo "-with-jemalloc    -> build SGE with the jemalloc library"
++   echo " -32               -> create 32 bit binaries (where supported)"
++   echo " -64               -> create 64 bit binaries (where supported)"
++   echo " -D*               -> include a macro definition in CFLAGS"
++   echo " -add-copyright    -> insert a special copyright string in each binary"
++   echo " -add-sun-copyright-> insert a Sun copyright string in each binary" 
++   echo " -adoc             -> create source code documentation in adoc format"
++   echo " -catman           -> generate man pages in catman format"
++   echo " -cc               -> use cc/CC to compile c/c++ code"
++   echo " -cov              -> complile for code coverage analysis"
++   echo " -dce              -> enable dce security"
++   echo " -debug            -> compile with debug information"
++   echo " -efence           -> compile in debug mode and detect memory leaks"
++   echo " -f                -> specify other Makefile instead of common/Makefile"
++   echo " -flags            -> print C_FLAGS and INCLUDE_FLAGS to stdout, used by gelint"
++   echo " -gcc              -> use gcc instead of system compiler (where supported)"
++   echo " -gettext          -> build the gettext libraries"
++   echo " -gprof            -> enable gprof profiling"
++   echo " -gss              -> enable gss security"
++   echo " -help             -> show this help"
++   echo " -htmlman          -> generate man and html pages"
++   echo " -htmlmankv        -> generate man and html pages checked out with '-kv' flag"
++   echo " -insure           -> compile in debug mode and detect memory leaks"
++   echo " -intl             -> compile with internationalization library (libintl)"
++   echo " -javadoc          -> create source code documentation in Javadoc[TM] tool format"
++   echo " -kerberos         -> enable kerberos authentication"
++   echo " -man              -> generate man pages"
++   echo " -mankv            -> generate man pages checked out with '-kv' flag"
++   echo " -mo               -> generate the message catalogues (Solaris only)"
++   echo " -no-core          -> don't compile the core system"
++   echo " -no-java          -> don't compile Java[TM] class files"
++   echo " -no-gui-inst      -> don't compile Java[TM] GUI installer"
++   echo " -no-jni           -> don't compile JNI library"
++   echo " -no-intl          -> do not compile with internationalization library"
++   echo " -no-mk            -> only return the specific architecture string"
++   echo " -no-opt           -> compile with no optimization"
++   echo " -no-perfstat      -> don't use Perfstat Library on AIX"
++   echo " -no-qmake         -> don't compile qmake"
++   echo " -no-qmon          -> don't compile qmon 3rdparty libs and qmon client"
++   echo " -no-qtcsh         -> don't compile qtcsh"
++   echo " -no-remote        -> don't compile 3rdparty remote module (rsh, rshd, rlogin)"
++   echo " -no-rmon          -> disable rmon debug output"
++   echo " -no-secure        -> disable ssl security (enabled by default)"
++   echo " -no-jemalloc      -> disable jemalloc (enabled by default on Linux hosts)"
++   echo " -no-mtmalloc      -> disable mtmalloc (this is needed for dbx debugging)"
++   echo " -only-core        -> build only the core system"
++   echo " -only-depend      -> only compile 3rdparty/sge_depend"
++   echo " -only-java        -> only compile Java[TM] class files"
++   echo " -only-gui-inst    -> only compile Java[TM] GUI installer"
++   echo " -only-jemalloc    -> build only the jemalloc library"
++   echo " -only-qmake       -> build only qmake"
++   echo " -only-qmon        -> build only qmon 3rdparty libs and qmon client"
++   echo " -only-qtcsh       -> build only qtcsh"
++   echo " -only-remote      -> build only 3rdparty remote module (rsh, rshd, rlogin)"
++   echo " -only-64          -> build only 64 bit shared libraries for SOLARIS64, don't build 32 bit shared libraries"
++   echo " -parallel n       -> spawn multiple make processes by passing option -j n to make"
++   echo " -po               -> merge gridengine .pot with translations (Linux)"
++   echo " -pot              -> extract message template to gridengine .pot file (Linux)"
++   echo " -protected        -> create complete class file documentation"
++   echo " -purify           -> instrument code with purify (implies -debug)"
++   echo " -qmake            -> use qmake instead of make"
++   echo " -shared-libs      -> create libraries as shared libs"
++   echo " -spool-berkeleydb -> use berkeleydb spooling"
++   echo " -spool-classic    -> use classic flatfile spooling"
++   echo " -spool-targets    -> only create qmaster, spooldefaults and spoolinit"
++   echo " -sunman           -> create man pages for Sun branded man pages (with -man[kv])"
++   echo " -tight-ssh        -> compile SSH daemon with tight SGE integration"
++   echo " -umap             -> compile with usermapping and hostgroup feature"
++   echo " -werror           -> turn all compiler warnings into errors"
++   echo " -wextra           -> turn on extra compiler warnings"
++   echo " -with-jemalloc    -> build SGE with the jemalloc library"
++   echo ""
++   echo "Linking against system libraries"
++   echo " -sys-hwloc        -> use the hwloc library provided by the system"
++   echo " -sys-jemalloc     -> use the jemalloc library provided by the system"
++   echo " -sys-libssl       -> use the ssl library provided by the system"
+    echo ""
+    echo "Deprecated Features (support will be removed by 2013 Q3)"
+-   echo "-plpa                 -> PLPA hardware topology support"
+-   echo "-solaris-pset         -> enable Solaris Processor Set binding support"
+-   echo "-spool-berkeleydb-rpc -> enable BerkeleyDB RPC server support"
+-   echo "-DOGLIBC_LINUX        -> support glibc 2.1 or older (Linux only)"
++   echo " -plpa                 -> PLPA hardware topology support"
++   echo " -solaris-pset         -> enable Solaris Processor Set binding support"
++   echo " -spool-berkeleydb-rpc -> enable BerkeleyDB RPC server support"
++   echo " -DOGLIBC_LINUX        -> support glibc 2.1 or older (Linux only)"
+ 
+   exit
+ }
+@@ -257,12 +264,14 @@
+ set REMOTE           = 1
+ set QMAKE            = 1
+ set QMAKELIB         = ""
++set QTCSH            = 1
+ set PLPA             = 0
+ set HWLOC            = 1
+ set HWLOC_CFLAGS     = "-O2"
+-set QTCSH            = 1
+-set MAKEMTMALLOCLIB  = 1
++set MAKEHWLOC        = 1
+ set MAKEJEMALLOCLIB  = 0
++set LINKJEMALLOCLIB  = 0
++set LINKMTMALLOCLIB  = 1
+ set MAKESTRPTIME     = 0
+ set MAKESNPRINTF     = 0
+ set MAKEFNMATCH      = 0
+@@ -285,7 +294,7 @@
+ set CC               = cc
+ set CXX              = CC
+ set CFLAGS           = "-D$TARGET_BITS $INP_CFLAGS"
+-set CORE_INCLUDE     = "-I../common -I../libs -I../libs/uti -I../libs/juti -I../libs/gdi -I../libs/japi -I../libs/sgeobj -I../libs/cull -I../libs/rmon -I../libs/comm -I../libs/comm/lists -I../libs/sched -I../libs/evc -I../libs/evm -I../libs/mir -I../libs/lck -I../daemons/common -I../daemons/qmaster -I../daemons/execd -I../daemons/schedd -I../clients/common -I."
++set CORE_INCLUDE     = "-I../common -I../libs -I../libs/uti -I../libs/juti -I../libs/gdi -I../libs/japi -I../libs/sgeobj -I../libs/cull -I../libs/rmon -I../libs/comm -I../libs/comm/lists -I../libs/sched -I../libs/evc -I../libs/evm -I../libs/mir -I../libs/lck -I../daemons/common -I../daemons/qmaster -I../daemons/execd -I../clients/common -I."
+ set DEBUG_FLAG       = ""
+ set INSURE_FLAG      = ""
+ set JEMALLOC_CFLAGS  = ""
+@@ -308,6 +317,7 @@
+ set LFLAGS           = "-L."
+ set XLFLAGS          = ""
+ set XLIBS            = ""
++set XMLIBS           = ""
+ set LIBS             = "-lm -lpthread"
+ set LIBRARY_LIBS     = ""  # used for linking shared objects like drmaa.so or jgdi.so. Overwritten by $LIBS if empty
+ set LD_WRAPPER       = ""
+@@ -429,6 +439,7 @@
+ switch ($BUILDARCH) 
+    case LINUXX64:
+      set MAKEJEMALLOCLIB  = 1
++     set LINKJEMALLOCLIB  = 1
+      set WITH_GETTEXT = 1
+      breaksw
+    case LINUX*:
+@@ -508,6 +519,7 @@
+       set QMAKE  = 0
+       set PLPA   = 0
+       set HWLOC  = 0
++      set MAKEHWLOC = 0
+       set QMON   = 0
+       set QTCSH  = 0
+       set REMOTE = 0
+@@ -631,7 +643,7 @@
+       set BUILDMAN   = 1
+       set KVMAN      = 1
+       breaksw
+-   case  "-mo"
++   case "-mo"
+       echo "BUILDARCH=$BUILDARCH"
+       if ( $BUILDARCH == sol-sparc || $BUILDARCH == sol-sparc64 ) then
+          scripts/msgmerge.csh
+@@ -646,16 +658,16 @@
+    case "-no-dump":
+       set DUMP = 0
+       breaksw
+-   case  "-no-java"
++   case "-no-java"
+       set JAVA = 0
+       breaksw
+-   case  "-no-gui-inst"
++   case "-no-gui-inst"
+       set JAVA_GUI_INST = 0
+       breaksw
+-   case  "-no-jni"
++   case "-no-jni"
+       set JNI = 0
+       breaksw
+-   case  "-no-intl"
++   case "-no-intl"
+       set WITH_GETTEXT = 0
+       breaksw
+    case "-no-mk":
+@@ -692,20 +704,24 @@
+       breaksw
+    case "-no-jemalloc":
+       set MAKEJEMALLOCLIB = 0
++      set LINKJEMALLOCLIB = 0
+       breaksw
+    case "-plpa":
+       set PLPA = 1
+       set HWLOC = 0
++      set MAKEHWLOC = 0
+       breaksw
+    case "-solaris-pset":
+       set SOLARISPSET = 1
+       set HWLOC = 0
++      set MAKEHWLOC = 0
+       breaksw
+    case "-no-hwloc":
+       set HWLOC = 0
++      set MAKEHWLOC = 0
+       breaksw
+    case "-no-mtmalloc":
+-      set MAKEMTMALLOCLIB = 0
++      set LINKMTMALLOCLIB = 0
+       breaksw
+    case "-only-core":
+       set CORE   = 1
+@@ -714,6 +730,7 @@
+       set QMAKE  = 0
+       set PLPA   = 0
+       set HWLOC  = 0
++      set MAKEHWLOC = 0
+       set QMON   = 0
+       set QTCSH  = 0
+       set REMOTE = 0
+@@ -728,20 +745,22 @@
+       set QMAKE      = 0
+       set PLPA       = 0
+       set HWLOC      = 0
++      set MAKEHWLOC  = 0
+       set QMON       = 0
+       set QTCSH      = 0
+       set REMOTE     = 0
+       set SGE_DEPEND = 1
+       set MAKEWINGRIDAPP = 0
+       set MAKEWINGRIDLIB = 0
+-      set MAKEJEMALLOCLIB  = 0
++      set MAKEJEMALLOCLIB = 0
++      set LINKJEMALLOCLIB = 0
+       set ONLY_PARAM_SPEC = 1
+       breaksw
+-   case  "-only-java"
++   case "-only-java"
+       set JAVA = 2
+       set ONLY_PARAM_SPEC = 1
+       breaksw
+-   case  "-only-gui-inst"
++   case "-only-gui-inst"
+       set JAVA_GUI_INST = 2
+       set ONLY_PARAM_SPEC = 1
+       breaksw
+@@ -754,7 +773,8 @@
+       set QMON   = 0
+       set QTCSH  = 0
+       set REMOTE = 0
+-      set MAKEJEMALLOCLIB  = 1
++      set MAKEJEMALLOCLIB = 1
++      set LINKJEMALLOCLIB = 1
+       set MAKEWINGRIDAPP = 0
+       set MAKEWINGRIDLIB = 0
+       set ONLY_PARAM_SPEC = 1
+@@ -766,6 +786,7 @@
+       set QMAKE  = 1
+       set PLPA   = 0
+       set HWLOC  = 0
++      set MAKEHWLOC = 0
+       set QMON   = 0
+       set QTCSH  = 0
+       set REMOTE = 0
+@@ -776,6 +797,7 @@
+    case "-only-plpa":
+       set PLPA   = 1
+       set HWLOC  = 0
++      set MAKEHWLOC = 0
+       set CORE   = 0
+       set JAVA   = 0
+       set JAVA_GUI_INST = 0
+@@ -794,6 +816,7 @@
+       set QMAKE  = 0
+       set PLPA   = 0
+       set HWLOC  = 0
++      set MAKEHWLOC = 0
+       set QMON   = 1
+       set QTCSH  = 0
+       set REMOTE = 0
+@@ -808,6 +831,7 @@
+       set QMAKE  = 0
+       set PLPA   = 0
+       set HWLOC  = 0
++      set MAKEHWLOC = 0
+ 
+       set QMON   = 0
+       set QTCSH  = 1
+@@ -823,6 +847,7 @@
+       set QMAKE  = 0
+       set PLPA   = 0
+       set HWLOC  = 0
++      set MAKEHWLOC = 0
+       set QMON   = 0
+       set QTCSH  = 0
+       set REMOTE = 0
+@@ -837,6 +862,7 @@
+       set QMAKE  = 0
+       set PLPA   = 0
+       set HWLOC  = 0
++      set MAKEHWLOC = 0
+       set QMON   = 0
+       set QTCSH  = 0
+       set REMOTE = 1
+@@ -855,7 +881,7 @@
+       set PERLGUI = "perlgui_all"
+       set PERLGUI_CLEAN = "perlgui_clean"
+       breaksw
+-   case  "-po"
++   case "-po"
+       if ( $buildarch == linux-x86 ) then
+          scripts/msgmerge.csh merge
+          echo ""
+@@ -867,7 +893,7 @@
+       endif
+       exit 0
+       breaksw
+-   case  "-pot"
++   case "-pot"
+       if ( $buildarch != linux-x86 ) then
+          echo "Must be done on linux-86 architecture"
+          exit 1
+@@ -903,14 +929,6 @@
+       breaksw
+    case "-plpa" 
+       breaksw
+-   case "-secure"
+-      echo "___________W_A_R_N_I_N_G_____________"
+-      echo "The -secure option is no longer supported as security is now enabled"
+-      echo "by default.  Please remove the -secure option from your aimk.site and"
+-      echo "aimk.private files.  To disable security, you may use the -no-secure"
+-      echo "option."
+-      echo
+-      breaksw
+    case "-shared-libs":
+       set SHAREDLIBS = 1
+       breaksw
+@@ -943,6 +961,17 @@
+    case "-sunman":
+       set SGE_PRODUCT_MODE=sge
+       breaksw
++   case "-sys-jemalloc":
++      setenv SGE_SYSJEMALLOC "SGE_SYSJEMALLOC"
++      breaksw
++   case "-sys-hwloc":
++      setenv SGE_SYSHWLOC "SGE_SYSHWLOC"
++      breaksw
++   case "-sys-libssl":
++      set SECFLAGS="-DSECURE"
++      set SECLIBS_STATIC="-lssl -lcrypto"
++      set KLFLAGS=""
++      breaksw
+    case "-umap"
+       set WITH_USERMAPPING = 1
+       breaksw
+@@ -952,11 +981,15 @@
+    case "-werror":
+       set WERR = 1
+       breaksw
++   case "-wextra":
++      set WEXTRA = 1
++      breaksw
+    case "-stackprotect":
+       set STACKPROTECT = 1
+       breaksw
+    case "-with-jemalloc"
+       set MAKEJEMALLOCLIB = 1
++      set LINKJEMALLOCLIB = 1
+       breaksw
+    default:
+       unset found
+@@ -974,6 +1007,16 @@
+    set MAKEOPT = "-verbose $MAKEOPT"
+ endif
+ 
++if ( $?SGE_SYSJEMALLOC ) then
++   set MAKEJEMALLOCLIB = 0
++   set LINKJEMALLOCLIB = 1
++endif
++
++if ( $?SGE_SYSHWLOC ) then
++   set MAKEHWLOC = 0
++endif
++
++
+ set CFLAGS = "$CFLAGS -DSPOOLING_$SPOOLING_METHOD $SECFLAGS"
+ 
+ #---------------------------------------------------------------------------
+@@ -1022,25 +1065,10 @@
+    endif
+ endif
+ 
+-#---------------------------------------------------------------------------
+-if ( $JAVA > 0 || $BUILDJAVADOC == 1 || $JNI == 1 ) then
+-   # Make sure we can find JAVA_HOME
+-   if ( ${?JAVA_HOME} == 0 ) then
+-      echo "Please set JAVA_HOME"
+-      exit 1
+-   endif
+-   if ( ${JAVA_HOME} == "/usr" ) then
+-      echo 'Warning:'
+-      echo 'Setting $JAVA_HOME to "/usr" causes problems on some systems, '
+-      echo 'because the associated include path will be "/usr/include", '
+-      echo 'which is a reserved system include path.'
+-      echo
+-   endif
+-endif
+ 
+ switch ($BUILDARCH)
+ case AIX43:
+-case AIX51:
++case AIX:
+    set MAKEWINGRIDLIB   = 0
+    set MAKEWINGRIDAPP   = 0
+    set COMPILE_DC = 1
+@@ -1054,11 +1082,13 @@
+    if ( $DEBUGGED == 1 ) then
+       set DEBUG_FLAG = "$DEBUG_FLAG -qinitauto=01 -qro -qroconst"
+    endif
++
+    if ( $OPTIMIZATION == 1 ) then
+       set OFLAG = "-O3 -qstrict -qmaxmem=8192"
+    else
+       set OFLAG    = "-qmaxmem=8192"
+    endif
++
+    set CC       = xlc_r
+    set CXX      = xlC_r
+    set CFLAGS   = "$OFLAG -DAIX -D$BUILDARCH -D_LARGE_FILES -DUSE_STDARG -DUSE_SGE_UNSETENV -DGETHOSTBYADDR_R5 -DGETHOSTBYNAME_R3 $DEBUG_FLAG $CFLAGS -bnoquiet"
+@@ -1069,9 +1099,11 @@
+    set XLIBD    = ""
+    set XLFLAGS  = "$XLIBD"
+    set XLIBS    = "-lXm  -lXt -lXext -lX11 -lm -liconv -lc"
++   set XMLIBS   = "$XLIBS"
+ 
+    if ("$PERFSTAT" == 1) then
+       set CFLAGS = "$CFLAGS -DHAS_AIX_PERFLIB"
++      set LFLAGS = "$LFLAGS -lperfstat"
+    endif
+ 
+    if ("$WERR" == 1) then
+@@ -1133,16 +1165,19 @@
+    set XLIBD    = ""
+    set XLFLAGS  = "-taso $XLIBD"
+    set XLIBS    = "-lXm -lXt -lXext -lX11 -lSM -lICE -lPW -ldnet_stub"
++   set XMLIBS   = "$XLIBS"
+    set LIBS     = "-lpset -lmach $LIBS"
+    set JAVA_ARCH = "alpha"
+    breaksw
+ 
+ case DARWIN_X86:
++case DARWIN_X64:
+ case DARWIN_PPC:
+    set MAKEWINGRIDLIB   = 0
+    set MAKEWINGRIDAPP   = 0
+    set COMPILE_DC = 1
+    set HWLOC      = 0
++   set MAKEHWLOC  = 0
+ 
+    if ( $OPTIMIZATION == 1 ) then
+       set OFLAG = "-O3"
+@@ -1167,28 +1202,29 @@
+       set DEBUG_FLAG = "$DEBUG_FLAG -fprofile-arcs -ftest-coverage"
+    endif
+ 
++   if ($BUILDARCH == "DARWIN_X86") then
++      set X86_ARCH = "-arch i386"
++   else if ($BUILDARCH == "DARWIN_X64") then
++      set X86_ARCH = "-arch x86_64"
++   else
++      set X86_ARCH = ""
++   endif
++
+    set REL = `/usr/bin/uname -r`
+    switch ($REL)
+    case "6.*":
+       set CFLAGS = "$OFLAG -no-cpp-precomp -flat_namespace -Wall -Wstrict-prototypes -DFD_SETSIZE=8192 -DDARWIN -DDARWIN6 -D$BUILDARCH -DGETHOSTBYNAME -DGETHOSTBYADDR_M $DEBUG_FLAG $CFLAGS"
+       breaksw
++
+    case "7.*":
+-      set CFLAGS = "$OFLAG -no-cpp-precomp -flat_namespace -Wall -Wstrict-prototypes -DFD_SETSIZE=8192 -DDARWIN -DDARWIN7 -D$BUILDARCH -DGETHOSTBYNAME -DGETHOSTBYADDR_M $DEBUG_FLAG $CFLAGS"
+-      breaksw
+    case "8.*":
+-      set CFLAGS = "$OFLAG -no-cpp-precomp -flat_namespace -Wall -Wstrict-prototypes -DFD_SETSIZE=8192 -DDARWIN -DDARWIN8 -D$BUILDARCH -DGETHOSTBYNAME -DGETHOSTBYADDR_M $DEBUG_FLAG $CFLAGS"
+-      breaksw
+-   case "9.*":
+-      set CFLAGS = "$OFLAG -no-cpp-precomp -flat_namespace -Wall -Wstrict-prototypes -DFD_SETSIZE=8192 -DDARWIN -DDARWIN9 -D$BUILDARCH -DGETHOSTBYNAME -DGETHOSTBYADDR_M $DEBUG_FLAG $CFLAGS"
+-      breaksw
+-   case "10.*":
+-      set CFLAGS = "$OFLAG -no-cpp-precomp -flat_namespace -arch i386 -Wall -Wno-format -Wstrict-prototypes -DFD_SETSIZE=8192 -DDARWIN -DDARWIN10 -D$BUILDARCH -DGETHOSTBYNAME -DGETHOSTBYADDR_M $DEBUG_FLAG $CFLAGS"
+-      set SHARED_LFLAGS = "$SHARED_LFLAGS -arch i386"
+-      set LFLAGS = "$LFLAGS -arch i386"
++      set CFLAGS = "$OFLAG -no-cpp-precomp -flat_namespace -Wall -Wstrict-prototypes -DFD_SETSIZE=8192 -DDARWIN -D$BUILDARCH -DGETHOSTBYNAME -DGETHOSTBYADDR_M $DEBUG_FLAG $CFLAGS"
+       breaksw
++
+    default:
+-      echo DARWIN release \"$REL\" not supported!
+-      exit 1
++      set CFLAGS = "$OFLAG -no-cpp-precomp -flat_namespace -Wall -Wno-format -Wstrict-prototypes -DFD_SETSIZE=8192 -DDARWIN -DDARWIN9 -D$BUILDARCH -DGETHOSTBYNAME -DGETHOSTBYADDR_M $DEBUG_FLAG $CFLAGS $X86_ARCH"
++      set SHARED_LFLAGS = "$SHARED_LFLAGS $X86_ARCH"
++      set LFLAGS        = "$LFLAGS        $X86_ARCH"
+       breaksw
+    endsw
+ 
+@@ -1196,6 +1232,10 @@
+       set CFLAGS = "$CFLAGS -Werror"
+    endif
+ 
++   if ("$WEXTRA" == 1) then
++      set CFLAGS = "$CFLAGS -Wextra"
++   endif
++
+    if ("$STACKPROTECT" == 1) then
+       set CFLAGS = "$CFLAGS -fstack-protector-all"
+    endif
+@@ -1225,23 +1265,12 @@
+    set XCFLAGS  = "-DNeedFunctionPrototypes -DNeedVarargsPrototypes -Wno-error $XMTDEF $XINCD $XCFLAGS"
+    set XLIBD    = "-L$MOTIFHOME/lib -L/usr/X11R6/lib"
+    set XLIBS    = "-lXm -lXpm -lXt -lXext -lX11 -lSM -lICE"
++   set XMLIBS   = "$XLIBS"
+    if ("$ADOC" == 1) then
+       set CFLAGS = "$CFLAGS -Wno-error"
+    endif
+ 
+-   switch ($REL)
+-   case "6.*":
+-   case "7.*":
+-   case "8.*":
+-   case "9.*":
+-   case "10.*":
+-      set XLFLAGS = "$XLIBD"
+-      breaksw
+-   default:
+-      echo DARWIN release \"$REL\" not supported!
+-      exit 1
+-      breaksw
+-   endsw
++   set XLFLAGS = "$XLIBD"
+ 
+    set NOERR_CFLAG = "-Wno-error"
+    set NOERR_PROTO = "-Wno-strict-prototypes"
+@@ -1268,9 +1297,9 @@
+    set CC       = gcc
+    set CXX      = g++
+    set DLLIB	 = ""
+-   set DEPEND_FLAGS = "$CFLAGS $XMTINCD"
+    set PTHRDSFLAGS = "-D_REENTRANT -D__USE_REENTRANT"
+    set CFLAGS   = "$OFLAG -Wall -DFREEBSD -D$BUILDARCH -DGETHOSTBYNAME_M -DGETHOSTBYADDR_M $DEBUG_FLAG $CFLAGS -I/usr/X11R6/include"
++   set DEPEND_FLAGS = "$CFLAGS $XMTINCD"
+    set NOERR_CFLAG = "-Wno-error"
+    set LFLAGS   = "$DEBUG_FLAG $LFLAGS -export-dynamic"
+    set LIBS     = "$LIBS -lkvm"
+@@ -1285,6 +1314,7 @@
+    set XLIBD    = "-L/usr/X11R6/lib"
+    set XLFLAGS  = "$XLIBD"
+    set XLIBS    = " -Xlinker -lXm -Xlinker -Bdynamic -lXpm -lXt -lXext -lX11 -lSM -lICE -lXp"
++   set XMLIBS   = "$XLIBS"
+    set RM	= "rm -f"
+    set JAVA_ARCH = "linux"
+    breaksw 
+@@ -1293,15 +1323,19 @@
+    set MAKEWINGRIDLIB   = 0
+    set MAKEWINGRIDAPP   = 0
+    set COMPILE_DC = 1
++
++   set HWLOC      = 0
++   set MAKEHWLOC  = 0
++
+    set MAKE = gmake
+    set OFLAG = "-O"
+    set ARFLAGS  = rcv
+    set CC       = gcc
+    set CXX      = g++
+    set DLLIB    = ""
+-   set DEPEND_FLAGS = "$CFLAGS $XMTINCD"
+    set PTHRDSFLAGS = "-D_REENTRANT -D__USE_REENTRANT"
+    set CFLAGS   = "$OFLAG -Wall -DNETBSD -D$BUILDARCH -DGETHOSTBYNAME_M -DGETHOSTBYADDR_M $DEBUG_FLAG $CFLAGS -I/usr/X11R6/include"
++   set DEPEND_FLAGS = "$CFLAGS $XMTINCD"
+    set NOERR_CFLAG = "-Wno-error"
+    set LFLAGS   = "$DEBUG_FLAG $LFLAGS -export-dynamic"
+    set LIBS     = "$LIBS -lkvm"
+@@ -1316,6 +1350,7 @@
+    set XLIBD    = "-L/usr/X11R6/lib -R/usr/X11R6/lib -L/usr/pkg/lib -R /usr/pkg/lib"
+    set XLFLAGS  = "$XLIBD"
+    set XLIBS    = " -lXm -lXpm -lXt -lXext -lX11 -lSM -lICE -lXp"
++   set XMLIBS   = "$XLIBS"
+    set RM       = "rm -f"
+    set JAVA_ARCH = "netbsd"
+    breaksw
+@@ -1340,6 +1375,9 @@
+    set COMPILE_DC = 1
+    set MAKE = gmake
+ 
++   set HWLOC      = 0
++   set MAKEHWLOC  = 0
++
+    set CFLAGS   = "$OFLAG -Werror -woff 1035,3201,3496 -n32 -mips3 -mp -DFD_SETSIZE=8192 -DIRIX -D$BUILDARCH -DGETHOSTBYNAME_M -DGETHOSTBYADDR_M $DEBUG_FLAG -DUSE_SGE_UNSETENV $CFLAGS"
+    set NOERR_CFLAG = "-woff 47,1110,1174,1209"
+    set DEPEND_FLAGS = "$CFLAGS $XMTINCD"
+@@ -1351,6 +1389,7 @@
+    set XLIBD    = ""
+    set XLFLAGS  = "$XLIBD"
+    set XLIBS    = "-lXm -lXt -lXext -lX11 -lPW -lm"
++   set XMLIBS   = "$XLIBS"
+    set RANLIB   = echo
+ 
+    # set SONAME_LFLAG_DRMAA10 = "-W l,-soname,libdrmaa.so.1.0"
+@@ -1433,6 +1472,7 @@
+    set XLIBD    = ""
+    set XLFLAGS  = "$XLIBD"
+    set XLIBS    = "-lXm -lXt -lXext -lXhp11 -lX11 -lm"
++   set XMLIBS   = "$XLIBS"
+ 
+    set SHAREDEXT = ".sl"
+    set JAVA_ARCH = "hp-ux"
+@@ -1456,19 +1496,7 @@
+    breaksw
+    
+ case ALINUX:
+-case LINUXARM:
+-case LINUXARM64:
+-case LINUXIA64:
+-case LINUXMIPS:
+-case LINUXMIPS64:
+-case LINUXPPC:
+-case LINUXPPC64:
+-case LINUXS390:
+-case LINUXS390X:
+-case LINUXSPARC:
+-case LINUXSPARC64:
+-case LINUX86:
+-case LINUXX64:
++case LINUX*:
+    set MAKEWINGRIDLIB   = 0
+    set MAKEWINGRIDAPP   = 0
+    set AUTHLIBS = "-lcrypt -lpam"
+@@ -1532,14 +1560,17 @@
+       endif
+    endif
+ 
+-   set CFLAGS = "$CFLAGS -Wno-strict-aliasing"
+-
+-   set CFLAGS = "$OFLAG -Wall -Wstrict-prototypes -DUSE_POLL -DLINUX -D$BUILDARCH -D$COMPILE_ARCH -D_GNU_SOURCE -DGETHOSTBYNAME_R6 -DGETHOSTBYADDR_R8 -DHAS_VSNPRINTF $DEBUG_FLAG $CFLAGS"
++   set CFLAGS = "$OFLAG -Wall -Wstrict-prototypes -DUSE_POLL -DLINUX -DLINUX_NATIVE -D$BUILDARCH -D$COMPILE_ARCH -D_GNU_SOURCE -DGETHOSTBYNAME_R6 -DGETHOSTBYADDR_R8 -DHAS_VSNPRINTF $DEBUG_FLAG $CFLAGS"
+ 
+    if ("$WERR" == 1) then
++      set CFLAGS = "$CFLAGS -Wno-strict-aliasing"
+       set CFLAGS = "$CFLAGS -Werror"
+    endif
+ 
++   if ("$WEXTRA" == 1) then
++      set CFLAGS = "$CFLAGS -Wextra"
++   endif
++
+    if ("$STACKPROTECT" == 1) then
+       set CFLAGS = "$CFLAGS -fstack-protector-all"
+    endif
+@@ -1547,9 +1578,11 @@
+    if ("$ADOC" == 1) then
+       set CFLAGS = "$CFLAGS -Wno-error"
+    endif
++
+    if ( $TARGET_BITS == TARGET_32BIT ) then
+       set CFLAGS = "$CFLAGS -D_FILE_OFFSET_BITS=64"
+    endif
++
+    set LFLAGS   = "$DEBUG_FLAG $LFLAGS"
+ 
+    set SHAREDLD = $CC
+@@ -1608,6 +1641,8 @@
+       set XCFLAGS  = "-DNeedFunctionPrototypes -Wno-error $XMTDEF $XINCD $XCFLAGS"
+       set XLIBS    = "-Xlinker -Bstatic -Xlinker -Bdynamic -lXpm -lXt -lXext -lX11 -lSM -lICE -lXp -lXm"
+    endif
++   set XMLIBS   = "-lXt -lXm -lX11"
++
+    set JAVA_ARCH = "linux"
+ 
+    # due to -rpath relative_path the LD_LIBRARY_PATH not needed anymore
+@@ -1618,16 +1653,118 @@
+    if ( $COMPILE_ARCH == "ULINUX86" || $COMPILE_ARCH == "ULINUXX64" ) then
+       echo "Ignore jemalloc for unsupported architectures!"
+       set MAKEJEMALLOCLIB = 0
++      set LINKJEMALLOCLIB = 0
+    endif
+ 
+    if ( $MAKEJEMALLOCLIB == 1 ) then
+-      set LIBRARY_LIBS = "$LIBS"
+       set JEMALLOC_CFLAGS  = "-Wno-error -DMOZ_MEMORY_LINUX"
++   endif
++
++   if ( $LINKJEMALLOCLIB == 1) then
++      set LIBRARY_LIBS = "$LIBS"
+       set LIBS = "-ljemalloc $LIBS"
+    endif
+ 
+    breaksw
+-   
++
++case CYGWIN_X86:
++   set MAKEWINGRIDLIB   = 0
++   set MAKEWINGRIDAPP   = 0
++   set AUTHLIBS = "-lcrypt -lpam"
++
++   set COMPILE_DC = 1
++
++   if ($OPTIMIZATION == 1 ) then
++      set OFLAG = "-O2"
++   else
++      set OFLAG = ""
++   endif
++
++   set HWLOC      = 0
++   set MAKEHWLOC  = 0
++
++   set CC  = gcc
++   set CXX = g++
++
++   if ($DEBUGGED == 1) then
++      set DEBUG_FLAG = "-g $INSURE_FLAG -DSGE_LOCK_DEBUG"
++   endif
++
++   if ($GPROFFED == 1) then
++      set DEBUG_FLAG = "$DEBUG_FLAG -pg"
++   endif
++
++   if ($COVED == 1) then
++      set DEBUG_FLAG = "$DEBUG_FLAG -fprofile-arcs -ftest-coverage"
++   endif
++
++   set CFLAGS = "$CFLAGS -Wno-strict-aliasing"
++
++   set CFLAGS = "$OFLAG -Wall -Wstrict-prototypes -DUSE_POLL -DLINUX -DOGLIBC_LINUX -DCYGWIN -D$BUILDARCH -D$COMPILE_ARCH -D_GNU_SOURCE -DGETHOSTBYNAME -DGETHOSTBYADDR -DHAS_VSNPRINTF $DEBUG_FLAG $CFLAGS"
++
++   if ("$WERR" == 1) then
++      set CFLAGS = "$CFLAGS -Werror"
++   endif
++
++   if ("$WEXTRA" == 1) then
++      set CFLAGS = "$CFLAGS -Wextra"
++   endif
++
++   if ("$STACKPROTECT" == 1) then
++      set CFLAGS = "$CFLAGS -fstack-protector-all"
++   endif
++
++   if ("$ADOC" == 1) then
++      set CFLAGS = "$CFLAGS -Wno-error"
++   endif
++
++   if ( $TARGET_BITS == TARGET_32BIT ) then
++      set CFLAGS = "$CFLAGS -D_FILE_OFFSET_BITS=64"
++   endif
++
++   set LFLAGS   = "$DEBUG_FLAG $LFLAGS"
++
++   set SHAREDLD = $CC
++   set SHARED_LFLAGS = "$SHARED_LFLAGS -L. -shared"
++
++   set SONAME_LFLAG_DRMAA10 = "-Wl,-soname,libdrmaa.so.1.0"
++   set SONAME_LFLAG_DRMAA95 = "-Wl,-soname,libdrmaa.so.0.95"
++
++   set SHAREDEXT = ".dll"
++
++   if ( $SHAREDLIBS == 1 || $SPOOLING_METHOD == dynamic ) then
++      set LFLAGS = "$LFLAGS -rdynamic"
++   endif
++
++   set NOERR_CFLAG = "-Wno-error"
++   set NOERR_PROTO = "-Wno-strict-prototypes"
++
++   set XMTDEF   = ""
++
++   if ($TARGET_BITS == TARGET_32BIT ) then
++      set XLIBD    = "-L/usr/X11R6/lib"
++   else
++      set XLIBD    = "-L/usr/X11R6/lib64"
++   endif
++
++   set XLFLAGS  = "$XLIBD"
++
++   set DEPEND_FLAGS = "$CFLAGS $XMTINCD"
++
++   set XINCD    = "$XMTINCD $XINCD -I/usr/X11R6/include"
++   set XCFLAGS  = "-Wno-strict-prototypes -Wno-error $XMTDEF $XINCD $XCFLAGS"
++   set XLIBS    = "-lXm -lXpm -lXt -lXext -lXmu -lX11 -lSM -lICE -lXp"
++   set XMLIBS   = "$XLIBS"
++
++   set JAVA_ARCH = "linux"
++
++   # due to -rpath relative_path the LD_LIBRARY_PATH not needed anymore
++   set RUNPATH       = -Wl,-rpath,'\$$ORIGIN'/../../lib/$buildarch
++   set LFLAGS        = "$LFLAGS $RUNPATH"
++   set SHARED_LFLAGS = "$SHARED_LFLAGS $RUNPATH"
++
++   breaksw
++
+ case WIN32_X86:
+    setenv LD_LIBRARY_PATH /usr/lib/x86:/usr/local/lib
+    set CC = gcc
+@@ -1644,6 +1781,7 @@
+    set WITH_USERMAPPING = 0 # Compile without usermapping feature
+    set COMPILE_DC       = 1
+    set HWLOC            = 0
++   set MAKEHWLOC        = 0
+    set AUTHLIBS         = ""
+    set JUTI_ALL         = ""
+    set JUTI_DEPEND      = ""
+@@ -1684,6 +1822,10 @@
+       if ("$WERR" == 1) then
+         set CFLAGS = "$CFLAGS -Werror"
+       endif
++
++      if ("$WEXTRA" == 1) then
++        set CFLAGS = "$CFLAGS -Wextra"
++      endif
+    else
+       set CC  = cc
+       set CXX = cc
+@@ -1722,6 +1864,7 @@
+    set XINCD        = "$XMTINCD $XINCD -I/usr/X11R6/include -I/usr/local/include/bind"
+    set XCFLAGS      = "-Wno-strict-prototypes -Wno-error $XMTDEF $XINCD $XCFLAGS"
+    set XLIBS        = "-lXm -lXpm -lXt -lXext -lXmu -lX11 -lSM -lICE -lXp"
++   set XMLIBS       = "$XLIBS"
+ 
+    if ( $DEBUGGED == 1 ) then
+       set WINCFLAGS = "/Od /D "WIN32" /D "_DEBUG" /MTd /Zi"
+@@ -1763,6 +1906,10 @@
+ #
+    set INTERACTTARGETS = ""
+    set COMPILE_DC = 1
++
++   set HWLOC      = 0
++   set MAKEHWLOC  = 0
++
+    set MAKE = make
+    set CFLAGS = "-DNECSX4 -DGETHOSTBYNAME_M -DGETHOSTBYADDR_M -dir,novec,nopar,nopthr -hfloat0 $DEBUG_FLAG $CFLAGS"
+    set DEPEND_FLAGS = "$CFLAGS $XMTINCD"
+@@ -1784,6 +1931,10 @@
+    set MAKEWINGRIDAPP   = 0
+    set INTERACTTARGETS = ""
+    set COMPILE_DC = 1
++
++   set HWLOC      = 0
++   set MAKEHWLOC  = 0
++
+    if ( $CORE == 1 ) then
+       set MAKESTRPTIME = 1
+       set MAKEFNMATCH = 1
+@@ -1937,7 +2088,6 @@
+       endif
+       set CFLAGS = "-Xc -v $OFLAG $MEMFLAG -ftrap=division $CFLAGS $DEBUG_FLAG"
+    else if ( $CC == gcc) then
+-      #set CFLAGS = "-Wall -Werror -Wstrict-prototypes $CFLAGS"
+       set CFLAGS = "-Wall -Wstrict-prototypes $CFLAGS"
+       set SHARED_CFLAGS = "-fPIC"
+       set SHARED_LFLAGS = "$SHARED_LFLAGS -L. -shared"
+@@ -1946,6 +2096,10 @@
+         set CFLAGS = "$CFLAGS -Werror"
+       endif
+ 
++      if ("$WEXTRA" == 1) then
++        set CFLAGS = "$CFLAGS -Wextra"
++      endif
++
+       if ( $BUILDARCH == SOLARIS64 ) then
+          set CFLAGS = "-m64 $CFLAGS"
+          set MEMFLAG = "-m64"
+@@ -2008,6 +2162,7 @@
+    
+    set XLFLAGS  = "$XLIBD"
+    set XLIBS    = "-lXm -lXt -lXext -lXmu -lX11 -lw -lgen"
++   set XMLIBS   = "$XLIBS"
+ 
+    set RANLIB   = "echo"
+    set JAVA_ARCH = "solaris"
+@@ -2023,11 +2178,15 @@
+ 
+    set LFLAGS   = "$LFLAGS $DEBUG_FLAG"
+    set LIBRARY_LIBS = "$LIBS"
++
+    if ( $MAKEJEMALLOCLIB == 1 ) then
+       set JEMALLOC_CFLAGS  = "-DMOZ_MEMORY_SOLARIS -xc99"
++   endif
++
++   if ( $LINKJEMALLOCLIB == 1 ) then
+       set LIBS = "-ljemalloc $LIBS"
+    else
+-      if ( $MAKEMTMALLOCLIB == 1 ) then
++      if ( $LINKMTMALLOCLIB == 1 ) then
+          set LIBS = "-lmtmalloc $LIBS"
+       endif
+    endif
+@@ -2038,6 +2197,10 @@
+    set MAKEWINGRIDLIB   = 0
+    set MAKEWINGRIDAPP   = 0
+    set INTERACTTARGETS = ""
++
++   set HWLOC      = 0
++   set MAKEHWLOC  = 0
++
+    set MAKE = gmake
+    set ARFLAGS = rcv
+    switch ($BUILDARCH)
+@@ -2066,6 +2229,7 @@
+          set XLIBS    = "-lXm -lXt -lXext -lX11 -lSM -lICE"
+          breaksw
+    endsw
++   set XMLIBS   = "$XLIBS"
+    set XCFLAGS  = "$XMTDEF $XINCD $XCFLAGS"
+    set XLFLAGS  = "$XLIBD"
+    set COMPILE_DC = 1
+@@ -2091,11 +2255,54 @@
+ set CFLAGS       = "-D$ARCH_STRING $CFLAGS"
+ set DEPEND_FLAGS = "-D$ARCH_STRING $DEPEND_FLAGS"
+ 
++#---------------------------------------------------------------------------
++if ( $JAVA > 0 || $BUILDJAVADOC == 1 || $JNI == 1 ) then
++
++   # Make sure we can find JAVA_HOME
++   if ( ${?JAVA_HOME} == 0 ) then
++      echo "Please set JAVA_HOME or disable Java & JGDI support"
++      echo "with aimk flags: -no-java -no-jni"
++      exit 1
++   endif
++
++   if ( ${JAVA_HOME} == "/usr" ) then
++      echo 'WARNING:'
++      echo 'Setting $JAVA_HOME to "/usr" causes problems on some systems, '
++      echo 'because the associated include path will be "/usr/include", '
++      echo 'which is a reserved system include path.'
++      echo
++      echo 'Please either set $JAVA_HOME correctly or disable Java & JGDI support'
++      echo 'with aimk flags: -no-java -no-jni'
++      echo
++      echo 'Contining without Java & JGDI support'
++      echo
++
++      if ( ${?JAVA_HOME_SET_BY_SGE} ) then
++         unsetenv JAVA_HOME
++      endif
++
++      set JNI = 0
++      set JAVA = 0
++   endif
++endif
++
+ if ( $JNI == 1 ) then
+-   set CORE_INCLUDE = "$CORE_INCLUDE -I${JAVA_HOME}/${JAVA_INCL}"
++
++   set JAVA_INCL_DIR = "${JAVA_HOME}/${JAVA_INCL}"
++
++   if ( ! -d "$JAVA_INCL_DIR" ) then
++      echo 'WARNING:'
++      echo 'Java include directory not found.'
++      echo
++      echo 'Please either set $JAVA_HOME correctly or disable Java & JGDI support'
++      echo 'with aimk flags: -no-java -no-jni'
++      exit 1
++   else
++      set CORE_INCLUDE = "$CORE_INCLUDE -I${JAVA_INCL_DIR}"
++   endif
+ 
+    if ("$JAVA_ARCH" != "") then
+-      set CORE_INCLUDE = "$CORE_INCLUDE -I${JAVA_HOME}/${JAVA_INCL}/${JAVA_ARCH}"
++      set CORE_INCLUDE = "$CORE_INCLUDE -I${JAVA_INCL_DIR}/${JAVA_ARCH}"
+       switch ($buildarch)
+          case linux-x86:
+          case nbsd-i386:
+@@ -2114,7 +2321,11 @@
+              breaksw
+          case linux-x64:
+          case sol-amd64:
+-             set JAVA_LIB_ARCH = amd64
++             if ($FORCE_32BIT == 1) then
++                set JAVA_LIB_ARCH = i386
++             else
++                set JAVA_LIB_ARCH = amd64
++             endif
+              breaksw
+          case linux-ia64:
+              set JAVA_LIB_ARCH = ia64
+@@ -2143,7 +2354,7 @@
+          case tru64:
+              set JAVA_LIB_ARCH = "" 
+              breaksw
+-         case aix5:
++         case aix:
+              set JAVA_LIB_ARCH = "" 
+              breaksw
+          default:
+@@ -2159,9 +2370,9 @@
+    #
+    # special treatment
+    #
+-   if ( $buildarch == aix51 ) then
++   if ( $buildarch == aix ) then
+      set JAVA_LFLAGS="-L$JAVA_HOME/jre/bin/classic"
+-   else if ( $buildarch == darwin-x86 || $buildarch == darwin-ppc ) then
++   else if ( $buildarch == darwin-x86 || $buildarch == darwin-x64 || $buildarch == darwin-ppc ) then
+      set JAVA_LFLAGS="-L$JAVA_HOME/../Libraries"
+    else if ( $buildarch == irix65 ) then
+      set JAVA_LFLAGS="-L$JAVA_HOME/jre/lib32/mips"
+@@ -2180,19 +2391,6 @@
+ 
+ set MAKEOPT = "$MAKEOPT $PARALLEL"
+ 
+-# set gcc version dependent defines, suppress gcc 3.3.x warnings
+-#
+-if ($CC == gcc) then
+-   expr `gcc -dumpversion` : 3.3 > /dev/null
+-   if ($status == 0) then
+-      set CFLAGS = "$CFLAGS"
+-   endif
+-   expr `gcc -dumpversion` : 2.96 > /dev/null
+-   if ($status == 0) then
+-      set CFLAGS = "-DUSING_GCC_2_96 $CFLAGS"
+-   endif
+-endif
+-
+ # pass -DCOMPILE_DC define to compile where PTF and PDC are ported
+ #
+ if ( $COMPILE_DC == 1 ) then
+@@ -2246,13 +2444,17 @@
+ 
+ if ( $HWLOC == 1 ) then
+    set CFLAGS = "$CFLAGS -DTHREADBINDING -DHWLOC"
+-   set CORE_INCLUDE = "$CORE_INCLUDE -I$SOURCE/3rdparty/hwloc/$HWLOC_DIRECTORY/include/ -I$SOURCE/3rdparty/hwloc/$HWLOC_DIRECTORY/$COMPILE_ARCH/include"
+-   # set LFLAGS = "$LFLAGS -L$SOURCE/3rdparty/hwloc/$HWLOC_DIRECTORY/$COMPILE_ARCH/src/.libs/"
+-   # set LIBS = "$LIBS -lhwloc"
+-   set LIBS = "-L$SOURCE/3rdparty/hwloc/$HWLOC_DIRECTORY/$COMPILE_ARCH/src/.libs/ -lhwloc $LIBS"
++
++   if ( $MAKEHWLOC == 1 ) then
++      set CORE_INCLUDE = "$CORE_INCLUDE -I$SOURCE/3rdparty/hwloc/$HWLOC_DIRECTORY/include/ -I$SOURCE/3rdparty/hwloc/$HWLOC_DIRECTORY/$COMPILE_ARCH/include"
++      set LIBS = "-L$SOURCE/3rdparty/hwloc/$HWLOC_DIRECTORY/$COMPILE_ARCH/src/.libs/ -lhwloc $LIBS"
++   else
++      set LIBS = "-lhwloc $LIBS"
++   endif
+ endif
+ 
+ 
++
+ # create shared lib from LGPL code  - use $SHAREDEXT for shared lib extension
+ #
+ set GSHARED_CFLAGS = "$SHARED_CFLAGS"
+@@ -2444,7 +2646,8 @@
+ 
+    if ( "$HWLOC" == 1 ) then
+       echo "No dependencies for 3rd_party hwloc ... skipping"
+-      set HWLOC = 0
++      set HWLOC     = 0
++      set MAKEHWLOC = 0
+    endif
+ 
+    if ( "$QMAKE" == 1 ) then
+@@ -2581,7 +2784,7 @@
+    cd $SOURCE
+ endif
+ 
+-if ( "$HWLOC" == 1 ) then
++if ( "$MAKEHWLOC" == 1 ) then
+    echo _________3_r_d_p_a_r_t_y__H_W_L_O_C_______
+ 
+       set maj_ver = `echo $HWLOC_VERSION| cut -f 1 -d .`
+@@ -2768,7 +2971,7 @@
+          "KRBLIB=$KRBLIB" "GSSDEPEND=$GSSDEPEND" \
+          "GSSCLEAN=$GSSCLEAN" "MSDIR=$MSDIR" "SLIBS=$GSSLIBS $KLIBS" "LIBS=$LIBS" \
+          "XCFLAGS=$XCFLAGS" "XLFLAGS=$XLFLAGS" \
+-         "XLIBS=$XLIBS" "LFLAGS=$LFLAGS $KLFLAGS" "STRIP=$STRIP" \
++         "XLIBS=$XLIBS" "XMLIBS=$XMLIBS" "LFLAGS=$LFLAGS $KLFLAGS" "STRIP=$STRIP" \
+          "RANLIB=$RANLIB" "AR=$AR" "ARFLAGS=$ARFLAGS" \
+          "NOERR_PROTO=$NOERR_PROTO" "NOERR_CFLAG=$NOERR_CFLAG" \
+          "COMPILE_DC=$COMPILE_DC" "LOADAVGLIBS=$LOADAVGLIBS" \
+@@ -2870,7 +3073,7 @@
+          "CFLAGS=$CFLAGS" "SDIR=$SDIR" "SOURCE=$SOURCE" \
+          "COMPILE_ARCH=$COMPILE_ARCH" \
+          "XCFLAGS=$XCFLAGS" "XLFLAGS=$XLFLAGS" "KRBLIBS=$KRBLIBS" \
+-         "XLIBS=$XLIBS" "LFLAGS=$LFLAGS $KLFLAGS" "STRIP=$STRIP" "RANLIB=$RANLIB" \
++         "XLIBS=$XLIBS" "XMLIBS=$XMLIBS" "LFLAGS=$LFLAGS $KLFLAGS" "STRIP=$STRIP" "RANLIB=$RANLIB" \
+          "AR=$AR" "ARFLAGS=$ARFLAGS" "TPLIB=$TPLIB" \
+          "MEMCFLAG=$MEMCFLAG"  \
+          "SHARED_CFLAGS=$SHARED_CFLAGS" "SHARED_LFLAGS=$SHARED_LFLAGS" \
+@@ -2897,7 +3100,7 @@
+          "KRBLIBS=$KRBLIBS" "KRBLIB=$KRBLIB" "GSSDEPEND=$GSSDEPEND" \
+          "GSSCLEAN=$GSSCLEAN" "MSDIR=$MSDIR" "SLIBS=$GSSLIBS $KLIBS" "LIBS=$LIBS" \
+          "XCFLAGS=$XCFLAGS" "XLFLAGS=$XLFLAGS" \
+-         "XLIBS=$XLIBS" "LFLAGS=$LFLAGS $KLFLAGS" "STRIP=$STRIP" \
++         "XLIBS=$XLIBS" "XMLIBS=$XMLIBS" "LFLAGS=$LFLAGS $KLFLAGS" "STRIP=$STRIP" \
+          "RANLIB=$RANLIB" "AR=$AR" "ARFLAGS=$ARFLAGS" \
+          "NOERR_PROTO=$NOERR_PROTO" \
+          "NOERR_CFLAG=$NOERR_CFLAG" \
+diff -ruN --exclude .svn GE2011.11/source/aimk.site gridscheduler-trunk/source/aimk.site
+--- GE2011.11/source/aimk.site	2011-11-14 12:01:16.000000000 -0700
++++ gridscheduler-trunk/source/aimk.site	2012-03-21 09:25:10.595916974 -0600
+@@ -53,8 +53,8 @@
+    case "irix65":
+    case "hp11":
+    case "hp11-64":
+-   case "lx24-ia64":
+-   case "aix51":
++   case "linux-ia64":
++   case "aix":
+       if ( -f /vol2/resources/en_jdk14 ) then
+          source /vol2/resources/en_jdk14 
+       endif   
+@@ -147,7 +147,7 @@
+       # for HP11.00 we don't have dynamic loading of shared libraries
+       # build with berkeleydb
+    case "AIX43":
+-   case "AIX51":
++   case "AIX":
+    case "IRIX65":
+       # for these platforms, reverse resolving of global symbols doesn't
+       # work as expected: Instead of reverse resolving global symbols
+@@ -158,18 +158,68 @@
+ endsw
+ 
+ if ( ! $?JAVA_HOME ) then
+-   set JAVA_BIN = `which \java`
+ 
+-   if ( -e "$JAVA_BIN" ) then
+-      set JAVAV = `$JAVA_BIN -version |& head -1`
+-      set JAVAV = `expr "$JAVAV" : 'java version "1\.\([0-9]\).*"'`
++   set JAVAC_BIN = `which \javac`
++   set JAVA_HOME_LOCATION = ""
+ 
+-      if ( $JAVAV >= 4 ) then
+-         setenv JAVA_HOME `expr //$JAVA_BIN : '//\(.*\)/bin/.*'`
++   set JAVAC_LOCATION = $JAVAC_BIN
++   while ( { test -L "$JAVAC_LOCATION" }  )
++       set JAVAC_LOCATION = `readlink $JAVAC_LOCATION`
++       if ( $status != 0 ) then
++          break
++       endif
++   end
++
++   if ( -e "$JAVAC_LOCATION" ) then
++      set JAVAC_BIN = $JAVAC_LOCATION
++   endif
++
++   if ( -e "$JAVAC_BIN" ) then
++      set JAVAV = `$JAVAC_BIN -version >& /dev/null`
++      if ( $status == 0 ) then
++         set JAVAV = `$JAVAC_BIN -version |& head -1`
++         set JAVAV = `expr "$JAVAV" : 'javac 1\.\([0-9]\).*'`
++
++         if ( $JAVAV >= 4 ) then
++            set JAVA_HOME_LOCATION = `expr //$JAVAC_BIN : '//\(.*\)/bin/.*'`
++
++            if ( ! -d  "$JAVA_HOME_LOCATION" ) then
++               set JAVA_HOME_LOCATION = `expr //$JAVAC_BIN : '//\(.*\)/Commands/.*'`
++            endif
++         endif
++      else
++         set JAVA_HOME_LOCATION = `expr //$JAVAC_BIN : '//\(.*\)/bin/.*'`
++
++         if ( ! -d  "$JAVA_HOME_LOCATION" ) then
++            set JAVA_HOME_LOCATION = `expr //$JAVAC_BIN : '//\(.*\)/Commands/.*'`
++         endif
++      endif
++
++      if ( -d "$JAVA_HOME_LOCATION" ) then
++         setenv JAVA_HOME            $JAVA_HOME_LOCATION
++         setenv JAVA_HOME_SET_BY_SGE TRUE
++      else
++         set JAVAC_LOCATION = `which \javac`
++
++         while ( { test -L "$JAVAC_LOCATION" }  )
++             set JAVAC_LOCATION = `readlink $JAVAC_LOCATION`
++             if ( $status != 0 ) then
++                break
++             endif
++
++             set CHECK_PATH = `expr //$JAVAC_LOCATION : '//\(.*\)/bin/.*'`
++
++             if ( -e "$CHECK_PATH/include/jni.h" ) then
++                setenv JAVA_HOME            $CHECK_PATH
++                setenv JAVA_HOME_SET_BY_SGE TRUE
++                break
++             endif
++         end
+       endif
+    endif
+ endif
+ 
++
+ # set junit jar file
+ # set JUNIT_JAR = '/vol2/tools/SW/java/junit3.8.1/junit.jar'
+ set JUNIT_JAR = '/usr/share/java/junit.jar'
+diff -ruN --exclude .svn GE2011.11/source/clients/common/sge_qstat.c gridscheduler-trunk/source/clients/common/sge_qstat.c
+--- GE2011.11/source/clients/common/sge_qstat.c	2011-11-14 12:00:52.000000000 -0700
++++ gridscheduler-trunk/source/clients/common/sge_qstat.c	2012-02-08 09:46:02.593094944 -0700
+@@ -723,18 +723,19 @@
+    /*
+    ** tag only jobs which satisfy the user list
+    */
+-   if (lGetNumberOfElem(qstat_env->user_list)) {
++   if (lGetNumberOfElem(qstat_env->user_list))
++   {
+       DPRINTF(("------- selecting jobs -----------\n"));
+ 
+       /* ok, now we untag the jobs if the user_list was specified */ 
+       for_each(up, qstat_env->user_list) 
+-         for_each (jep, qstat_env->job_list) {
+-            if (up && lGetString(up, ST_name) && 
+-                  !fnmatch(lGetString(up, ST_name), 
+-                              lGetString(jep, JB_owner), 0)) {
+-               for_each (jatep, lGetList(jep, JB_ja_tasks)) {
+-                  lSetUlong(jatep, JAT_suitable, 
+-                     lGetUlong(jatep, JAT_suitable)|TAG_SHOW_IT|TAG_SELECT_IT);
++         for_each (jep, qstat_env->job_list)
++         {
++            if (up && lGetString(up, ST_name) && !fnmatch(lGetString(up, ST_name), lGetString(jep, JB_owner), FNM_NOESCAPE))
++            {
++               for_each (jatep, lGetList(jep, JB_ja_tasks))
++               {
++                  lSetUlong(jatep, JAT_suitable, lGetUlong(jatep, JAT_suitable)|TAG_SHOW_IT|TAG_SELECT_IT);
+                }
+             }
+          }
+@@ -839,19 +840,19 @@
+    DENTER(TOP_LAYER, "qstat_env_filter_queues");
+ 
+    ret = filter_queues(NULL,
+-                        qstat_env->queue_list,
+-                        qstat_env->centry_list,
+-                        qstat_env->hgrp_list,
+-                        qstat_env->exechost_list,
+-                        qstat_env->acl_list,
+-                        qstat_env->project_list,
+-                        qstat_env->pe_list,
+-                        qstat_env->resource_list, 
+-                        qstat_env->queueref_list, 
+-                        qstat_env->peref_list, 
+-                        qstat_env->queue_user_list,
+-                        qstat_env->queue_state,
+-                        alpp);
++                       qstat_env->queue_list,
++                       qstat_env->centry_list,
++                       qstat_env->hgrp_list,
++                       qstat_env->exechost_list,
++                       qstat_env->acl_list,
++                       qstat_env->project_list,
++                       qstat_env->pe_list,
++                       qstat_env->resource_list, 
++                       qstat_env->queueref_list, 
++                       qstat_env->peref_list, 
++                       qstat_env->queue_user_list,
++                       qstat_env->queue_state,
++                       alpp);
+    DRETURN(ret);
+ }
+ 
+diff -ruN --exclude .svn GE2011.11/source/clients/gui-installer/html/en/help/SpoolingConfig.html gridscheduler-trunk/source/clients/gui-installer/html/en/help/SpoolingConfig.html
+--- GE2011.11/source/clients/gui-installer/html/en/help/SpoolingConfig.html	2011-11-14 12:00:52.000000000 -0700
++++ gridscheduler-trunk/source/clients/gui-installer/html/en/help/SpoolingConfig.html	2012-04-17 09:13:36.842322869 -0600
+@@ -39,11 +39,13 @@
+ <UL>
+ 	<LI><P STYLE="margin-bottom: 0in"><B>Qmaster spool directory</B> -
+ 	Directory for qmaster spooling data .</P>
++        
+ 	<LI><P STYLE="margin-bottom: 0in"><B>Global execd spool directory</B>
+ 	- Directory for execution daemon spooling directory used by default
+ 	for all execution hosts, unless overridden in the <I>Host selection</I> 
+ 	screen, each execution host creates a subdirectory in the global
+ 	execd spool directory.</P>
++
+ 	<LI><P STYLE="margin-bottom: 0in"><B>Spooling method</B> 
+ 	</P>
+ 	<OL>
+@@ -51,17 +53,9 @@
+ 		human readable format.</P>
+ 		<LI><P STYLE="margin-bottom: 0in">Berkeley db - Spooling is done to
+ 		local Berkley db.</P>
+-		<LI><P STYLE="margin-bottom: 0in">Berkeley db spooling server -
+-		Spooling is done to Berkley db server.</P>
+ 	</OL>
+-	<LI><P STYLE="margin-bottom: 0in"><B>Berkeley db host</B> - host
+-	where Berkeley db server will be/is installed, enabled only when
+-	<I>Berkeley db spooling server</I> method is selected 
+-	</P>
+-	<LI><P><B>Db directory</B> - Berkeley db spooling directory either
+-	on local host or Berkeley db host in case of <I>Berkeley db spooling
+-	server</I> method 
+-	</P>
++
++	<LI><P><B>Db directory</B> - Berkeley db spooling directory on the local host</P>
+ </UL>
+ <P><BR><BR>
+ </P>
+Binary files GE2011.11/source/clients/gui-installer/resources/logo.png and gridscheduler-trunk/source/clients/gui-installer/resources/logo.png differ
+diff -ruN --exclude .svn GE2011.11/source/clients/gui-installer/templates/readme_template.html gridscheduler-trunk/source/clients/gui-installer/templates/readme_template.html
+--- GE2011.11/source/clients/gui-installer/templates/readme_template.html	2011-11-14 12:00:52.000000000 -0700
++++ gridscheduler-trunk/source/clients/gui-installer/templates/readme_template.html	2012-04-17 09:13:36.942319279 -0600
+@@ -35,15 +35,16 @@
+         <title>Read Me</title>
+     </head>
+     <body>
++
+         <h2>Grid Engine cluster configuration</h2>
+-        <table border = "0">
++        <table border="1" cellspacing="0">
+             <tr><td>Grid Engine root directory (<code>$SGE_ROOT</code>)</td><td>${cfg.sge.root}</td></tr>
+             <tr><td>Cell name (<code>$SGE_CELL</code>)</td><td>${cfg.cell.name}</td></tr>
+             <tr><td>Cluster name (<code>$SGE_CLUSTER_NAME</code>)</td><td>${cfg.sge.cluster.name}</td></tr>
+-            <tr><td>Qmaster port (<code>$SGE_QMASTER_PORT</code>)</td><td>${cfg.sge.qmaster.port}</td></tr>
+-            <tr><td>Execd port (<code>$SGE_EXECD_PORT</code>)</td><td>${cfg.sge.execd.port}</td></tr>
+-            <tr><td>Group id range (<code>$SGE_GID_RANGE</code>)</td><td>${cfg.gid.range}</td></tr>
+-            <tr><td>Qmaster spool directory</td><td>${cfg.qmaster.spool.dir}</td></tr>
++            <tr><td>qmaster port (<code>$SGE_QMASTER_PORT</code>)</td><td>${cfg.sge.qmaster.port}</td></tr>
++            <tr><td>execd port (<code>$SGE_EXECD_PORT</code>)</td><td>${cfg.sge.execd.port}</td></tr>
++            <tr><td>Group id range </td><td>${cfg.gid.range}</td></tr>
++            <tr><td>qmaster spool directory</td><td>${cfg.qmaster.spool.dir}</td></tr>
+             <tr><td>Global execd spool directory</td><td>${cfg.execd.spool.dir}</td></tr>
+             <tr><td>Spooling method</td><td>${cfg.spooling.method}</td></tr>
+             <!--.if !cond.spooling.classic.-->
+@@ -59,7 +60,7 @@
+             <tr><td>Administrator mail</td><td>${cfg.admin.mail}</td></tr>
+         </table>
+         <br>
+-        <table border = "0">
++        <table border="1" >
+             <tr><td></td><td align="center"><b>Succeded</b></td><td align="center"><b>Failed</b></td></tr>
+             <tr><td>Qmaster host</td><td>${add.qmaster.host}</td><td><font color="red">${add.qmaster.host.failed}</font></td></tr>
+             <tr><td>Execution host(s)</td><td>${cfg.exec.host.list}</td><td><font color="red">${add.exec.host.list.failed}</font></td></tr>
+@@ -69,15 +70,19 @@
+             <tr><td>Submit host(s)</td><td>${cfg.submit.host.list}</td><td><font color="red">${add.submit.host.list.failed}</font></td></tr>
+         </table>
+         
+-        <h2>How to start with Grid Engine</h2>
+-        <ol>
+-            <li>
+-                Set the environment...<br>
+-                ... if you are a csh/tcsh user:<br>
+-                <code>source ${cfg.sge.root}/${cfg.cell.name}/common/settings.csh</code><br>
+-                ... if you are a sh/ksh user:<br>
+-                <code>. ${cfg.sge.root}/${cfg.cell.name}/common/settings.sh</code><br>
+-                <br>
++        <h2>Getting started with Grid Engine</h2>
++            <h3>Setting the environment</h3>
++                <li>
++                  if you are a csh/tcsh user:<br>
++                  <code>source ${cfg.sge.root}/${cfg.cell.name}/common/settings.csh</code><br>
++                </li>
++
++                <li>
++                  if you are a sh/bash/ksh user:<br>
++                    <code>. ${cfg.sge.root}/${cfg.cell.name}/common/settings.sh</code><br>
++                </li>
++
++                <li>
+                 This will set or expand the following environment variables:
+                 <ul>
+                     <li><code>$SGE_ROOT</code>         (always necessary)</li>
+@@ -88,31 +93,32 @@
+                     <li><code>$PATH/$path</code>       (to find the Grid Engine binaries)</li>
+                     <li><code>$MANPATH</code>          (to access the manual pages)</li>
+                 </ul>
+-            </li>
+-            <br>
++                </li>
++
++            <h3>Submitting your first Grid Engine job</h3>
+             <li>
+-                Submit one of the sample scripts contained in the ${cfg.sge.root}/examples/jobs directory.<br>
+-                <code>qsub ${cfg.sge.root}/examples/jobs/simple.sh</code><br>
+-                or<br>
+-                <code>qsub ${cfg.sge.root}/examples/jobs/sleeper.sh</code>
++                Submit one of the sample scripts contained in the <code>$SGE_ROOT/examples/jobs</code> directory. Example:<br>
++                <code>qsub $SGE_ROOT/examples/jobs/sleeper.sh</code>
+             </li>
+-            <br>
++
++            <h3>Monitoring your Grid Engine jobs</h3>
+             <li>
+                 Use the qstat command to monitor the job's behavior.<br>
+-                <code>qstat -f</code>
++                <code>qstat</code>
+             </li>
+-            <br>
++
++            <h3>Job output</h3>
+             <li>
+                 After the job finishes executing, check your home directory for 
+-                the redirected stdout/stderr files <code>script-name.ejob-id</code> and <code>script-name.ojob-id</code>.<br>
+-                The <code>job-id</code> is a consecutive unique integer number assigned to each job.
++                the redirected stdout/stderr files <code>script-name.e</code><b><i>job-id</i></b> and <code>script-name.o</code><b><i>job-id</i></b>.
+             </li>
+-        </ol>
+ 
+         <h2>Administering Grid Engine</h2>
+-        Grid Engine startup scripts can be found at:<br>
+-        Qmaster:     <code>${cfg.sge.root}/${cfg.cell.name}/common/sgemaster start/stop</code><br>
+-        Exec daemon: <code>${cfg.sge.root}/${cfg.cell.name}/common/sgeexecd start/stop</code><br>
++        <table border = "1">
++        <tr><td>Component</td><td align="center"> Startup Script </td><td>  actions</td></tr>
++        <tr><td>qmaster </td><td> <code>${cfg.sge.root}/${cfg.cell.name}/common/sgemaster </code> </td><td><code>start/stop</code></td></tr>
++        <tr><td>execd </td><td> <code>${cfg.sge.root}/${cfg.cell.name}/common/sgeexecd </code> </td><td><code>start/stop</code></td></tr>
++        </table>
+         <br>
+         
+         <!--.if ${installed.solaris.smf}.-->
+@@ -122,14 +128,16 @@
+         <br>
+         <!--.endif.-->
+ 
+-        After startup the daemons log their messages in their spool directories.<br>
+-        Qmaster:     <code>${cfg.qmaster.spool.dir}/messages</code><br>
+-        Exec daemon: <code>&lt;execd_spool_dir&gt;/&lt;hostname&gt;/messages</code>
++        <table border = "1">
++        <tr><td>Component</td> <td align="center">Log File Location</td></tr>
++        <tr><td>qmaster </td>  <td><code>${cfg.qmaster.spool.dir}/messages</code></td></tr>
++        <tr><td>execd </td>    <td><code>&lt;execd_spool_dir&gt;/&lt;hostname&gt;/messages</code></td></tr>
++        </table>
+ 
+         <h2>Useful links</h2>
+         <table border = "0">
+-        <tr><td>Sun Grid Engine Information Center</td><td><a href="http://wikis.sun.com/display/SunGridEngine/Home">http://wikis.sun.com/display/SunGridEngine/Home</a></td></tr>
+-        <tr><td>Grid Engine project home</td><td><a href="http://gridengine.sunsource.net">http://gridengine.sunsource.net</a></td></tr>
++        <tr><td>Oracle Grid Engine Documentation</td><td><a href="http://docs.oracle.com/cd/E24901_01/index.htm">http://docs.oracle.com/cd/E24901_01/index.htm</a></td></tr>
++        <tr><td>Grid Engine project home</td><td><a href="http://gridscheduler.sourceforge.net/">http://gridscheduler.sourceforge.net/</a></td></tr>
+         </table>
+     </body>
+ </html>
+diff -ruN --exclude .svn GE2011.11/source/clients/qdel/qdel.c gridscheduler-trunk/source/clients/qdel/qdel.c
+--- GE2011.11/source/clients/qdel/qdel.c	2011-11-14 12:00:52.000000000 -0700
++++ gridscheduler-trunk/source/clients/qdel/qdel.c	2012-02-28 17:08:35.474822444 -0700
+@@ -51,7 +51,7 @@
+ #include "msg_clients_common.h"
+ #include "msg_qdel.h"
+ #include "sgeobj/msg_sgeobjlib.h"
+-#include "sgeobj//sge_range.h"
++#include "sgeobj/sge_range.h"
+ #include "sge_options.h"
+ #include "sge_profiling.h"
+ 
+diff -ruN --exclude .svn GE2011.11/source/clients/qmod/qmod.c gridscheduler-trunk/source/clients/qmod/qmod.c
+--- GE2011.11/source/clients/qmod/qmod.c	2011-11-14 12:00:52.000000000 -0700
++++ gridscheduler-trunk/source/clients/qmod/qmod.c	2012-02-28 17:08:35.534820307 -0700
+@@ -53,7 +53,7 @@
+ 
+ #include "sgeobj/sge_str.h"
+ #include "sgeobj/msg_sgeobjlib.h"
+-#include "sgeobj//sge_range.h"
++#include "sgeobj/sge_range.h"
+ #include "sge_options.h"
+ #include "sge_profiling.h"
+ #include "gdi/sge_gdi.h"
+diff -ruN --exclude .svn GE2011.11/source/common/basis_types.h gridscheduler-trunk/source/common/basis_types.h
+--- GE2011.11/source/common/basis_types.h	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/common/basis_types.h	2012-02-08 09:46:01.468133610 -0700
+@@ -60,7 +60,7 @@
+ #endif
+ 
+ #if !defined(__cplusplus) 
+-#  if defined(DARWIN9) || defined(DARWIN10)
++#  if defined(DARWIN9)
+ #     include <stdbool.h>
+ #  else
+ typedef enum {
+diff -ruN --exclude .svn GE2011.11/source/common/msg_common.h gridscheduler-trunk/source/common/msg_common.h
+--- GE2011.11/source/common/msg_common.h	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/common/msg_common.h	2012-03-21 09:25:08.899977341 -0600
+@@ -64,6 +64,7 @@
+ #define MSG_FILE_CANNOT_WRITE_SS                                     _MESSAGE(23030, _("unable to write to file "SFN": "SFN))
+ #define MSG_FILE_CANNOT_FLUSH_SS                                     _MESSAGE(23031, _("unable to flush file "SFN": "SFN))
+ #define MSG_CONF_THEPATHGIVENFORXMUSTSTARTWITHANY_S                  _MESSAGE(23032, _("denied: the path given for "SFQ" must start with a \"/\""))
++#define MSG_FILE_CANNOT_CHOWN                                     _MESSAGE(23033, _("unable to chown file "SFN": "SFN))
+ 
+ /*
+ ** parse_job_cull.c
+diff -ruN --exclude .svn GE2011.11/source/common/parse_qsub.c gridscheduler-trunk/source/common/parse_qsub.c
+--- GE2011.11/source/common/parse_qsub.c	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/common/parse_qsub.c	2012-02-08 09:46:01.467133645 -0700
+@@ -2064,20 +2064,24 @@
+ {
+    DENTER(TOP_LAYER, "var_list_parse_from_environment");
+ 
+-   if (!lpp || !envp) {
++   if (!lpp || !envp)
++   {
+       DEXIT;
+       return 1;
+    }
+ 
+-   if (!*lpp) {
++   if (!*lpp)
++   {
+       *lpp = lCreateList("env list", VA_Type);
+-      if (!*lpp) {
++      if (!*lpp)
++      {
+          DEXIT;
+-         return 3;
++         return 1;
+       }
+    }
+ 
+-   for (; *envp; envp++) {
++   for (; *envp; envp++)
++   {
+       char *env_name;
+       char *env_description;
+       char *env_entry;
+@@ -2094,7 +2098,7 @@
+       SGE_ASSERT((env_name));
+       lSetString(ep, VA_variable, env_name);
+ 
+-      env_description = sge_strtok_r((char *) 0, "\n", &context);
++      env_description = sge_strtok_r(NULL, "\0", &context);
+       if (env_description)
+          lSetString(ep, VA_value, env_description);
+       FREE(env_entry);
+diff -ruN --exclude .svn GE2011.11/source/daemons/common/pdc.c gridscheduler-trunk/source/daemons/common/pdc.c
+--- GE2011.11/source/daemons/common/pdc.c	2011-11-14 12:00:42.000000000 -0700
++++ gridscheduler-trunk/source/daemons/common/pdc.c	2012-02-08 09:46:00.747158446 -0700
+@@ -1703,15 +1703,20 @@
+       int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
+       size_t bufSize = 0;
+ 
+-      if (sysctl(mib, 4, NULL, &bufSize, NULL, 0) < 0) {
++      if (sysctl(mib, 4, NULL, &bufSize, NULL, 0) < 0)
++      {
+          DPRINTF(("sysctl() failed(1)\n"));
+          DRETURN(-1);
+       }
+-      if ((procs = (struct kinfo_proc *)malloc(bufSize)) == NULL) {
++
++      if ((procs = malloc(bufSize)) == NULL)
++      {
+          DPRINTF(("malloc() failed\n"));
+          DRETURN(-1);
+       }
+-      if (sysctl(mib, 4, procs, &bufSize, NULL, 0) < 0) {
++
++      if (sysctl(mib, 4, procs, &bufSize, NULL, 0) < 0)
++      {
+          DPRINTF(("sysctl() failed(2)\n"));
+          FREE(procs);
+          DRETURN(-1);
+@@ -1719,29 +1724,38 @@
+       procs_begin = procs;
+       nprocs = bufSize/sizeof(struct kinfo_proc);
+       
+-      for (; nprocs >= 0; nprocs--, procs++) {
+-         for (curr=job_list.next; curr != &job_list; curr=curr->next) {
++      for (; nprocs >= 0; nprocs--, procs++)
++      {
++         for (curr=job_list.next; curr != &job_list; curr=curr->next)
++         {
+             job_elem = LNK_DATA(curr, job_elem_t, link);
+ 
+-            for (i = 0; i < procs->kp_eproc.e_ucred.cr_ngroups; i++) {
+-               if (job_elem->job.jd_jid == procs->kp_eproc.e_ucred.cr_groups[i]) {
++            for (i = 0; i < procs->kp_eproc.e_ucred.cr_ngroups; i++)
++            {
++               if (job_elem->job.jd_jid == procs->kp_eproc.e_ucred.cr_groups[i])
++               {
+                   lnk_link_t  *curr2;
+                   proc_elem_t *proc_elem;
+                   int newprocess = 1;
+                   
+-                  if (job_elem->job.jd_proccount != 0) {
+-                     for (curr2=job_elem->procs.next; curr2 != &job_elem->procs; curr2=curr2->next) {
++                  if (job_elem->job.jd_proccount != 0)
++                  {
++                     for (curr2=job_elem->procs.next; curr2 != &job_elem->procs; curr2=curr2->next)
++                     {
+                         proc_elem = LNK_DATA(curr2, proc_elem_t, link);
+ 
+-                        if (proc_elem->proc.pd_pid == procs->kp_proc.p_pid) {
++                        if (proc_elem->proc.pd_pid == procs->kp_proc.p_pid)
++                        {
+                            newprocess = 0;
+                            break;
+                         }
+                      }
+                   }
+-                  if (newprocess) {
++                  if (newprocess)
++                  {
+                      proc_elem = malloc(sizeof(proc_elem_t));
+-                     if (proc_elem == NULL) {
++                     if (proc_elem == NULL)
++                     {
+                         FREE(procs_begin);
+                         DRETURN(0);
+                      }
+@@ -1753,7 +1767,9 @@
+ 
+                      LNK_ADD(job_elem->procs.prev, &proc_elem->link);
+                      job_elem->job.jd_proccount++;
+-                  } else {
++                  }
++                  else
++                  {
+                      /* save previous usage data - needed to build delta usage */
+                      old_time = proc_elem->proc.pd_utime + proc_elem->proc.pd_stime;
+                      old_vmem  = proc_elem->vmem;
+@@ -1768,36 +1784,51 @@
+                      mach_port_t task;
+                      unsigned int info_count = TASK_BASIC_INFO_COUNT;
+ 
+-                     if (task_for_pid(mach_task_self(), proc_elem->proc.pd_pid, &task) != KERN_SUCCESS) {
++                     if (task_for_pid(mach_task_self(), proc_elem->proc.pd_pid, &task) != KERN_SUCCESS)
++                     {
+                         DPRINTF(("task_for_pid() error"));
+-                     } else {
+-                        if (task_info(task, TASK_BASIC_INFO, (task_info_t)&t_info, &info_count) != KERN_SUCCESS) {
++                     }
++                     else
++                     {
++                        if (task_info(task, TASK_BASIC_INFO, (task_info_t)&t_info, &info_count) != KERN_SUCCESS)
++                        {
+                            DPRINTF(("task_info() error"));
+-                        } else {
+-                           proc_elem->vmem           = t_info.virtual_size/1024;
++                        }
++                        else
++                        {
++                           proc_elem->vmem           = t_info.virtual_size;
++                           proc_elem->rss            = t_info.resident_size;
++
+                            DPRINTF(("vmem: %d\n", proc_elem->vmem));
+-                           proc_elem->rss            = t_info.resident_size/1024;
+-                           DPRINTF(("rss: %d\n", proc_elem->rss));
++                           DPRINTF(("rss: %d\n",  proc_elem->rss));
+                         }
+ 
+                         info_count = TASK_THREAD_TIMES_INFO_COUNT;
+-                        if (task_info(task, TASK_THREAD_TIMES_INFO, (task_info_t)&t_times_info, &info_count) != KERN_SUCCESS) {
++                        if (task_info(task, TASK_THREAD_TIMES_INFO, (task_info_t)&t_times_info, &info_count) != KERN_SUCCESS)
++                        {
+                            DPRINTF(("task_info() error\n"));
+-                        } else {
++                        }
++                        else
++                        {
+                            proc_elem->proc.pd_utime  = t_times_info.user_time.seconds;
+-                           DPRINTF(("user_time: %d\n", proc_elem->proc.pd_utime));
+                            proc_elem->proc.pd_stime  = t_times_info.system_time.seconds;
++
++                           DPRINTF(("user_time: %d\n",   proc_elem->proc.pd_utime));
+                            DPRINTF(("system_time: %d\n", proc_elem->proc.pd_stime));
+                         }
+                      }
++                     mach_port_deallocate(mach_task_self(), task);
+                   }
+ 
+                   proc_elem->proc.pd_uid    = procs->kp_eproc.e_ucred.cr_uid;
+-                  DPRINTF(("uid: %d\n", proc_elem->proc.pd_uid));
+                   proc_elem->proc.pd_gid    = procs->kp_eproc.e_pcred.p_rgid;
++
++                  DPRINTF(("uid: %d\n", proc_elem->proc.pd_uid));
+                   DPRINTF(("gid: %d\n", proc_elem->proc.pd_gid));
++
+                   proc_elem->mem = ((proc_elem->proc.pd_stime + proc_elem->proc.pd_utime) - old_time) *
+                                          ((old_vmem + proc_elem->vmem)/2);
++
+                   DPRINTF(("mem %d\n", proc_elem->mem));
+                }
+             }
+diff -ruN --exclude .svn GE2011.11/source/daemons/common/procfs.c gridscheduler-trunk/source/daemons/common/procfs.c
+--- GE2011.11/source/daemons/common/procfs.c	2011-11-14 12:00:42.000000000 -0700
++++ gridscheduler-trunk/source/daemons/common/procfs.c	2012-02-08 09:46:00.755158170 -0700
+@@ -43,7 +43,7 @@
+ #include <sys/types.h>
+ #include <sys/signal.h>
+ 
+-#if !defined(CRAY) && !defined(NECSX4) && !defined(NECSX5) && !defined(AIX)
++#if !defined(CRAY) && !defined(NECSX4) && !defined(NECSX5) && !defined(AIX) && !defined(CYGWIN)
+ #include <sys/syscall.h>
+ #endif
+ 
+diff -ruN --exclude .svn GE2011.11/source/daemons/common/qlogin_starter.c gridscheduler-trunk/source/daemons/common/qlogin_starter.c
+--- GE2011.11/source/daemons/common/qlogin_starter.c	2011-11-14 12:00:42.000000000 -0700
++++ gridscheduler-trunk/source/daemons/common/qlogin_starter.c	2012-04-17 09:13:35.490371387 -0600
+@@ -507,24 +507,25 @@
+       return 8;
+    }
+ 
+-   /* send necessary info to qrsh: port + utilbin directory + active job 
+-    * directory 
++   /* send necessary info to qrsh: port + utilbin directory + active job
++    * directory
+     */
+-   port = ntohs(serv_addr.sin_port);
+-   shepherd_trace("bound to port %d", port);
+- 
++
+    sge_root = sge_get_root_dir(0, NULL, 0, 1);
+    arch = sge_get_arch();
+-   
+-   if (sge_root == NULL || arch == NULL) {
+-      shepherd_trace("reading environment SGE_ROOT and ARC failed");
++
++   if (sge_root == NULL || arch == NULL)
++   {
++      shepherd_trace("reading environment SGE_ROOT and ARCH failed");
+       shutdown(sockfd, 2);
+       close(sockfd);
+       return 9;
+    }
+-  
+-   snprintf(buffer, sizeof(buffer), "0:%d:%s/utilbin/%s:%s:%s",
+-            port, sge_root, arch, cwd, get_conf_val("host"));
++
++   port = ntohs(serv_addr.sin_port);
++   shepherd_trace("bound to port %d", port);
++
++   snprintf(buffer, sizeof(buffer), "0:%d:%s/utilbin/%s:%s:%s", port, sge_root, arch, cwd, get_conf_val("host"));
+ 
+    if (write_to_qrsh(buffer) != 0) {
+       shepherd_trace("communication with qrsh failed");
+diff -ruN --exclude .svn GE2011.11/source/daemons/execd/execd_job_exec.c gridscheduler-trunk/source/daemons/execd/execd_job_exec.c
+--- GE2011.11/source/daemons/execd/execd_job_exec.c	2011-11-14 12:00:42.000000000 -0700
++++ gridscheduler-trunk/source/daemons/execd/execd_job_exec.c	2012-04-17 09:13:35.821359514 -0600
+@@ -90,13 +90,13 @@
+ {
+    int ret = 1;
+    u_long32 feature_set;
+-   const char *admin_user = ctx->get_admin_user(ctx);
+    const char *progname = ctx->get_progname(ctx);
+ 
+    DENTER(TOP_LAYER, "do_job_exec");
+ 
+    /* ------- featureset */
+-   if (unpackint(&(aMsg->buf), &feature_set)) {
++   if (unpackint(&(aMsg->buf), &feature_set))
++   {
+       ERROR((SGE_EVENT, MSG_COM_UNPACKFEATURESET));
+       DRETURN(0);
+    }
+@@ -104,9 +104,11 @@
+    /* if request comes from qmaster: start a job
+     * else it is a request to start a pe task
+     */
+-   if (strcmp(aMsg->snd_name, prognames[QMASTER]) == 0) {
++   if (strcmp(aMsg->snd_name, prognames[QMASTER]) == 0)
++   {
+       lListElem *job, *ja_task;
+       lList *answer_list = NULL;
++      const char *admin_user = ctx->get_admin_user(ctx);
+ 
+       if (!sge_security_verify_unique_identifier(true, admin_user, progname, 0,
+                                             aMsg->snd_host, aMsg->snd_name, aMsg->snd_id)) {
+@@ -656,8 +658,6 @@
+ 
+    DENTER(TOP_LAYER, "handle_task");
+ 
+-   petep = lCreateElem(PET_Type);
+-
+ #ifdef KERBEROS
+    if (krb_verify_user(de->host, de->commproc, de->id,
+                        lGetString(petrep, PETR_owner)) < 0) {
+@@ -669,32 +669,48 @@
+    jobid    = lGetUlong(petrep, PETR_jobid);
+    jataskid = lGetUlong(petrep, PETR_jataskid);
+ 
+-   if (!execd_get_job_ja_task(jobid, jataskid, &jep, &jatep)) {
++   if (!execd_get_job_ja_task(jobid, jataskid, &jep, &jatep))
++   {
+       goto Error;
+    }
+ 
+-   if (!sge_security_verify_unique_identifier(false, 
+-                                         lGetString(jep, JB_owner), progname, 0,
+-                                         host, commproc, id)) {
++  /*
++   * Verify that it is actually the job owner starting a pe task:
++   * - in CSP mode, we can check against the user certificate
++   * - in general we can compare the pe task request owner against the job owner
++   */
++   if (!sge_security_verify_unique_identifier(false, lGetString(jep, JB_owner), progname, 0, host, commproc, id))
++   {
++      /* Error message is generated in sge_security_verify_unique_identifier */
++      goto Error;
++   }
++
++   if (strcmp(lGetString(jep, JB_owner), lGetString(petrep, PETR_owner)) != 0)
++   {
++      WARNING((SGE_EVENT, MSG_DENIED_PETASKREQUEST_WRONG_USER_SS, lGetString(petrep, PETR_owner), lGetString(jep, JB_owner)));
+       goto Error;
+    }
+ 
+    /* do not accept the task if job is not parallel or 'control_slaves' is not active */
+-   if (!(pe=lGetObject(jatep, JAT_pe_object)) || !lGetBool(pe, PE_control_slaves)) {
++   if (!(pe=lGetObject(jatep, JAT_pe_object)) || !lGetBool(pe, PE_control_slaves))
++   {
+       ERROR((SGE_EVENT, MSG_JOB_TASKNOSUITABLEJOB_U, sge_u32c(jobid)));
+       goto Error;
+    }
+ 
+    /* do not accept the task if job is in deletion */
+-   if (lGetUlong(jatep, JAT_state) & JDELETED) {
++   if (lGetUlong(jatep, JAT_state) & JDELETED)
++   {
+       DPRINTF(("received task exec request while job is in deletion or exiting\n"));
+       goto Error;
+    }
+ 
+    /* generate unique task id by combining consecutive number 1-max(u_long32) */
+    tid = MAX(1, lGetUlong(jatep, JAT_next_pe_task_id));
+-   sprintf(new_task_id, "%d.%s", tid, unqualified_hostname);
++   snprintf(new_task_id, sizeof(new_task_id), "%d.%s", tid, unqualified_hostname);
+    DPRINTF(("using pe_task_id_str %s for job "sge_u32"."sge_u32"\n", new_task_id, jobid, jataskid));
++
++   petep = lCreateElem(PET_Type);
+    lSetString(petep, PET_id, new_task_id);
+ 
+    /* set taskid for next task to be started */
+@@ -703,10 +719,8 @@
+    lSetString(petep, PET_name, "petask");
+    lSetUlong(petep, PET_submission_time, lGetUlong(petrep, PETR_submission_time));
+    lSetString(petep, PET_cwd, lGetString(petrep, PETR_cwd));
+-   lSetList(petep, PET_environment, 
+-            lCopyList("petask environment", lGetList(petrep, PETR_environment)));
+-   lSetList(petep, PET_path_aliases, 
+-            lCopyList("petask path_aliases", lGetList(petrep, PETR_path_aliases)));
++   lSetList(petep, PET_environment, lCopyList("petask environment", lGetList(petrep, PETR_environment)));
++   lSetList(petep, PET_path_aliases, lCopyList("petask path_aliases", lGetList(petrep, PETR_path_aliases)));
+ 
+    requested_queue = lGetString(petrep, PETR_queuename);
+ 
+@@ -728,14 +742,18 @@
+    }
+          
+    /* put task into task_list of slave/master job */ 
+-   if (lGetList(jatep, JAT_task_list) == NULL) {
++   if (lGetList(jatep, JAT_task_list) == NULL)
++   {
+       lSetList(jatep, JAT_task_list, lCreateList("task_list", PET_Type));
+    }
++
+    /* put task into task_list of slave/master job */ 
+    lAppendElem(lGetList(jatep, JAT_task_list), petep);
+ 
+-   if (!mconf_get_simulate_jobs()) {
+-      if (job_write_spool_file(jep, jataskid, NULL, SPOOL_WITHIN_EXECD)) { 
++   if (!mconf_get_simulate_jobs())
++   {
++      if (job_write_spool_file(jep, jataskid, NULL, SPOOL_WITHIN_EXECD))
++      { 
+          dstring err_str = DSTRING_INIT;
+          sge_dstring_copy_string(&err_str, SGE_EVENT);
+          execd_job_start_failure(jep, jatep, petep, sge_dstring_get_string(&err_str), 1);
+@@ -756,23 +774,27 @@
+       add_usage(jr, "submission_time", NULL, lGetUlong(petep, PET_submission_time));
+       
+       /* if we are not interested in online usage per task, suppress sending of this job report */
+-      if (mconf_get_sharetree_reserved_usage() && lGetBool(pe, PE_accounting_summary)) {
++      if (mconf_get_sharetree_reserved_usage() && lGetBool(pe, PE_accounting_summary))
++      {
+          lSetBool(jr, JR_no_send, true);
+       }
+    }
+ 
+    /* for debugging: never start job but report a failure */
+-   if (getenv("FAILURE_BEFORE_START")) {
++   if (getenv("FAILURE_BEFORE_START"))
++   {
+       execd_job_start_failure(jep, jatep, petep, "FAILURE_BEFORE_START", 0);
+    }   
+ 
+-   if (sge_make_pe_task_active_dir(jep, jatep, petep, NULL) == NULL) {
++   if (sge_make_pe_task_active_dir(jep, jatep, petep, NULL) == NULL)
++   {
+      goto Error;
+    }
+ 
+    /* put task into task_list of slave/master job */ 
+    /* send ack to sender of task */
+-   if (tid) {
++   if (tid)
++   {
+       DPRINTF(("sending tid %s\n", new_task_id)); 
+       packstr(apb, new_task_id);
+    }
+@@ -881,7 +903,8 @@
+     * validate, stdin may not be the same as stdout or stderr
+     * except, when it is "/dev/null".
+     */
+-   if (ret) {
++   if (ret)
++   {
+       char stdin_path[SGE_PATH_MAX];
+       char stdout_path[SGE_PATH_MAX];
+       char stderr_path[SGE_PATH_MAX];
+@@ -909,12 +932,16 @@
+                    job_id,
+                    job_is_array(job) ? ja_task_id : 0,
+                    SGE_STDERR, stderr_path, SGE_PATH_MAX);
+-      if (strcmp(stdin_path, "/dev/null") != 0) {
+-         if (strcmp(stdin_path, stdout_path) == 0) {
++      if (strcmp(stdin_path, "/dev/null") != 0)
++      {
++         if (strcmp(stdin_path, stdout_path) == 0)
++         {
+             answer_list_add_sprintf(answer_list, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, 
+                               MSG_JOB_SAMEPATHSFORINPUTANDOUTPUT_SSS, stdin_path, "stdout", stdout_path);
+             ret = false;
+-         } else if (strcmp(stdin_path, stderr_path) == 0) {
++         }
++         else if (strcmp(stdin_path, stderr_path) == 0)
++         {
+             answer_list_add_sprintf(answer_list, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, 
+                               MSG_JOB_SAMEPATHSFORINPUTANDOUTPUT_SSS, stdin_path, "stderr", stderr_path);
+             ret = false;
+diff -ruN --exclude .svn GE2011.11/source/daemons/execd/exec_job.c gridscheduler-trunk/source/daemons/execd/exec_job.c
+--- GE2011.11/source/daemons/execd/exec_job.c	2011-11-14 12:00:42.000000000 -0700
++++ gridscheduler-trunk/source/daemons/execd/exec_job.c	2012-03-21 09:25:08.801980829 -0600
+@@ -493,7 +493,7 @@
+                && strcmp(sge_dstring_get_string(&core_binding_strategy_string), "NULL") != 0) {
+             
+             sge_dstring_sprintf(&pseudo_usage, "binding_inuse=%s", 
+-                           binding_get_topology_for_job((sge_dstring_get_string(&core_binding_strategy_string))));
++                           binding_get_topology_for_job(sge_dstring_get_string(&core_binding_strategy_string)));
+ 
+             jr = get_job_report(job_id, ja_task_id, pe_task_id);
+             
+diff -ruN --exclude .svn GE2011.11/source/daemons/execd/msg_execd.h gridscheduler-trunk/source/daemons/execd/msg_execd.h
+--- GE2011.11/source/daemons/execd/msg_execd.h	2011-11-14 12:00:42.000000000 -0700
++++ gridscheduler-trunk/source/daemons/execd/msg_execd.h	2012-04-17 09:13:35.809359940 -0600
+@@ -235,6 +235,7 @@
+ #define MSG_JOB_NOFREEQ_USSS          _MESSAGE(29145, _("no free queue for job "sge_U32CFormat" of user "SFN"@"SFN" (localhost = "SFN")"))
+ #define MSG_JOB_INVALIDJATASK_REQUEST _MESSAGE(29146, _("invalid task list in job start request"))
+ #define MSG_JOB_SAMEPATHSFORINPUTANDOUTPUT_SSS   _MESSAGE(29147, _("same paths given for stdin ("SFQ") and "SFN" ("SFQ")"))
++#define MSG_DENIED_PETASKREQUEST_WRONG_USER_SS   _MESSAGE(29148, _("denied request of user "SFQ" to start a pe task in job of user "SFQ))
+ /*
+ ** execd_kill_execd.c
+ */
+diff -ruN --exclude .svn GE2011.11/source/daemons/qmaster/sge_c_gdi.c gridscheduler-trunk/source/daemons/qmaster/sge_c_gdi.c
+--- GE2011.11/source/daemons/qmaster/sge_c_gdi.c	2011-11-14 12:00:43.000000000 -0700
++++ gridscheduler-trunk/source/daemons/qmaster/sge_c_gdi.c	2012-04-17 09:13:35.962354449 -0600
+@@ -1253,7 +1253,7 @@
+ /*
+  * MT-NOTE: sge_c_gdi_mod() is MT safe
+  */
+-void sge_c_gdi_mod(sge_gdi_ctx_class_t *ctx, gdi_object_t *ao,
++static void sge_c_gdi_mod(sge_gdi_ctx_class_t *ctx, gdi_object_t *ao,
+                    sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task, int sub_command,
+                    monitoring_t *monitor)
+ {
+diff -ruN --exclude .svn GE2011.11/source/daemons/qmaster/sge_host_qmaster.c gridscheduler-trunk/source/daemons/qmaster/sge_host_qmaster.c
+--- GE2011.11/source/daemons/qmaster/sge_host_qmaster.c	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/daemons/qmaster/sge_host_qmaster.c	2012-04-17 09:13:35.968354233 -0600
+@@ -112,7 +112,8 @@
+    object_base = object_type_get_object_description();
+ 
+    /* initiate timer for all hosts because they start in 'unknown' state */
+-   if (*object_base[SGE_TYPE_EXECHOST].list) {
++   if (*object_base[SGE_TYPE_EXECHOST].list)
++   {
+       lListElem *host               = NULL;
+       lListElem *global_host_elem   = NULL;
+       lListElem *template_host_elem = NULL;
+@@ -123,8 +124,10 @@
+       /* get "template" element pointer */
+       template_host_elem = host_list_locate(*object_base[SGE_TYPE_EXECHOST].list, SGE_TEMPLATE_NAME);
+       
+-      for_each(host, *object_base[SGE_TYPE_EXECHOST].list) {
+-         if ((host != global_host_elem) && (host != template_host_elem)) {
++      for_each(host, *object_base[SGE_TYPE_EXECHOST].list)
++      {
++         if ((host != global_host_elem) && (host != template_host_elem))
++         {
+             reschedule_add_additional_time(load_report_interval(host));
+             reschedule_unknown_trigger(host);
+             reschedule_add_additional_time(0);
+@@ -159,11 +162,11 @@
+ 
+    load_attr_list = lGetList(host, EH_load_list);
+    next_load_attr = lFirst(load_attr_list);
+-   while ((load_attr = next_load_attr)) {
++   while ((load_attr = next_load_attr))
++   {
+       next_load_attr = lNext(load_attr);
+-      if (!lGetBool(load_attr, HL_static)) {
++      if (!lGetBool(load_attr, HL_static))
+          lRemoveElem(load_attr_list, &load_attr);
+-      }
+    }
+ }
+ 
+@@ -190,7 +193,8 @@
+ 
+    DENTER(TOP_LAYER, "sge_add_host_of_type");
+ 
+-   if (hostname == NULL) {
++   if (hostname == NULL)
++   {
+       DRETURN(-1);
+    }
+   
+@@ -200,7 +204,8 @@
+    ep = lCreateElem(object->type);
+    pos = lGetPosInDescr(object->type,object->key_nm);
+    dataType = lGetPosType(object->type , pos);
+-   switch (dataType) {
++   switch (dataType)
++   {
+       case lStringT:
+          lSetString(ep, object->key_nm, hostname);
+          break;
+@@ -210,8 +215,8 @@
+       default:
+          DPRINTF(("sge_add_host_of_type: unexpected datatype\n"));
+    }
+-   ret = sge_gdi_add_mod_generic(ctx, NULL, ep, 1, object, username, 
+-      qualified_hostname, 0, &ppList, monitor);
++
++   ret = sge_gdi_add_mod_generic(ctx, NULL, ep, 1, object, username, qualified_hostname, 0, &ppList, monitor);
+    lFreeElem(&ep);
+    lFreeList(&ppList);
+ 
+@@ -230,13 +235,13 @@
+    lListElem *href = NULL;
+ 
+    DENTER(TOP_LAYER, "host_list_add_missing_href");
+-   for_each(href, href_list) {
++   for_each(href, href_list)
++   {
+       const char *hostname = lGetHost(href, HR_name);
+       lListElem *host = host_list_locate(this_list, hostname);
+ 
+-      if (host == NULL) {
++      if (host == NULL)
+          ret &= (sge_add_host_of_type(ctx, hostname, SGE_EH_LIST, monitor) == 0);
+-      }
+    }
+    DRETURN(ret);
+ }
+@@ -265,44 +270,51 @@
+ 
+    DENTER(TOP_LAYER, "sge_del_host");
+ 
+-   if ( !hep || !ruser || !rhost ) {
++   if ( !hep || !ruser || !rhost )
++   {
+       CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
+       answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
+       DEXIT;
+       return STATUS_EUNKNOWN;
+    }
+ 
+-   switch ( target ) {
+-   case SGE_EH_LIST:
++   switch ( target )
++   {
++    case SGE_EH_LIST:
+       host_list = object_type_get_master_list(SGE_TYPE_EXECHOST);
+       nm = EH_name;
+       name = "execution host";
+       break;
+-   case SGE_AH_LIST:
++
++    case SGE_AH_LIST:
+       host_list = object_type_get_master_list(SGE_TYPE_ADMINHOST);
+       nm = AH_name;
+       name = "administrative host";
+       break;
+-   case SGE_SH_LIST:
++
++    case SGE_SH_LIST:
+       host_list = object_type_get_master_list(SGE_TYPE_SUBMITHOST);
+       nm = SH_name;
+       name = "submit host";
+       break;
+-   default:
++
++    default:
+      DEXIT;
+      return STATUS_EUNKNOWN;
+    }
++
+    /* ep is no host element, if ep has no nm */
+-   if ((pos = lGetPosViaElem(hep, nm, SGE_NO_ABORT)) < 0) {
+-      ERROR((SGE_EVENT, MSG_SGETEXT_MISSINGCULLFIELD_SS,
+-            lNm2Str(nm), SGE_FUNC));
++   if ((pos = lGetPosViaElem(hep, nm, SGE_NO_ABORT)) < 0)
++   {
++      ERROR((SGE_EVENT, MSG_SGETEXT_MISSINGCULLFIELD_SS, lNm2Str(nm), SGE_FUNC));
+       answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
+       DEXIT;
+       return STATUS_EUNKNOWN;
+    }
+ 
+    host = lGetPosHost(hep, pos);
+-   if (!host) {
++   if (!host)
++   {
+       ERROR((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
+       answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
+       DEXIT;
+@@ -310,7 +322,8 @@
+    }
+ 
+    ret = sge_resolve_hostname(host, unique, EH_name);
+-   if (ret  != CL_RETVAL_OK) {
++   if (ret  != CL_RETVAL_OK)
++   {
+       /* 
+        * Due to CR 6319231, IZ 1760 this is allowed 
+        */
+@@ -318,7 +331,8 @@
+    }
+ 
+    /* check if host is in host list */
+-   if ((ep=host_list_locate(*host_list, unique))==NULL) {
++   if ((ep=host_list_locate(*host_list, unique))==NULL)
++   {
+       /* may be host was not the unique hostname.
+          Get the unique hostname and try to find it again. */
+       if (getuniquehostname(host, unique, 0)!=CL_RETVAL_OK)
+@@ -328,9 +342,11 @@
+          DEXIT;
+          return STATUS_EUNKNOWN;
+       }
++
+       /* again check if host is in host list. This time use the unique
+          hostname */
+-      if ((ep=host_list_locate(*host_list, unique))==NULL) {
++      if ((ep=host_list_locate(*host_list, unique))==NULL)
++      {
+          ERROR((SGE_EVENT, MSG_SGETEXT_DOESNOTEXIST_SS, name, host));
+          answer_list_add(alpp, SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_ERROR);
+          DEXIT;
+@@ -342,69 +358,68 @@
+       check if someone tries to delete 
+       the qmaster host from admin host list
+    */
+-   if (target==SGE_AH_LIST && 
+-         !sge_hostcmp(unique, qualified_hostname)) {
+-      ERROR((SGE_EVENT, MSG_SGETEXT_CANTDELADMINQMASTER_S, 
+-          qualified_hostname));
+-      answer_list_add(alpp, SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_ERROR);
+-      DEXIT;
+-      return STATUS_EEXIST;
+-   }
+-
+-   if (target == SGE_EH_LIST && 
+-       host_is_referenced(hep, alpp, 
+-                          *(object_type_get_master_list(SGE_TYPE_CQUEUE)),
+-                          master_hGroup_List)) {
+-      answer_list_log(alpp, false, true);                    
+-      DEXIT;
+-      return STATUS_ESEMANTIC;
+-   }
+-
+-   if (target==SGE_EH_LIST && !strcasecmp(unique, "global")) {
+-      ERROR((SGE_EVENT, MSG_OBJ_DELGLOBALHOST));
+-      answer_list_add(alpp, SGE_EVENT, STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR);
+-      DEXIT;
+-      return STATUS_ESEMANTIC;
+-   }
+ 
+    /* remove host file and send event */
+-   switch(target) {
++   switch (target)
++   {
+       case SGE_AH_LIST:
+-         {
+-            lList *answer_list = NULL;
+-            sge_event_spool(ctx, &answer_list, 0, sgeE_ADMINHOST_DEL, 
+-                            0, 0, lGetHost(ep, nm), NULL, NULL,
+-                            NULL, NULL, NULL, true, true);
+-            answer_list_output(&answer_list);
+-         }
+-         break;
++      {
++        lList *answer_list = NULL;
++
++        if (!sge_hostcmp(unique, qualified_hostname))
++        {
++           ERROR((SGE_EVENT, MSG_SGETEXT_CANTDELADMINQMASTER_S, qualified_hostname));
++           answer_list_add(alpp, SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_ERROR);
++           DEXIT;
++           return STATUS_EEXIST;
++        }
++
++        sge_event_spool(ctx, &answer_list, 0, sgeE_ADMINHOST_DEL, 0, 0, lGetHost(ep, nm), NULL, NULL, NULL, NULL, NULL, true, true);
++        answer_list_output(&answer_list);
++
++        break;
++      }
++
+       case SGE_EH_LIST:
+-         {
+-            lList *answer_list = NULL;
+-            sge_event_spool(ctx, &answer_list, 0, sgeE_EXECHOST_DEL, 
+-                            0, 0, lGetHost(ep, nm), NULL, NULL,
+-                            NULL, NULL, NULL, true, true);
+-            answer_list_output(&answer_list);
+-         }
+-	 host_update_categories(NULL, ep);
++      {
++        lList *answer_list = NULL;
++
++        if (host_is_referenced(hep, alpp, *(object_type_get_master_list(SGE_TYPE_CQUEUE)), master_hGroup_List))
++        {
++           answer_list_log(alpp, false, true);
++           DEXIT;
++           return STATUS_ESEMANTIC;
++        }
++        else if (!strcasecmp(unique, "global"))
++        {
++           ERROR((SGE_EVENT, MSG_OBJ_DELGLOBALHOST));
++           answer_list_add(alpp, SGE_EVENT, STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR);
++           DEXIT;
++           return STATUS_ESEMANTIC;
++        }
++
++        sge_event_spool(ctx, &answer_list, 0, sgeE_EXECHOST_DEL, 0, 0, lGetHost(ep, nm), NULL, NULL, NULL, NULL, NULL, true, true);
++        answer_list_output(&answer_list);
++        host_update_categories(NULL, ep);
++
++        break;
++      }
+ 
+-         break;
+       case SGE_SH_LIST:
+-         {
+-            lList *answer_list = NULL;
+-            sge_event_spool(ctx, &answer_list, 0, sgeE_SUBMITHOST_DEL, 
+-                            0, 0, lGetHost(ep, nm), NULL, NULL,
+-                            NULL, NULL, NULL, true, true);
+-            answer_list_output(&answer_list);
+-         }
+-         break;
++      {
++        lList *answer_list = NULL;
++
++        sge_event_spool(ctx, &answer_list, 0, sgeE_SUBMITHOST_DEL, 0, 0, lGetHost(ep, nm), NULL, NULL, NULL, NULL, NULL, true, true);
++        answer_list_output(&answer_list);
++
++        break;
++      }
+    }
+ 
+    /* delete found host element */
+    lRemoveElem(*host_list, &ep);
+ 
+-   INFO((SGE_EVENT, MSG_SGETEXT_REMOVEDFROMLIST_SSSS, 
+-         ruser, rhost, unique, name));
++   INFO((SGE_EVENT, MSG_SGETEXT_REMOVEDFROMLIST_SSSS, ruser, rhost, unique, name));
+    answer_list_add(alpp, SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);
+    DEXIT;
+    return STATUS_OK;
+@@ -421,8 +436,8 @@
+ const char *ruser,
+ const char *rhost,
+ gdi_object_t *object,
+-int sub_command, monitoring_t *monitor
+-) {
++int sub_command, monitoring_t *monitor)
++{
+    const char *host;
+    int nm;
+    int pos;
+@@ -582,29 +597,29 @@
+ 
+    pos = lGetPosViaElem(ep, object->key_nm, SGE_NO_ABORT );
+    dataType = lGetPosType(lGetElemDescr(ep),pos);
+-   if (dataType == lHostT ) { 
++   if (dataType == lHostT )
+       key = lGetHost(ep, object->key_nm);
+-   } else {
++   else
+       key = lGetString(ep, object->key_nm);
+-   }
+-     
+-   switch (object->key_nm) {
++ 
++   switch (object->key_nm)
++   {
+       case AH_name:
+          host_type = SGE_TYPE_ADMINHOST;
+          break;
++
+       case EH_name:
+          host_type = SGE_TYPE_EXECHOST;
+          break;
++
+       case SH_name:
+          host_type = SGE_TYPE_SUBMITHOST;
+          break;
+    }
+      
+-   if (!spool_write_object(alpp, spool_get_default_context(), ep, key, host_type, job_spooling)) {
+-      answer_list_add_sprintf(alpp, STATUS_EUNKNOWN, 
+-                              ANSWER_QUALITY_ERROR, 
+-                              MSG_PERSISTENCE_WRITE_FAILED_S,
+-                              key);
++   if (!spool_write_object(alpp, spool_get_default_context(), ep, key, host_type, job_spooling))
++   {
++      answer_list_add_sprintf(alpp, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, MSG_PERSISTENCE_WRITE_FAILED_S, key);
+       ret = 1;
+    }
+    answer_list_output(&answer_list);
+@@ -616,7 +631,8 @@
+ {
+    DENTER(TOP_LAYER, "host_success");
+ 
+-   switch(object->key_nm) {
++   switch(object->key_nm)
++   {
+       case EH_name:
+       {
+          const char *host = lGetHost(ep, EH_name);
+@@ -624,34 +640,40 @@
+ 
+          sge_change_queue_version_exechost(ctx, host);
+ 
+-         if (global_host) {
++         if (global_host)
++         {
+             host_list_merge(*object_type_get_master_list(SGE_TYPE_EXECHOST));
+-         } else {
++         }
++         else
++         {
+             const lListElem *global_ep = NULL;
+ 
+-            global_ep = lGetElemHost(*object_type_get_master_list(SGE_TYPE_EXECHOST), EH_name,
+-                                     SGE_GLOBAL_NAME);
++            global_ep = lGetElemHost(*object_type_get_master_list(SGE_TYPE_EXECHOST), EH_name, SGE_GLOBAL_NAME);
+             host_merge(ep, global_ep);
+          }
+ 
+          host_update_categories(ep, old_ep);
+-         sge_add_event( 0, old_ep?sgeE_EXECHOST_MOD:sgeE_EXECHOST_ADD,
+-                       0, 0, host, NULL, NULL, ep);
++         sge_add_event( 0, old_ep?sgeE_EXECHOST_MOD:sgeE_EXECHOST_ADD, 0, 0, host, NULL, NULL, ep);
+          lListElem_clear_changed_info(ep);
++
++         break;
+       }
+-      break;
+ 
+       case AH_name:
+-         sge_add_event( 0, old_ep?sgeE_ADMINHOST_MOD:sgeE_ADMINHOST_ADD, 
+-                       0, 0, lGetHost(ep, AH_name), NULL, NULL, ep);
++      {
++         sge_add_event( 0, old_ep?sgeE_ADMINHOST_MOD:sgeE_ADMINHOST_ADD, 0, 0, lGetHost(ep, AH_name), NULL, NULL, ep);
+          lListElem_clear_changed_info(ep);
+-      break;
++
++         break;
++      }
+ 
+       case SH_name:
+-         sge_add_event( 0, old_ep?sgeE_SUBMITHOST_MOD:sgeE_SUBMITHOST_ADD, 
+-                       0, 0, lGetHost(ep, SH_name), NULL, NULL, ep);
++      {
++         sge_add_event( 0, old_ep?sgeE_SUBMITHOST_MOD:sgeE_SUBMITHOST_ADD, 0, 0, lGetHost(ep, SH_name), NULL, NULL, ep);
+          lListElem_clear_changed_info(ep);
+-      break;
++
++         break;
++      }
+    }
+ 
+    DRETURN(0);
+@@ -659,18 +681,19 @@
+ 
+ /* ------------------------------------------------------------ */
+ 
+-void sge_mark_unheard(lListElem *hep) {
++void sge_mark_unheard(lListElem *hep)
++{
+    const char *host;
+ 
+    DENTER(TOP_LAYER, "sge_mark_unheard");
+ 
+    host = lGetHost(hep, EH_name);
+ 
+-   if (cl_com_remove_known_endpoint_from_name(host, prognames[EXECD], 1) == CL_RETVAL_OK) {
++   if (cl_com_remove_known_endpoint_from_name(host, prognames[EXECD], 1) == CL_RETVAL_OK)
+       DEBUG((SGE_EVENT, "set %s/%s/%d to unheard\n", host, prognames[EXECD], 1));
+-   }
+ 
+-   if (lGetUlong(hep, EH_lt_heard_from) != 0) {
++   if (lGetUlong(hep, EH_lt_heard_from) != 0)
++   {
+       host_trash_nonstatic_load_values(hep);
+       cqueue_list_set_unknown_state(
+             *(object_type_get_master_list(SGE_TYPE_CQUEUE)),
+@@ -705,13 +728,9 @@
+ 
+    DENTER(TOP_LAYER, "sge_update_load_values");
+ 
+-   /* JG: TODO: this time should better come with the report.
+-    *           it is the time when the reported values were valid.
+-    */
+-   now = sge_get_gmt();
+-
+    host_ep = lGetElemHost(*object_type_get_master_list(SGE_TYPE_EXECHOST), EH_name, rhost);
+-   if (host_ep == NULL) {
++   if (host_ep == NULL)
++   {
+       /* report from unknown host arrived, ignore it */
+       DRETURN_VOID;
+    }
+@@ -719,7 +738,8 @@
+    /* 
+     * if rhost is unknown set him to known
+     */
+-   if (lGetUlong(host_ep, EH_lt_heard_from) == 0) {
++   if (lGetUlong(host_ep, EH_lt_heard_from) == 0)
++   {
+       cqueue_list_set_unknown_state(*(object_type_get_master_list(SGE_TYPE_CQUEUE)),
+                                     rhost, true, false);
+ 
+@@ -729,6 +749,11 @@
+       lSetUlong(host_ep, EH_lt_heard_from, sge_get_gmt());
+    }
+ 
++   /* JG: TODO: this time should better come with the report.
++    *           it is the time when the reported values were valid.
++    */
++   now = sge_get_gmt();
++
+    host_ep = NULL;
+    /* loop over all received load values */
+    for_each(ep, lp) {
+@@ -844,7 +869,8 @@
+    /* get "global" element pointer */
+    global_host_elem   = host_list_locate(master_exechost_list, SGE_GLOBAL_NAME);    
+    /* get "template" element pointer */
+-   template_host_elem = host_list_locate(master_exechost_list, SGE_TEMPLATE_NAME); 
++   template_host_elem = host_list_locate(master_exechost_list, SGE_TEMPLATE_NAME);
++
+    /* take each host including the "global" host */
+    for_each(hep, master_exechost_list) {
+       unsigned long last_heard;
+diff -ruN --exclude .svn GE2011.11/source/daemons/qmaster/sge_job_verify.c gridscheduler-trunk/source/daemons/qmaster/sge_job_verify.c
+--- GE2011.11/source/daemons/qmaster/sge_job_verify.c	2011-11-14 12:00:43.000000000 -0700
++++ gridscheduler-trunk/source/daemons/qmaster/sge_job_verify.c	2012-03-21 09:25:08.861978693 -0600
+@@ -83,60 +83,58 @@
+ #include "msg_qmaster.h"
+ #include "msg_daemons_common.h"
+ 
+-int
+-sge_job_verify_adjust(sge_gdi_ctx_class_t *ctx, lListElem *jep, lList **alpp, 
+-                      lList **lpp, char *ruser, char *rhost, uid_t uid, gid_t gid, char *group, 
+-                      sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
+-                      monitoring_t *monitor)
++int sge_job_verify_adjust(sge_gdi_ctx_class_t *ctx, lListElem *jep, lList **alpp, lList **lpp,
++                          char *ruser, char *rhost, uid_t uid, gid_t gid, char *group, 
++                          sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
++                          monitoring_t *monitor)
+ {
+    object_description *object_base = object_type_get_object_description();
+    int ret = STATUS_OK;
+ 
+    DENTER(TOP_LAYER, "sge_job_verify_adjust");
+ 
+-   if (jep == NULL || ruser == NULL || rhost == NULL ) {
++   if (jep == NULL || ruser == NULL || rhost == NULL )
++   {
+       CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
+       answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
+       ret = STATUS_EUNKNOWN;
+    }
+ 
+-   /* check min_uid */
+-   if (ret == STATUS_OK) {
+-      if (uid < mconf_get_min_uid()) {
++   if (ret == STATUS_OK)
++   {
++      /* check min_uid */
++      if (uid < mconf_get_min_uid())
++      {
+          ERROR((SGE_EVENT, MSG_JOB_UID2LOW_II, (int)uid, (int)mconf_get_min_uid()));
+          answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
+          ret = STATUS_EUNKNOWN;
+       }
+-   }
+-
+-   /* check min_gid */
+-   if (ret == STATUS_OK) {
+-      if (gid < mconf_get_min_gid()) {
++      /* check min_gid */
++      else if (gid < mconf_get_min_gid())
++      {
+          ERROR((SGE_EVENT, MSG_JOB_GID2LOW_II, (int)gid, (int)mconf_get_min_gid()));
+          answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
+          ret = STATUS_EUNKNOWN;
+       }
+-   }
+-
+-   /* 
+-    * adjust user and group    
+-    *
+-    * we cannot rely on the information we got from the client
+-    * therefore we fill in the data we got from communication
+-    * library.
+-    */
+-   if (ret == STATUS_OK) {
+-      if (!job_set_owner_and_group(jep, uid, gid, ruser, group)) {
++      /*
++       * adjust user and group
++       *
++       * we cannot rely on the information we got from the client
++       * therefore we fill in the data we got from communication
++       * library.
++       */
++      else if (!job_set_owner_and_group(jep, uid, gid, ruser, group))
++      {
+          ret = STATUS_EUNKNOWN;
+       }
+    }
+ 
+ 
+    /* check for qsh without DISPLAY set */
+-   if (ret == STATUS_OK) {
+-      if (JOB_TYPE_IS_QSH(lGetUlong(jep, JB_type))) {
++   if (ret == STATUS_OK)
++   {
++      if (JOB_TYPE_IS_QSH(lGetUlong(jep, JB_type)))
+          ret = job_check_qsh_display(jep, alpp, false);
+-      }   
+    }
+ 
+    /*
+@@ -144,26 +142,27 @@
+     *    JB_ja_structure, JB_ja_n_h_ids, JB_ja_u_h_ids, 
+     *    JB_ja_s_h_ids, JB_ja_o_h_ids, JB_ja_a_h_ids, JB_ja_z_ids
+     */
+-   if (ret == STATUS_OK) {
++   if (ret == STATUS_OK)
++   {
+       job_check_correct_id_sublists(jep, alpp);
+-      if (answer_list_has_error(alpp)) {
++      if (answer_list_has_error(alpp))
+          ret = STATUS_EUNKNOWN;
+-      }
+    }  
+ 
+    /*
+     * resolve host names contained in path names
+     */ 
+-   if (ret == STATUS_OK) {
++   if (ret == STATUS_OK)
++   {
+       int s1, s2, s3, s4;
+       
+       s1 = job_resolve_host_for_path_list(jep, alpp, JB_stdout_path_list);
+       s2 = job_resolve_host_for_path_list(jep, alpp, JB_stdin_path_list);
+-      s3 = job_resolve_host_for_path_list(jep, alpp,JB_shell_list);
++      s3 = job_resolve_host_for_path_list(jep, alpp, JB_shell_list);
+       s4 = job_resolve_host_for_path_list(jep, alpp, JB_stderr_path_list);
+-      if (s1 != STATUS_OK || s2 != STATUS_OK || s3 != STATUS_OK || s4 != STATUS_OK) {
++
++      if (s1 != STATUS_OK || s2 != STATUS_OK || s3 != STATUS_OK || s4 != STATUS_OK)
+          ret = STATUS_EUNKNOWN;
+-      }
+    }
+ 
+    /* take care that non-binary jobs have a script */
+@@ -176,40 +175,45 @@
+       }
+    }
+ 
+-   /* set the jobs submittion time */
+-   if (ret == STATUS_OK) {
++   if (ret == STATUS_OK)
++   {
++      /* set the jobs submittion time */
+       lSetUlong(jep, JB_submission_time, sge_get_gmt());
+-   }
+ 
+-   /* initialize the task template element and other sublists */
+-   if (ret == STATUS_OK) {
++      /* initialize the task template element and other sublists */
+       lSetList(jep, JB_ja_tasks, NULL);
+       lSetList(jep, JB_jid_successor_list, NULL);
+       lSetList(jep, JB_ja_ad_successor_list, NULL);
+-      if (lGetList(jep, JB_ja_template) == NULL) {
++
++      if (lGetList(jep, JB_ja_template) == NULL)
+          lAddSubUlong(jep, JAT_task_number, 0, JB_ja_template, JAT_Type);
+-      }
+-   } 
++   }
+ 
+-   if (ret == STATUS_OK) {
++   if (ret == STATUS_OK)
++   {
+       lListElem *binding_elem = lFirst(lGetList(jep, JB_binding));
+                
+-      if (binding_elem == NULL) {
++      if (binding_elem == NULL)
++      {
+          bool lret = job_init_binding_elem(jep);
+ 
+-         if (lret == false) {
++         if (lret == false)
+             ret = STATUS_EUNKNOWN;
+-         }
+       }
+    }
+ 
+    /* verify or set the account string */
+-   if (ret == STATUS_OK) {
+-      if (!lGetString(jep, JB_account)) {
++   if (ret == STATUS_OK)
++   {
++      if (!lGetString(jep, JB_account))
++      {
+          lSetString(jep, JB_account, DEFAULT_ACCOUNT);
+-      } else {
++      }
++      else
++      {
+          if (verify_str_key(alpp, lGetString(jep, JB_account), MAX_VERIFY_STRING,
+-                            "account string", QSUB_TABLE) != STATUS_OK) { 
++                            "account string", QSUB_TABLE) != STATUS_OK)
++         { 
+             ret = STATUS_EUNKNOWN;
+          }
+       }
+@@ -296,7 +300,7 @@
+         if (suser_check_new_job(jep, mconf_get_max_u_jobs()) != 0)
+         { 
+            INFO((SGE_EVENT, MSG_JOB_ALLOWEDJOBSPERUSER_UU, sge_u32c(mconf_get_max_u_jobs()),
+-                                                         sge_u32c(suser_job_count(jep))));
++                                                           sge_u32c(suser_job_count(jep))));
+            answer_list_add(alpp, SGE_EVENT, STATUS_NOTOK_DOAGAIN, ANSWER_QUALITY_ERROR);
+            DRETURN(STATUS_NOTOK_DOAGAIN);
+         }
+@@ -306,18 +310,18 @@
+    {
+       lList *user_lists = mconf_get_user_lists();
+       lList *xuser_lists = mconf_get_xuser_lists();
++      int has_access = sge_has_access_(ruser, lGetString(jep, JB_group), /* read */
++                                       user_lists, xuser_lists, *object_base[SGE_TYPE_USERSET].list);
+ 
+-      if (!sge_has_access_(ruser, lGetString(jep, JB_group), /* read */
+-                           user_lists, xuser_lists, *object_base[SGE_TYPE_USERSET].list))
++      lFreeList(&xuser_lists);
++      lFreeList(&user_lists);
++
++      if (!has_access)
+       {
+          ERROR((SGE_EVENT, MSG_JOB_NOPERMS_SS, ruser, rhost));
+          answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
+-         lFreeList(&user_lists);
+-         lFreeList(&xuser_lists);
+          DRETURN(STATUS_EUNKNOWN);
+       }
+-      lFreeList(&user_lists);
+-      lFreeList(&xuser_lists);
+    }
+ 
+    /* 
+@@ -330,8 +334,8 @@
+       lList *master_centry_list = *object_base[SGE_TYPE_CENTRY].list;
+ 
+       if (centry_list_fill_request(lGetList(jep, JB_hard_resource_list),
+-                                   alpp, master_centry_list, false, true,
+-                                   false)) {
++                                   alpp, master_centry_list, false, true, false))
++      {
+          DRETURN(STATUS_EUNKNOWN);
+       }
+       if (compress_ressources(alpp, lGetList(jep, JB_hard_resource_list), SGE_OBJ_JOB))
+@@ -340,8 +344,7 @@
+       }
+ 
+       if (centry_list_fill_request(lGetList(jep, JB_soft_resource_list),
+-                                   alpp, master_centry_list, false, true,
+-                                   false))
++                                   alpp, master_centry_list, false, true, false))
+       {
+          DRETURN(STATUS_EUNKNOWN);
+       }
+@@ -388,11 +391,12 @@
+     */
+    {
+       const char *pe_name = NULL;
+-      lList *pe_range = NULL;
+ 
+       pe_name = lGetString(jep, JB_pe);
+-      if (pe_name) {
++      if (pe_name)
++      {
+          const lListElem *pep;
++         lList *pe_range;
+ 
+          pep = pe_list_find_matching(*object_base[SGE_TYPE_PE].list, pe_name);
+          if (!pep) {
+@@ -402,7 +406,8 @@
+          }
+          /* check pe_range */
+          pe_range = lGetList(jep, JB_pe_range);
+-         if (object_verify_pe_range(alpp, pe_name, pe_range, SGE_OBJ_JOB)!=STATUS_OK) {
++         if (object_verify_pe_range(alpp, pe_name, pe_range, SGE_OBJ_JOB)!=STATUS_OK)
++         {
+             DRETURN(STATUS_EUNKNOWN);
+          }
+ 
+@@ -431,38 +436,39 @@
+ 
+    {
+       u_long32 ckpt_attr = lGetUlong(jep, JB_checkpoint_attr);
+-      u_long32 ckpt_inter = lGetUlong(jep, JB_checkpoint_interval);
+       const char *ckpt_name = lGetString(jep, JB_checkpoint_name);
+-      lListElem *ckpt_ep;
+       int ckpt_err = 0;
+ 
+       /* request for non existing ckpt object will be refused */
+-      if ((ckpt_name != NULL)) {
++      if (ckpt_name != NULL)
++      {
++         lListElem *ckpt_ep;
++
+          if (!(ckpt_ep = ckpt_list_locate(*object_base[SGE_TYPE_CKPT].list, ckpt_name)))
+             ckpt_err = 1;
+-         else if (!ckpt_attr) {
++         else if (!ckpt_attr)
++         {
+             ckpt_attr = sge_parse_checkpoint_attr(lGetString(ckpt_ep, CK_when));
+             lSetUlong(jep, JB_checkpoint_attr, ckpt_attr);
+          }
+       }
+ 
+-      if (!ckpt_err) {
+-         if ((ckpt_attr & NO_CHECKPOINT) && (ckpt_attr & ~NO_CHECKPOINT)) {
++      if (ckpt_err == 0)
++      {
++         if ((ckpt_attr & NO_CHECKPOINT) && (ckpt_attr & ~NO_CHECKPOINT))
+             ckpt_err = 2;
+-         }
+-         else if (ckpt_name && (ckpt_attr & NO_CHECKPOINT)) {
++         else if (ckpt_name && (ckpt_attr & NO_CHECKPOINT))
+             ckpt_err = 3;
+-         }
+-         else if ((!ckpt_name && (ckpt_attr & ~NO_CHECKPOINT))) {
++         else if (!ckpt_name && (ckpt_attr & ~NO_CHECKPOINT))
+             ckpt_err = 4;
+-         }
+-         else if (!ckpt_name && ckpt_inter) {
++         else if (!ckpt_name && lGetUlong(jep, JB_checkpoint_interval))
+             ckpt_err = 5;
+-         }
+       }
+ 
+-      if (ckpt_err) {
+-         switch (ckpt_err) {
++      if (ckpt_err)
++      {
++         switch (ckpt_err)
++         {
+          case 1:
+             ERROR((SGE_EVENT, MSG_JOB_CKPTUNKNOWN_S, ckpt_name));
+           break;
+@@ -484,28 +490,32 @@
+    }
+ 
+    /* first check user permissions */
++   if (lGetUlong(jep, JB_verify_suitable_queues) != SKIP_VERIFY)
+    {
+       lListElem *cqueue = NULL;
+       int has_permissions = 0;
+ 
+-      for_each (cqueue, *object_base[SGE_TYPE_CQUEUE].list) {
++      for_each (cqueue, *object_base[SGE_TYPE_CQUEUE].list)
++      {
+          lList *qinstance_list = lGetList(cqueue, CQ_qinstances);
+          lListElem *qinstance = NULL;
+          lList *master_userset_list = *object_base[SGE_TYPE_USERSET].list;
+ 
+-         for_each(qinstance, qinstance_list) {
++         for_each(qinstance, qinstance_list)
++         {
+             if (sge_has_access(ruser, lGetString(jep, JB_group),
+-                  qinstance, master_userset_list)) {
++                  qinstance, master_userset_list))
++            {
+                DPRINTF(("job has access to queue "SFQ"\n", lGetString(qinstance, QU_qname)));
+                has_permissions = 1;
+                break;
+             }
+          }
+-         if (has_permissions == 1) {
++         if (has_permissions == 1)
+             break;
+-         }
+       }
+-      if (has_permissions == 0) {
++      if (has_permissions == 0)
++      {
+          SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_JOB_NOTINANYQ_S, ruser));
+          answer_list_add(alpp, SGE_EVENT, STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR);
+       }
+@@ -518,7 +528,8 @@
+       if (enforce_user && !strcasecmp(enforce_user, "auto")) {
+          int status = sge_add_auto_user(ctx, ruser, alpp, monitor);
+ 
+-         if (status != STATUS_OK) {
++         if (status != STATUS_OK)
++         {
+             FREE(enforce_user);
+             DRETURN(status);
+          }
+@@ -579,16 +590,19 @@
+          DPRINTF(("job -ar "sge_u32"\n", sge_u32c(ar_id)));
+ 
+          ar=ar_list_locate(*object_base[SGE_TYPE_AR].list, ar_id);
+-         if (ar == NULL) {
++         if (ar == NULL)
++         {
+             ERROR((SGE_EVENT, MSG_JOB_NOAREXISTS_U, sge_u32c(ar_id)));
+             answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
+             DRETURN(STATUS_EEXIST);
+          } else if ((lGetUlong(ar, AR_state) == AR_DELETED) ||
+-                    (lGetUlong(ar, AR_state) == AR_EXITED)) {
++                    (lGetUlong(ar, AR_state) == AR_EXITED))
++         {
+             ERROR((SGE_EVENT, MSG_JOB_ARNOLONGERAVAILABE_U, sge_u32c(ar_id)));
+             answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
+             DRETURN(STATUS_EEXIST);
+          }
++
+          /* fill the job and ar values */         
+          ar_start_time = lGetUlong(ar, AR_start_time);
+          ar_end_time = lGetUlong(ar, AR_end_time);
+@@ -612,8 +626,8 @@
+          {
+             DPRINTF(("job -ar "sge_u32", ar_start_time "sge_u32", ar_end_time "sge_u32
+                      ", job_execution_time "sge_u32", job duration "sge_u32" \n",
+-                     sge_u32c(ar_id),sge_u32c( ar_start_time),sge_u32c(ar_end_time),
+-                     sge_u32c(job_execution_time),sge_u32c(job_duration)));
++                     sge_u32c(ar_id), sge_u32c( ar_start_time), sge_u32c(ar_end_time),
++                     sge_u32c(job_execution_time), sge_u32c(job_duration)));
+ 
+             /* fit the timeframe */
+             if (job_duration > (ar_end_time - ar_start_time))
+diff -ruN --exclude .svn GE2011.11/source/daemons/qmaster/sge_qmaster_main.c gridscheduler-trunk/source/daemons/qmaster/sge_qmaster_main.c
+--- GE2011.11/source/daemons/qmaster/sge_qmaster_main.c	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/daemons/qmaster/sge_qmaster_main.c	2012-04-17 09:13:35.964354377 -0600
+@@ -78,10 +78,9 @@
+ #   include "sge_smf.h"
+ #endif
+ 
+-#if !defined(INTERIX)
++#if !defined(INTERIX) && !defined(CYGWIN)
+ static void init_sig_action_and_mask(void);
+ #endif
+-static int set_file_descriptor_limit(void);
+ 
+ /****** qmaster/sge_qmaster_main/sge_qmaster_application_status() ************
+ *  NAME
+@@ -149,7 +148,8 @@
+ *              called before starting up the threads.
+ *
+ *******************************************************************************/
+-static int set_file_descriptor_limit(void) {
++static int set_file_descriptor_limit(void)
++{
+ 
+    /* define the max qmaster file descriptor limit */
+ #define SGE_MAX_QMASTER_SOFT_FD_LIMIT 8192
+@@ -304,14 +304,14 @@
+ 
+    /*
+     * daemonize qmaster
+-    * set filedescripto limits
+-    * and initialize librarrays to be used in multi threaded environment
++    * set file descriptor limits
++    * and initialize libraries to be used in multi threaded environment
+     * also take care that finished child processed of this process become
+     * zombie jobs
+     */
+    has_daemonized = sge_daemonize_qmaster();
+    file_descriptor_settings_result = set_file_descriptor_limit();
+-#if !defined(INTERIX)
++#if !defined(INTERIX) && !defined(CYGWIN)
+    init_sig_action_and_mask();
+ #endif
+ 
+@@ -447,7 +447,7 @@
+    return 0;
+ } /* main() */
+ 
+-#if !defined(INTERIX)
++#if !defined(INTERIX) && !defined(CYGWIN)
+ 
+ /****** qmaster/sge_qmaster_main/init_sig_action_and_mask() *******************
+ *  NAME
+diff -ruN --exclude .svn GE2011.11/source/daemons/qmaster/sge_qmaster_timed_event.c gridscheduler-trunk/source/daemons/qmaster/sge_qmaster_timed_event.c
+--- GE2011.11/source/daemons/qmaster/sge_qmaster_timed_event.c	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/daemons/qmaster/sge_qmaster_timed_event.c	2012-04-17 09:13:35.971354126 -0600
+@@ -395,7 +395,7 @@
+ 
+    SGE_ASSERT((anEvent != NULL));
+    
+-   sge_free((char*)(*anEvent)->str_key);
++   FREE((*anEvent)->str_key);
+    FREE(*anEvent);
+ 
+    DRETURN_VOID;
+@@ -873,7 +873,7 @@
+ {
+    DENTER(EVENT_LAYER, "te_shutdown");
+ 
+-   sge_free((char *)Handler_Tbl.list);
++   FREE(Handler_Tbl.list);
+ 
+    DEXIT;
+    return;
+diff -ruN --exclude .svn GE2011.11/source/daemons/qmaster/sge_qmod_qmaster.c gridscheduler-trunk/source/daemons/qmaster/sge_qmod_qmaster.c
+--- GE2011.11/source/daemons/qmaster/sge_qmod_qmaster.c	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/daemons/qmaster/sge_qmod_qmaster.c	2012-04-17 09:13:35.970354161 -0600
+@@ -1067,7 +1067,8 @@
+ 
+    MONITOR_WAIT_TIME(SGE_LOCK(LOCK_GLOBAL, LOCK_WRITE), monitor);
+ 
+-   if (queue == NULL) {
++   if (queue == NULL)
++   {
+       if (!(jep = job_list_locate(*(object_type_get_master_list(SGE_TYPE_JOB)), jobid)) || !(jatep=job_search_task(jep, NULL, jataskid)))
+       {
+          ERROR((SGE_EVENT, MSG_EVE_RESENTSIGNALTASK_UU, sge_u32c(jobid), sge_u32c(jataskid)));
+@@ -1083,7 +1084,7 @@
+       if (!(qep = cqueue_list_locate_qinstance(*(object_type_get_master_list(SGE_TYPE_CQUEUE)), queue))) {
+          ERROR((SGE_EVENT, MSG_EVE_RESENTSIGNALQ_S, queue));
+          SGE_UNLOCK(LOCK_GLOBAL, LOCK_WRITE);
+-         sge_free((char *)queue);
++         FREE(queue);
+          DEXIT;
+          return;
+       }
+@@ -1092,7 +1093,7 @@
+    }
+ 
+    SGE_UNLOCK(LOCK_GLOBAL, LOCK_WRITE);
+-   sge_free((char *)queue);
++   FREE(queue);
+ 
+    DEXIT;
+    return;
+diff -ruN --exclude .svn GE2011.11/source/daemons/qmaster/sge_sched_order.c gridscheduler-trunk/source/daemons/qmaster/sge_sched_order.c
+--- GE2011.11/source/daemons/qmaster/sge_sched_order.c	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/daemons/qmaster/sge_sched_order.c	2012-04-17 09:13:35.969354197 -0600
+@@ -177,7 +177,7 @@
+        */
+       lFreeList(&request_answer_list);
+       lFreeList(&multi_answer_list);
+-      current_state = (state_gdi_multi*)sge_free((char*)current_state);
++      FREE(current_state);
+    }
+    DRETURN(ret);
+ }
+diff -ruN --exclude .svn GE2011.11/source/daemons/qmaster/sge_sched_prepare_data.c gridscheduler-trunk/source/daemons/qmaster/sge_sched_prepare_data.c
+--- GE2011.11/source/daemons/qmaster/sge_sched_prepare_data.c	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/daemons/qmaster/sge_sched_prepare_data.c	2012-04-17 09:13:35.965354341 -0600
+@@ -402,9 +402,10 @@
+       CRITICAL((SGE_EVENT, MSG_SCHEDD_UNABLE_TO_SETUP_FILTER));
+    }
+    /* cleanup tmp data */
+-   if (tmp_what_descr != NULL) {
++   if (tmp_what_descr != NULL)
++   {
+       cull_hash_free_descr(tmp_what_descr);
+-      tmp_what_descr = (lDescr *)sge_free((char *)tmp_what_descr);
++      FREE(tmp_what_descr);
+    }
+    DRETURN_VOID;
+ }
+diff -ruN --exclude .svn GE2011.11/source/daemons/shepherd/builtin_starter.c gridscheduler-trunk/source/daemons/shepherd/builtin_starter.c
+--- GE2011.11/source/daemons/shepherd/builtin_starter.c	2011-11-14 12:00:42.000000000 -0700
++++ gridscheduler-trunk/source/daemons/shepherd/builtin_starter.c	2012-04-17 09:13:35.451372788 -0600
+@@ -121,13 +121,58 @@
+ extern char shepherd_job_dir[];
+ extern char **environ;
+ 
++#if !defined(STDIN_FILENO)
++ #define STDIN_FILENO 0
++#endif
++
++#if !defined(STDERR_FILENO)
++ #define STDERR_FILENO 2
++#endif
++
++#if !defined(_POSIX_OPEN_MAX)
++ #define _POSIX_OPEN_MAX 20
++#endif
++
++static void close_fds_from(int from)
++{
++   int i, fdmax;
++
++   shepherd_trace("closing all filedescriptors");
++   shepherd_trace("further messages are in \"error\" and \"trace\"");
++
++   fflush(stdout);
++   fflush(stderr);
++
++   /* Close all file descriptors except the ones used by tracing
++    * (for the files "trace", "error" and "exit_status") and,
++    * in interactive job case, the ones used to redirect stdin,
++    * stdout and stderr.
++    * Those files will be closed automatically in the exec() call
++    * due to the FD_CLOEXEC flag.
++    */
++
++   fdmax = sysconf(_SC_OPEN_MAX);
++   if (fdmax == -1)
++     fdmax = _POSIX_OPEN_MAX;
++
++   for (i=from; i < fdmax; i++)
++   {
++      if (!is_shepherd_trace_fd(i))
++      {
++         SGE_CLOSE(i);
++      }
++   }
++
++   foreground = 0;
++}
++
++
+ /* Copy from clients/qrsh/qrsh_starter.c 
+  * Trying to include it caused dependency problems
+  * TODO: Move it to a common file
+  * This TODO should not be neccessary any more if the command is
+  * transferred in the job object.
+  */
+-
+ static int count_command(char *command)
+ {
+    char *s = command, delimiter = '\xff';
+@@ -147,12 +192,11 @@
+ /************************************************************************
+  This is the shepherds buitin starter.
+ 
+- It is also used to start the external starter command .. 
++ It is also used to start the external starter command. 
+  ************************************************************************/
+ void son(const char *childname, char *script_file, int truncate_stderr_out)
+ {
+    int   in, out, err;          /* hold fds */
+-   int   i;
+    int   merge_stderr;
+    int   fs_stdin, fs_stdout, fs_stderr;
+    int   min_gid, min_uid;
+@@ -226,20 +270,20 @@
+    /*
+    ** login or rsh or rlogin jobs have the qlogin_starter as their job script
+    */
+-   
+-   if ( !strcasecmp(script_file, "QLOGIN") ||
+-        !strcasecmp(script_file, "QRSH")   ||
+-        !strcasecmp(script_file, "QRLOGIN"))
++
++   if (strcasecmp(script_file, "QRSH") == 0)
++      is_rsh = 1;
++   else if (strcasecmp(script_file, "QRLOGIN") == 0)
++      is_rlogin = 1;
++   else if (strcasecmp(script_file, "QLOGIN") == 0)
++      is_qlogin = 1;
++
++   if (is_rsh || is_rlogin || is_qlogin)
+    {
+       shepherd_trace("processing qlogin job");
+       is_qlogin_starter = 1;
+       is_qlogin = 1;
+ 
+-      if (!strcasecmp(script_file, "QRSH"))
+-         is_rsh = 1;
+-      else if(!strcasecmp(script_file, "QRLOGIN"))
+-         is_rlogin = 1;
+- 
+       /* must force to run the qlogin starter as root, since it needs
+          access to /dev/something */
+       if (g_new_interactive_job_support == false)
+@@ -266,7 +310,7 @@
+    pgrp = GETPGRP;
+ 
+ #ifdef SOLARIS
+-   if(!is_qlogin_starter || is_rsh)
++   if (!is_qlogin_starter || is_rsh)
+ #endif
+ #ifdef NECSX5
+    if (!is_qlogin_starter)
+@@ -322,7 +366,7 @@
+        *  job owner and then changing to the prolog user. 
+        *
+        *  Additionally it prevents that a root procedures write to
+-       *  files which may not be accessable by the job owner 
++       *  files which may not be accessible by the job owner
+        *  (e.g. /etc/passwd)
+        *
+        *  This workaround doesn't work for Interix - we have to find
+@@ -361,9 +405,11 @@
+ 
+    umask(022);
+ 
+-   if (!strcmp(childname, "job")) {
++   if (!strcmp(childname, "job"))
++   {
+       char *write_osjob_id = get_conf_val("write_osjob_id");
+-      if(write_osjob_id != NULL && atoi(write_osjob_id) != 0) {
++      if (write_osjob_id != NULL && atoi(write_osjob_id) != 0)
++      {
+          setosjobid(newpgrp, &add_grp_id, pw);
+       }   
+    }
+@@ -410,10 +456,12 @@
+                res = uidgid_read_passwd(target_user, &pass, err_str);
+                seteuid(uid);
+ 
+-               if(res == 0) {
++               if(res == 0)
++               {
+                   strlcpy(user_passwd, pass, MAX_STRING_SIZE);
+                   FREE(pass);
+-                  if (strlen(user_passwd) == 0) {
++                  if (strlen(user_passwd) == 0)
++                  {
+                      shepherd_trace("uidgid_read_passwd() returned empty password string!");
+                   }
+                } else {
+@@ -448,7 +496,8 @@
+     ** (add additional group id), switches to start user (root) 
+     **/
+     tmp_str = search_conf_val("qsub_gid");
+-    if (strcmp(tmp_str, "no")) {
++    if (strcmp(tmp_str, "no"))
++    {
+        use_qsub_gid = 1;   
+        gid = atol(tmp_str);
+     }
+@@ -459,7 +508,7 @@
+ 
+ /* --- switch to intermediate user */
+    shepherd_trace("switching to intermediate/target user");
+-   if(is_qlogin_starter && g_new_interactive_job_support == false) {
++   if (is_qlogin_starter && g_new_interactive_job_support == false) {
+       /* 
+        * In the old IJS, we didn't have to set the additional group id,
+        * because our custom rshd did it for us.
+@@ -497,38 +546,14 @@
+ 
+    shell_start_mode = get_conf_val("shell_start_mode");
+ 
+-   shepherd_trace("closing all filedescriptors");
+-   shepherd_trace("further messages are in \"error\" and \"trace\"");
+-   fflush(stdin);
+-   fflush(stdout);
+-   fflush(stderr);
+-
++   /* For batch jobs, close stdin, stdout and stderr.  Delay closing
++    * anything for new interactive jobs as we need to keep cached
++    * descriptors used by NSS modules open.
++    */
++   if (!is_qlogin_starter || !g_new_interactive_job_support)
+    {
+-		/* Close all file descriptors except the ones used by tracing
+-		 * (for the files "trace", "error" and "exit_status") and,
+-       * in interactive job case, the ones used to redirect stdin,
+-       * stdout and stderr.
+-		 * These files will be closed automatically in the exec() call
+-		 * due to the FD_CLOEXEC flag.
+-		 */
+-      int fdmax = sysconf(_SC_OPEN_MAX);
+-
+-      /* For batch jobs, also close stdin, stdout and stderr. For new
+-       * interactive jobs, keep stdin, stdout and stderr open, they are
+-       * already connected to the pty and/or the pipes.
+-       */
+-      if (g_new_interactive_job_support == true && is_qlogin_starter) {
+-         i=3;
+-      } else {
+-         i=0;
+-      }
+-      for ( ; i < fdmax; i++) {
+-         if (!is_shepherd_trace_fd(i)) {
+-         	SGE_CLOSE(i);
+-         }
+-      }
++      close_fds_from(STDIN_FILENO);
+    }
+-   foreground = 0;
+ 
+    /* We have different possiblities to start the job script:
+     * - We can start it as login shell or not
+@@ -651,7 +676,9 @@
+       }
+ 
+       if (stderr_path && strlen(stderr_path) > 0)
++      {
+          strcpy(fs_stderr_path, stderr_path);
++      }
+   
+       if (!merge_stderr)
+       {
+@@ -763,7 +790,9 @@
+    }
+ 
+    if (in != 0)
++   {
+       shepherd_error(1, "error: fd for in is not 0");
++   }
+ 
+    if (!is_qlogin_starter)
+    {
+@@ -896,7 +925,7 @@
+ #endif
+ /* ---- switch to target user */
+    if (intermediate_user) {
+-      if(is_qlogin_starter) {
++      if (is_qlogin_starter) {
+          ret = sge_set_uid_gid_addgrp(target_user, NULL, 0, 0, 0, 
+                                       err_str, use_qsub_gid, gid);
+       } else {
+@@ -985,7 +1014,7 @@
+ {
+    const char *const filename = "environment";
+    FILE *fp;
+-   char buf[10000], *name, *value;
++   char buf[10000];
+    int line=0;
+ #if defined(IRIX) || defined(CRAY) || defined(NECSX4) || defined(NECSX5)
+    char help_str[100] = "";
+@@ -999,25 +1028,27 @@
+ #endif
+ 
+    setup_environment();
+-   
++
+    if (!(fp = fopen(filename, "r")))
+       shepherd_error(1, "can't open environment file: %s", strerror(errno));
+ 
+ #if defined(IRIX) || defined(CRAY) || defined(NECSX4) || defined(NECSX5)
+-   if (shepherd_read_osjobid_file(&jobid, false)) {
+-#  if defined(IRIX)
++   if (shepherd_read_osjobid_file(&jobid, false))
++   {
++#if defined(IRIX)
+       snprintf(help_str, 100, "%lld", jobid);
+-#  elif defined(CRAY)
++#elif defined(CRAY)
+       snprintf(help_str, 100, "%d", jobid);
+-#  elif defined(NECSX4) || defined(NECSX5)
++#elif defined(NECSX4) || defined(NECSX5)
+       snprintf(help_str, 100, "%ld", jobid);
+-#  endif
++#endif
+       sge_set_env_value("OSJOBID", help_str);
+    }
+ #endif
+ 
+    while (fgets(buf, sizeof(buf), fp))
+    {
++      char *name, *value;
+       const char *new_value;
+ 
+       line++;
+@@ -1026,16 +1057,17 @@
+          continue;
+ 
+       name = strtok(buf, "=");
+-      if (!name)
++      if (name == NULL)
+       {
+          FCLOSE(fp);
+-         shepherd_error(1, "error reading environment file: line=%d, contents:%s",
+-                        line, buf);
++         shepherd_error(1, "error reading environment file: line=%d, contents:%s", line, buf);
+       }
+ 
+       value = strtok(NULL, "\n");
+       if (value == NULL)
++      {
+          value = "";
++      }
+ 
+       new_value = sge_replace_substring(value, "\\n", "\n");
+       if (new_value == NULL)
+@@ -1119,10 +1151,10 @@
+     * Because this fix could break pre-existing installations, it was made
+     * optional. */
+ 
+-   if (!inherit_env())
+-      return shepherd_env;
+-   else
++   if (inherit_env())
+       return environ;
++   else
++      return shepherd_env;
+ }
+ 
+ /****** Shepherd/sge_set_env_value() *******************************************
+@@ -1153,7 +1185,11 @@
+    /* Bugfix: Issuezilla 1300
+     * Because this fix could break pre-existing installations, it was made
+     * optional. */
+-   if (!inherit_env())
++   if (inherit_env())
++   {
++      ret = sge_setenv(name, value);
++   }
++   else
+    {
+       char *entry = NULL;
+       int entry_size = 0;
+@@ -1177,10 +1213,6 @@
+          }
+       }
+    }
+-   else
+-   {
+-      ret = sge_setenv(name, value);
+-   }
+    
+    return ret;
+ }
+@@ -1211,7 +1243,11 @@
+    /* Bugfix: Issuezilla 1300
+     * Because this fix could break pre-existing installations, it was made
+     * optional. */
+-   if (!inherit_env())
++   if (inherit_env())
++   {
++      ret = sge_getenv (name);
++   }
++   else
+    {
+       if (shepherd_env_index >= 0)
+       {
+@@ -1236,10 +1272,6 @@
+          }
+       }
+    }
+-   else
+-   {
+-      ret = sge_getenv (name);
+-   }
+    
+    return ret;
+ }
+@@ -1308,7 +1340,9 @@
+   
+    /* copy preargs */ 
+    for (i = 0; i < n_preargs; i++)
++   {
+       args[i] = strdup(preargs[i]);
++   }
+ 
+    args[i] = NULL;
+ 
+@@ -1326,6 +1360,51 @@
+    return args;
+ }
+ 
++static int check_configured_method(const char *method, const char *name, char *err_str)
++{
++   unsigned int        file_perm = S_IXOTH;
++   int                 ret = 0;
++   char                *command;
++   struct saved_vars_s *context = NULL;
++
++   /*
++    * The configured method can include some pameters, e.g.
++    * qlogin_daemon                /usr/sbin/in.telnetd -i
++    * Only the command itself must be checked.
++    */
++
++   command = sge_strtok_r(method, " ", &context);
++
++   if (strncmp(command, "/", 1) != 0)
++   {
++      sprintf(err_str, "%s \"%s\" is not an absolute path", name, command);
++      ret = -1;
++   }
++   else
++   {
++      SGE_STRUCT_STAT     statbuf;
++
++      if (SGE_STAT(command, &statbuf) != 0) {
++         sprintf(err_str, "%s \"%s\" can't be read: %s (%d)",
++            name, command, strerror(errno), errno);
++         ret = -1;
++      } else {
++         if (getuid() == statbuf.st_uid) {
++            file_perm = file_perm | S_IXUSR;
++         }
++         if (getgid() == statbuf.st_gid) {
++            file_perm = file_perm | S_IXGRP;
++         }
++         if ((statbuf.st_mode & file_perm) == 0) {
++            sprintf(err_str, "%s \"%s\" is not executable", name, command);
++            ret = -1;
++         }
++      }
++   }
++
++   sge_free_saved_vars(context);
++   return ret;
++}
+ 
+ /*--------------------------------------------------------------------
+  * set_shepherd_signal_mask
+@@ -1504,8 +1583,7 @@
+       }
+       pre_args_ptr[1] = get_conf_val(conf_name);
+ 
+-      if (check_configured_method(pre_args_ptr[1], conf_name, err_str) != 0
+-          && g_new_interactive_job_support == false)
++      if (g_new_interactive_job_support == false && check_configured_method(pre_args_ptr[1], conf_name, err_str) != 0)
+       {
+          shepherd_state = SSTATE_CHECK_DAEMON_CONFIG;
+          shepherd_error(1, err_str);
+@@ -1589,10 +1667,10 @@
+       else
+       {
+          /* g_new_interactive_job_support == true */
+-         if (is_rsh == false)                /* qlogin, qrsh (without command) */
+-            start_qlogin_job(shell_path);
+-         else                                /* qrsh <command> */
+-            start_qrsh_job();
++         if (is_rsh)
++            start_qrsh_job();               /* qrsh <command> */
++         else
++            start_qlogin_job(shell_path);   /* qlogin, qrsh (without command) */
+       }
+    }
+    else
+@@ -1721,7 +1799,11 @@
+ #if defined(INTERIX)
+          shepherd_trace("not a GUI job, starting directly");
+ #endif
+-         if (!inherit_env())
++         if (inherit_env())
++         {
++            execvp(filename, args);
++         }
++         else
+          {
+             /* The closest thing to execvp that takes an environment pointer is
+              * execve.  The problem is that execve does not resolve the path.
+@@ -1733,10 +1815,6 @@
+             execvp(filename, args);
+             environ = tmp;
+          }
+-         else
+-         {
+-            execvp(filename, args);
+-         }
+ 
+          /* Aaaah - execvp() failed */
+          {
+@@ -1753,54 +1831,8 @@
+    }
+ }
+ 
+-int check_configured_method(
+-const char *method,
+-const char *name,
+-char *err_str
+-) {
+-   SGE_STRUCT_STAT     statbuf;
+-   unsigned int        file_perm = S_IXOTH;
+-   int                 ret = 0;
+-   char                *command;
+-   struct saved_vars_s *context = NULL;
+-
+-   /*
+-    * The configured method can include some pameters, e.g.
+-    * qlogin_daemon                /usr/sbin/in.telnetd -i
+-    * Only the command itself must be checked.
+-    */
+-
+-   command = sge_strtok_r(method, " ", &context);
+-
+-   if (strncmp(command, "/", 1) != 0) {
+-      sprintf(err_str, "%s \"%s\" is not an absolute path", name, command);
+-      ret = -1;
+-   } else {
+-      if (SGE_STAT(command, &statbuf) != 0) {
+-         sprintf(err_str, "%s \"%s\" can't be read: %s (%d)",
+-            name, command, strerror(errno), errno);
+-         ret = -1;
+-      } else {
+-         if (getuid() == statbuf.st_uid) {
+-            file_perm = file_perm | S_IXUSR;
+-         }
+-         if (getgid() == statbuf.st_gid) {
+-            file_perm = file_perm | S_IXGRP;
+-         }
+-         if ((statbuf.st_mode & file_perm) == 0) {
+-            sprintf(err_str, "%s \"%s\" is not executable", name, command);
+-            ret = -1;
+-         }
+-      }
+-   }
+-
+-   sge_free_saved_vars(context);
+-   return ret;
+-}
+-
+-static char *build_path(
+-int type 
+-) {
++static char *build_path(int type)
++{
+    SGE_STRUCT_STAT statbuf;
+    char *path, *base;
+    char *postfix, *name, *job_id, *job_name, *ja_task_id;
+@@ -1835,7 +1867,8 @@
+    base = get_conf_val(name);
+ 
+    /* Try to get information about 'base' */
+-   if( SGE_STAT(base, &statbuf)) {
++   if (SGE_STAT(base, &statbuf))
++   {
+       /* An error occured */
+       if (errno != ENOENT) {
+          char *t;
+@@ -1911,8 +1944,7 @@
+ *     char* - If one is given, the name of the user.
+ *             Else NULL.
+ *******************************************************************************/
+-static char*
+-parse_script_params(char **script_file) 
++static char *parse_script_params(char **script_file) 
+ {
+    char* target_user = NULL;
+    char* s;
+@@ -1947,23 +1979,22 @@
+ *******************************************************************************/
+ static bool inherit_env()
+ {
+-   if (inherit_environ == -1) {
++   if (inherit_environ == -1)
++   {
+       /* We have to use search_conf_val() instead of get_conf_val() because this
+        * change is happening in a patch, and we can't break backward
+        * compatibility.  In a later release, this should probably be changed to
+        * use get_conf_val() instead. */
+       char *inherit = search_conf_val("inherit_env");
+       
+-      if (inherit != NULL) {
++      if (inherit != NULL)
+          inherit_environ = (strcmp(inherit, "1") == 0);
+-      }
+-      else {
++      else
+          /* This should match the default set in sgeobj/sge_conf.c. */
+          inherit_environ = true;
+-      }
+    }
+    
+-   return (inherit_environ == 1) ? true : false;
++   return (inherit_environ == 1);
+ }
+ 
+ #if 0 /* Not currently used, but looks kinda useful... */
+@@ -2075,13 +2106,18 @@
+       my_env[i++] = strncat(hertz, getenv("HZ"), 10);
+ 
+ 
+-#if defined(LINUX) || defined(DARWIN_PPC) || defined(DARWIN_X86)
++#if defined(LINUX) || defined(DARWIN)
+    my_env[i++] = strcat(path, "/bin:/usr/bin");
+ #else
+    my_env[i++] = strcat(path, "/usr/bin");
+ #endif
+    my_env[i] = NULL;
+ 
++   /* Keep stdin, stdout and stderr open, they are already connected to
++    * the pty and/or the pipes.
++    */
++   close_fds_from(STDERR_FILENO+1);
++
+    shepherd_trace("execle(%s, %s, NULL, env)", shell_path, minusname);
+    execle(shell_path, minusname, NULL, my_env);
+ }
+@@ -2133,7 +2169,7 @@
+       arch = sge_get_arch();
+ 
+       if (sge_root == NULL || arch == NULL) {
+-         shepherd_trace("reading environment SGE_ROOT and ARC failed");
++         shepherd_trace("reading environment SGE_ROOT and ARCH failed");
+          return;
+       }
+ 
+@@ -2157,6 +2193,11 @@
+    for (i=0; args[i] != NULL; i++)
+       shepherd_trace("args[%d] = \"%s\"", i, args[i]);
+ 
++   /* Keep stdin, stdout and stderr open, they are already connected to
++    * the pty and/or the pipes.
++    */
++   close_fds_from(STDERR_FILENO+1);
++
+    shepherd_trace("execvp(%s, ...);", args[0]);
+    execvp(args[0], args);
+ }
+diff -ruN --exclude .svn GE2011.11/source/daemons/shepherd/builtin_starter.h gridscheduler-trunk/source/daemons/shepherd/builtin_starter.h
+--- GE2011.11/source/daemons/shepherd/builtin_starter.h	2011-11-14 12:00:42.000000000 -0700
++++ gridscheduler-trunk/source/daemons/shepherd/builtin_starter.h	2012-04-17 09:13:35.452372752 -0600
+@@ -35,10 +35,9 @@
+ 
+ void son(const char *childname, char *script_file, int truncate_stderr_out);
+ int sge_set_environment(void);
+-char** sge_get_environment(void);
++char **sge_get_environment(void);
+ int sge_set_env_value(const char *, const char *);
+ const char *sge_get_env_value(const char *);
+ void start_command(const char *, char *, char *, char *, char *, int, int, int, int, char *, int);
+-int check_configured_method(const char *method, const char *name, char *err_str);
+ 
+ #endif /* __BUILTIN_STARTER_H */
+diff -ruN --exclude .svn GE2011.11/source/daemons/shepherd/shepherd.c gridscheduler-trunk/source/daemons/shepherd/shepherd.c
+--- GE2011.11/source/daemons/shepherd/shepherd.c	2011-11-14 12:00:42.000000000 -0700
++++ gridscheduler-trunk/source/daemons/shepherd/shepherd.c	2012-04-17 09:13:35.442373112 -0600
+@@ -2745,7 +2745,7 @@
+ 
+ /*-------------------------------------------------------------------------
+  * set_ckpt_params
+- * may not called befor "job_pid" is known and set in the configuration
++ * may not call before "job_pid" is known and set in the configuration
+  * don't do anything for non ckpt jobs except setting ckpt_interval = 0
+  *-------------------------------------------------------------------------*/
+ static void set_ckpt_params(int ckpt_type, char *ckpt_command, int ckpt_len,
+diff -ruN --exclude .svn GE2011.11/source/dist/inst_sge gridscheduler-trunk/source/dist/inst_sge
+--- GE2011.11/source/dist/inst_sge	2011-11-14 12:00:55.000000000 -0700
++++ gridscheduler-trunk/source/dist/inst_sge	2012-03-21 09:25:09.774946197 -0600
+@@ -32,6 +32,8 @@
+ #
+ #  All Rights Reserved.
+ #
++#  Copyright: 2012 by Open Grid Scheduler
++#
+ ##########################################################################
+ #___INFO__MARK_END__
+ #
+@@ -123,7 +125,6 @@
+ 
+ BasicSettings
+ SetUpInfoText
+-PreInstallCheck
+ 
+ 
+ ARGC=$#
+@@ -142,7 +143,8 @@
+      if [ ! -f "$2" ]; then
+         AUTO="false"
+         $INFOTEXT "Error: File $FILE does not exist!" 
+-        ErrUsage        
++        ErrUsage
++        exit 2
+      fi
+      shift
+      ARGC=`expr $ARGC - 1`
+@@ -155,6 +157,7 @@
+       ;;
+    -m)
+      QMASTER="install"
++     PreInstallCheck
+      . ./util/install_modules/inst_qmaster.sh
+      . ./util/install_modules/inst_berkeley.sh
+      . ./util/install_modules/inst_st.sh
+@@ -166,6 +169,7 @@
+      ;; 
+    -x)
+      EXECD="install"
++     PreInstallCheck
+      . ./util/install_modules/inst_execd.sh
+      if [ "$2" = "-upd" ]; then
+          UPDATE="true"
+@@ -186,6 +190,7 @@
+      ;;
+    -sm)
+      SHADOW="install"
++     PreInstallCheck
+      . ./util/install_modules/inst_qmaster.sh
+      . ./util/install_modules/inst_execd.sh
+      #echo Install Shadowhost
+@@ -233,6 +238,7 @@
+      #update from 6.0 or higher to 6.2
+      UPDATE=true
+      QMASTER="install"
++     PreInstallCheck
+      . ./util/install_modules/inst_qmaster.sh
+      . ./util/install_modules/inst_berkeley.sh
+      . ./util/install_modules/inst_st.sh
+@@ -274,6 +280,7 @@
+    -winsvc)
+      #install the windows helper service only
+      WIN_SVC="install"
++     PreInstallCheck
+      . ./util/install_modules/inst_common.sh
+      . ./util/install_modules/inst_execd.sh
+      ;;
+@@ -1086,7 +1093,7 @@
+       AddSubmitHostsExecd
+       AddSGEStartUpScript $euid execd
+       SetupWinSvc execinst     #service install during execd installation -> param: execinst
+-      CopyIBMLoadSensor
++      # CopyIBMLoadSensor
+       StartExecd
+       AddQueue
+       GiveHints
+@@ -1122,7 +1129,7 @@
+       AddLocalConfiguration_With_Qconf
+       AddSGEStartUpScript $euid execd
+       SetupWinSvc execinst  #service install during execd installation -> param: execinst
+-      CopyIBMLoadSensor
++      # CopyIBMLoadSensor
+       StartExecd
+       AddQueue
+       GiveHints
+diff -ruN --exclude .svn GE2011.11/source/dist/util/arch gridscheduler-trunk/source/dist/util/arch
+--- GE2011.11/source/dist/util/arch	2011-11-14 12:00:55.000000000 -0700
++++ gridscheduler-trunk/source/dist/util/arch	2012-02-08 09:46:04.971012943 -0700
+@@ -100,10 +100,31 @@
+       ARCH=craysmp
+    fi
+    ;;
++CYGWIN*)
++   ARCH=cygwin-x86
++   ;;
+ Darwin)
+    case $osmachine in
+       i386)
+-         darwin_machine=x86
++         case $osrelease in
++            8.*)
++               darwin_machine=x86
++               ;;
++            9.*|10.*)
++               cpuarch=`sysctl -n hw.cpu64bit_capable 2> /dev/null`
++               if [ "$cpuarch" = "0" ]; then
++                  darwin_machine=x86
++               else
++                  darwin_machine=x64
++               fi
++               ;;
++            *)
++               darwin_machine=x64
++               ;;
++            esac
++         ;;
++      x86_64)
++         darwin_machine=x64
+          ;;
+       Power*)
+          darwin_machine=ppc
+@@ -353,7 +374,7 @@
+       DEFAULTMANPATH=/usr/share/catman:/usr/share/man:/usr/catman:/usr/man
+       MANTYPE=catman
+       ;;
+-   lx*)
++   linux*)
+       if [ "`which manpath 2>/dev/null`" != "" ]; then
+          DEFAULTMANPATH=`manpath 2>/dev/null`
+       else
+diff -ruN --exclude .svn GE2011.11/source/dist/util/arch.dist gridscheduler-trunk/source/dist/util/arch.dist
+--- GE2011.11/source/dist/util/arch.dist	2011-11-14 12:00:55.000000000 -0700
++++ gridscheduler-trunk/source/dist/util/arch.dist	1969-12-31 17:00:00.000000000 -0700
+@@ -1,431 +0,0 @@
+-#!/bin/sh
+-#
+-#  arch
+-#
+-#___INFO__MARK_BEGIN__
+-##########################################################################
+-#
+-#  The Contents of this file are made available subject to the terms of
+-#  the Sun Industry Standards Source License Version 1.2
+-#
+-#  Sun Microsystems Inc., March, 2001
+-#
+-#
+-#  Sun Industry Standards Source License Version 1.2
+-#  =================================================
+-#  The contents of this file are subject to the Sun Industry Standards
+-#  Source License Version 1.2 (the "License"); You may not use this file
+-#  except in compliance with the License. You may obtain a copy of the
+-#  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
+-#
+-#  Software provided under this License is provided on an "AS IS" basis,
+-#  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+-#  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+-#  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+-#  See the License for the specific provisions governing your rights and
+-#  obligations concerning the Software.
+-#
+-#  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+-#
+-#  Copyright: 2001 by Sun Microsystems, Inc.
+-#
+-#  All Rights Reserved.
+-#
+-##########################################################################
+-#___INFO__MARK_END__
+-#
+-#  The original idea of "aimk" where this script is based on came from the
+-#  PVM 3.x distribution, 22 Jul 1991 Robert Manchek manchek at CS.UTK.EDU. 
+-#
+-#  call:   arch       (print SGEEE architecture string)
+-#          arch -m    (print default MANPATH of system)
+-#          arch -mt   (print either "man" or "catman")
+-#          arch -lib  (print name of variable to extend shared library path)
+-
+-# On some architectures, it is necessary to run the manpath(1) command
+-# with the user's path instead of our "safe" one.  Thus we need to
+-# save the old value of PATH for later restoration.
+-#
+-SAFE_PATH=/bin:/usr/bin:/usr/sbin
+-OLD_PATH=$PATH
+-PATH=$SAFE_PATH
+-
+-ARCH=UNKNOWN
+-
+-if [ -x /bin/uname ]; then
+-   UNAME=/bin/uname
+-elif [ -x /usr/bin/uname ]; then
+-   UNAME=/usr/bin/uname
+-else
+-   echo ERROR: \"uname\" command not found
+-   exit 1
+-fi
+-
+-ossysname="`$UNAME -s`"
+-osmachine="`$UNAME -m`"
+-osrelease="`$UNAME -r`"
+-
+-case $ossysname in
+-AIX)
+-   osversion=`$UNAME -v`
+-   case $osversion in
+-   3)
+-      ARCH=UNSUPPORTED-rs6000
+-      ;;
+-   4)
+-      case $osrelease in
+-      1)
+-         ARCH=UNSUPPORTED-aix41
+-         ;;
+-      2)
+-         ARCH=UNSUPPORTED-aix42
+-         ;;
+-      3)
+-         ARCH=aix43
+-         ;;
+-      esac
+-      ;;
+-   5)
+-      case $osrelease in
+-      1|2|3)
+-         ARCH=aix51
+-         ;;
+-      *)
+-         ARCH=UNSUPPORTED-aix-5-$osrelease
+-         ;;
+-      esac
+-      ;;
+-   esac
+-   ;;
+-CRSOS)
+-   if [ $osmachine = smp ]; then
+-      ARCH=craysmp
+-   fi
+-   ;;
+-Darwin)
+-   case $osmachine in
+-      i386)
+-         darwin_machine=x86
+-         ;;
+-      Power*)
+-         darwin_machine=ppc
+-         ;;
+-      *)
+-         darwin_machine=unsupported
+-         ;;
+-   esac
+-   ARCH=darwin-$darwin_machine
+-   ;;
+-FreeBSD|DragonFly)
+-   ARCH=fbsd-$osmachine
+-   ;;
+-NetBSD)
+-    osprocessor="`$UNAME -p`"
+-    ARCH=nbsd-$osprocessor
+-    ;;
+-IRIX*)
+-   case $osrelease in
+-   4*)
+-      ARCH=UNSUPPORTED-irix4
+-      ;;
+-   5*)
+-      ARCH=UNSUPPORTED-irix5
+-      ;;
+-   6.5)
+-      ARCH=irix65
+-      ;;
+-   6.*)
+-      ARCH=UNSUPPORTED-irix-$osrelease
+-      ;;
+-   esac
+-   ;;
+-HP-UX)
+-   case $osmachine in
+-   ia64)
+-      ARCH=hp11
+-      ;;
+-   9000/*)
+-      case $osrelease in
+-      *.09.*)
+-         ARCH=UNSUPPORTED-hp
+-         ;;
+-      *.10.10)
+-         ARCH=UNSUPPORTED-hp1010
+-         ;;
+-      *.10.*)
+-         ARCH=hp10
+-         ;;
+-      *.11.*)
+-      if [ -x /usr/bin/getconf ]; then
+-         bits="`/usr/bin/getconf KERNEL_BITS`"
+-         if [ $bits -eq 64 ]; then
+-            ARCH=hp11-64
+-         else
+-            ARCH=hp11
+-         fi
+-      else
+-         ARCH=hp11
+-      fi
+-      ;;
+-      esac
+-   esac
+-   ;;
+-Linux)
+-   unsupported=""
+-
+-   case $osmachine in
+-   i*86)
+-      lxmachine=x86
+-      ;;
+-   alpha)
+-      lxmachine=alpha
+-      ;;
+-   sparc)
+-      lxmachine=sparc
+-      ;;
+-   sparc64)
+-      lxmachine=sparc
+-      ;;
+-   x86_64)
+-      lxmachine=amd64
+-      ;;
+-   ia64)
+-      lxmachine=ia64
+-      ;;
+-   ppc)
+-      lxmachine=ppc
+-      ;;
+-   ppc64)
+-      lxmachine=ppc64
+-      ;;
+-   mips)
+-      lxmachine=mips
+-      ;;
+-   mips64)
+-      lxmachine=mips64
+-      ;;
+-   s390)
+-      lxmachine=s390
+-      ;;
+-   s390x)
+-      lxmachine=s390x
+-      ;;
+-   *)
+-      unsupported="UNSUPPORTED-"
+-      lxmachine=$osmachine
+-   esac
+-
+-   case $osrelease in
+-   2.[46].*)
+-      # retrieve os release. We use 2.4 on kernel 2.6 machines, unless
+-      # we have binaries installed that have been built for 2.6
+-      case $osrelease in
+-      2.4.*) 
+-         lxrelease=24
+-         ;;
+-      2.6.*) 
+-         ROOT_DIR=`dirname $0`/..
+-         if [ "$SGE_ROOT" != "" -a -d "$SGE_ROOT/bin/lx26-${lxmachine}" ] ; then
+-            lxrelease=26
+-         elif [ "$SGE_ROOT" = "" -a -d "$ROOT_DIR/bin/lx26-${lxmachine}" ] ; then
+-            lxrelease=26
+-         else
+-            lxrelease=24
+-         fi
+-         ;;
+-      esac
+-
+-      # verify the GNU C lib version
+-      # For an alternative means to determine GNU C lib version see
+-      # http://www.gnu.org/software/libc/FAQ.html#s-4.9
+-      case $lxmachine in
+-      amd64)
+-         libc_string=`strings /lib64/libc.so.6 | grep "GNU C Library"`
+-         ;;
+-      ia64)
+-         libc_string=`strings /lib/libc.so.6.1 | grep "GNU C Library"`
+-         ;;
+-      *)
+-         libc_string=`strings /lib/libc.so.6 | grep "GNU C Library"`
+-         ;;
+-      esac
+-
+-      # retrieving libc version failed
+-      if [ $? -ne 0 ]; then
+-         unsupported="UNSUPPORTED-"
+-         lxrelease="${lxrelease}-GLIBC"
+-      else
+-         libc_version=`echo $libc_string | tr ' ,' '\n' | grep "2\." | cut -f 2 -d "."`
+-         if [ $libc_version -lt 2 ]; then
+-            unsupported="UNSUPPORTED-"
+-            lxrelease=24-GLIBC-2.${libc_version}
+-         else
+-            if [ $libc_version -eq 2 ]; then
+-               unsupported="u"
+-            fi
+-         fi
+-      fi
+-      ;;
+-   *)
+-      unsupported="UNSUPPORTED-"
+-      lxrelease=$osrelease
+-   esac
+-   ARCH=${unsupported}lx${lxrelease}-${lxmachine}
+-   ;;
+-OSF1)
+-   case $osrelease in
+-   V4*)
+-      ARCH=osf4
+-      ;;
+-    V5*|T5*)
+-       ARCH=tru64
+-       ;;
+-    *)
+-       ARCH=UNSUPPORTED-osf1-$osrelease
+-       ;;
+-    esac
+-    ;;
+-SunOS)
+-   case $osmachine in
+-   sun4)
+-      ARCH=UNSUPPORTED-sun4
+-      ;;
+-   i86*)
+-      ARCH=sol-x86
+-      case $osrelease in
+-      5.[8]*)
+-         ARCH=usol-x86
+-         ;;
+-      5.[91]*)
+-         if [ `isainfo -b` = 64 ]; then
+-            ARCH=sol-amd64
+-         else
+-            ARCH=sol-x86
+-         fi
+-         ;;
+-      *)
+-         ARCH=UNSUPPORTED-SunOS-$osrelease
+-         ;;
+-      esac
+-      ;;
+-   *)
+-      case $osrelease in
+-      5.[7]*)
+-         if [ `isainfo -b` = 64 ]; then
+-            ARCH=usol-sparc64
+-         else
+-            ARCH=usol-sparc
+-         fi
+-         ;;
+-      5.[891]*)
+-         if [ `isainfo -b` = 64 ]; then
+-            ARCH=sol-sparc64
+-         else
+-            ARCH=sol-sparc
+-         fi
+-         ;;
+-      *)
+-         ARCH=UNSUPPORTED-SunOS-$osrelease
+-         ;;
+-      esac
+-      ;;
+-   esac
+-   ;;
+-SUPER-UX)
+-   case $osmachine in
+-   SX-4*)
+-      ARCH=UNSUPPORTED-necsx4
+-      ;;
+-   SX-[56]*)
+-      ARCH=sx
+-      ;;
+-   *)
+-      ARCH=UNSUPPORTED-SUPER-UX-$osmachine
+-      ;;
+-   esac
+-   ;;
+-Interix)
+-   ARCH=win32-x86
+-   ;;
+-*)
+-   if [ -f /unicos ]; then
+-      if [ "`$UNAME -m`" = "CRAY TS" ]; then
+-         if [ `/bin/target|/bin/grep ieee` = noieee ]; then
+-            ARCH=crayts
+-         else
+-            ARCH=craytsieee
+-         fi
+-      else
+-         ARCH=cray
+-      fi
+-   else
+-      ARCH=UNSUPPORTED-${ossysname}-${osmachine}-${osrelease}
+-   fi
+-   ;;
+-esac
+-
+-if [ "$1" = "-m" -o "$1" = "-mt" -o "$1" = "-lib" ]; then
+-   MANTYPE=man
+-   SHARED_LIBRARY_PATH="LD_LIBRARY_PATH"
+-   DEFAULTMANPATH=/usr/man
+-   case $ARCH in
+-   aix*)
+-      DEFAULTMANPATH=/usr/man
+-      SHARED_LIBRARY_PATH="LIBPATH"
+-      ;;
+-   darwin-*)
+-      DEFAULTMANPATH=`/usr/bin/manpath -q`
+-      SHARED_LIBRARY_PATH="DYLD_LIBRARY_PATH"
+-      ;;
+-   fbsd-*)
+-      PATH=$OLD_PATH
+-      DEFAULTMANPATH=`/usr/bin/manpath -q`
+-      PATH=$SAFE_PATH
+-      ;;
+-   nbsd-*)
+-      PATH=$OLD_PATH
+-      DEFAULTMANPATH=/usr/pkg/man:/usr/local/man:/usr/X11R6/man:/usr/share/man
+-      PATH=$SAFE_PATH
+-      ;;
+-   hp*)
+-      DEFAULTMANPATH=/usr/man:/usr/contrib/man:/usr/local/man
+-      SHARED_LIBRARY_PATH="SHLIB_PATH"
+-      ;;
+-   irix65)
+-      DEFAULTMANPATH=/usr/share/catman:/usr/share/man:/usr/catman:/usr/man
+-      MANTYPE=catman
+-      ;;
+-   lx*)
+-      if [ "`which manpath 2>/dev/null`" != "" ]; then
+-         DEFAULTMANPATH=`manpath 2>/dev/null`
+-      else
+-         DEFAULTMANPATH=/usr/local/man:/usr/share/man:/usr/man:/usr/X11R6/man
+-      fi
+-      ;;
+-   sol-*)
+-      DEFAULTMANPATH=/usr/share/man
+-      # if bit-specific variable already set, use this variable!
+-      SHARED_LIBRARY_PATH_BITS="LD_LIBRARY_PATH_`isainfo -b`"
+-      if eval [ x\$$SHARED_LIBRARY_PATH_BITS != x ]; then
+-	      SHARED_LIBRARY_PATH=$SHARED_LIBRARY_PATH_BITS
+-      fi
+-      ;;
+-   tru64)
+-      DEFAULTMANPATH=/usr/share/man:/usr/dt/share/man:/usr/local/man
+-      ;;
+-   win32*)
+-      DEFAULTMANPATH=/usr/share/man
+-      MANTYPE=catman/cat
+-      ;;
+-   esac
+-
+-   if [ "$1" = "-m" ]; then
+-      echo $DEFAULTMANPATH
+-   elif [ "$1" = "-lib" ]; then
+-      echo $SHARED_LIBRARY_PATH
+-   else
+-      echo $MANTYPE
+-   fi
+-else
+-   echo $ARCH
+-fi
+diff -ruN --exclude .svn GE2011.11/source/dist/util/bdb_checkpoint.sh gridscheduler-trunk/source/dist/util/bdb_checkpoint.sh
+--- GE2011.11/source/dist/util/bdb_checkpoint.sh	2011-11-14 12:00:55.000000000 -0700
++++ gridscheduler-trunk/source/dist/util/bdb_checkpoint.sh	2012-03-21 09:25:09.751947016 -0600
+@@ -78,8 +78,11 @@
+ # source settings, we need LD_LIBRARY_PATH/LIBPATH/SHLIB_PATH
+ . ${SGE_ROOT}/${SGE_CELL}/common/settings.sh
+ 
++# set PATH
++PATH=${SGE_ROOT}/utilbin/${SGE_ARCH}:$PATH
++
+ # checkpoint transaction log
+-result=`${SGE_ROOT}/utilbin/${SGE_ARCH}/db_checkpoint -1 -h ${BDB_HOME} 2>&1`
++result=`db_checkpoint -1 -h ${BDB_HOME} 2>&1`
+ if [ $? -ne 0 ]; then
+    echo "error checkpointing transaction log:" >&2
+    echo $result >&2
+@@ -87,7 +90,7 @@
+ fi
+ 
+ # retrieve no longer needed transaction logs
+-logs=`${SGE_ROOT}/utilbin/${SGE_ARCH}/db_archive -h ${BDB_HOME} 2>&1`
++logs=`db_archive -h ${BDB_HOME} 2>&1`
+ if [ $? -ne 0 ]; then
+    echo "error retrieving outdated transaction logs:" >&2
+    echo $logs >&2
+diff -ruN --exclude .svn GE2011.11/source/dist/util/install_modules/inst_common.sh gridscheduler-trunk/source/dist/util/install_modules/inst_common.sh
+--- GE2011.11/source/dist/util/install_modules/inst_common.sh	2011-11-14 12:00:55.000000000 -0700
++++ gridscheduler-trunk/source/dist/util/install_modules/inst_common.sh	2012-03-21 09:25:09.686949330 -0600
+@@ -33,6 +33,8 @@
+ #
+ #  All Rights Reserved.
+ #
++#  Copyright: 2012 by Open Grid Scheduler
++#
+ ##########################################################################
+ #___INFO__MARK_END__
+ 
+@@ -369,16 +371,11 @@
+ #
+ CheckBinaries()
+ {
+-
+-   BINFILES="sge_coshepherd \
+-             sge_execd sge_qmaster  \
+-             sge_shadowd \
+-             sge_shepherd qacct qalter qconf qdel qhold \
+-             qhost qlogin qmake qmod qmon qresub qrls qrsh qselect qsh \
++   BINFILES="qacct qalter qconf qdel qhold \
++             qhost qlogin qmake qmod qresub qrls qrsh qselect qsh \
+              qstat qsub qtcsh qping qquota sgepasswd"
+ 
+-   WINBINFILES="sge_coshepherd sge_execd sge_shepherd  \
+-                qacct qalter qconf qdel qhold qhost qlogin \
++   WINBINFILES="qacct qalter qconf qdel qhold qhost qlogin \
+                 qmake qmod qresub qrls qrsh qselect qsh \
+                 qstat qsub qtcsh qping qquota qloadsensor.exe"
+ 
+@@ -400,6 +397,18 @@
+       UTILFILES="$WINUTILFILES"
+    fi
+ 
++   if [ "$EXECD" = "install" ]; then
++      BINFILES="$BINFILES sge_execd sge_shepherd sge_coshepherd"
++   fi
++
++   if [ "$QMASTER" = "install" ]; then
++      BINFILES="$BINFILES sge_qmaster"
++   fi
++
++   if [ "$SHADOW" = "install" ]; then
++      BINFILES="$BINFILES sge_shadowd"
++   fi
++
+    missing=false
+    for f in $BINFILES; do
+       if [ ! -f $SGE_BIN/$f ]; then
+@@ -1983,7 +1992,7 @@
+    fi
+    
+    #MacOS overwrites the files (all services share single file)
+-   if [ "$ARCH" = darwin -o "$ARCH" = darwin-ppc -o "$ARCH" = darwin-x86 ]; then
++   if [ "$ARCH" = darwin -o "$ARCH" = darwin-ppc -o "$ARCH" = darwin-x86 -o "$ARCH" = darwin-x64 ]; then
+       return
+    fi
+     
+diff -ruN --exclude .svn GE2011.11/source/dist/util/install_modules/inst_qmaster.sh gridscheduler-trunk/source/dist/util/install_modules/inst_qmaster.sh
+--- GE2011.11/source/dist/util/install_modules/inst_qmaster.sh	2011-11-14 12:00:55.000000000 -0700
++++ gridscheduler-trunk/source/dist/util/install_modules/inst_qmaster.sh	2012-02-08 09:46:04.743020797 -0700
+@@ -1978,25 +1978,25 @@
+ GetDefaultJavaForPlatform()
+ {
+    case $SGE_ARCH in
+-      sol-sparc64) 
++      sol-sparc64)
+          java_homes="/usr/java
+ /usr/jdk/latest"
+          ;;
+-      sol-amd64)   
++      sol-amd64)
+          java_homes="/usr/java
+ /usr/jdk/latest"
+          ;;
+-      sol-x86)     
++      sol-x86)
+          java_homes="/usr/java
+ /usr/jdk/latest"
+          ;;
+-      linux-x64)   
++      linux-x64)
+          java_homes="/usr/java
+ /usr/jdk/latest
+ /usr/java/latest
+ /etc/alternatives/jre"
+          ;;
+-      linux-x86)     
++      linux-x86)
+          java_homes="/usr/java
+ /usr/jdk/latest
+ /usr/java/latest
+@@ -2006,7 +2006,11 @@
+          java_homes="/Library/Java/Home
+ /System/Library/Frameworks/JavaVM.framework/Home"
+          ;;
+-      darwin-x86)  
++      darwin-x86)
++         java_homes="/Library/Java/Home
++/System/Library/Frameworks/JavaVM.framework/Home"
++         ;;
++      darwin-x64)
+          java_homes="/Library/Java/Home
+ /System/Library/Frameworks/JavaVM.framework/Home"
+          ;;
+@@ -2126,6 +2130,9 @@
+       darwin-x86)  
+          suffix=../Libraries/libjvm.dylib
+          ;;
++      darwin-x64)
++         suffix=../Libraries/libjvm.dylib
++         ;;
+    #TODO: Missing HP, AIX platforms
+    esac
+    if [ -f $java_home/$suffix ]; then
+diff -ruN --exclude .svn GE2011.11/source/libs/comm/cl_ssl_framework.c gridscheduler-trunk/source/libs/comm/cl_ssl_framework.c
+--- GE2011.11/source/libs/comm/cl_ssl_framework.c	2011-11-14 12:00:45.000000000 -0700
++++ gridscheduler-trunk/source/libs/comm/cl_ssl_framework.c	2012-03-21 09:25:09.424958655 -0600
+@@ -97,10 +97,18 @@
+ #include "sge_os.h"
+ 
+ #if (OPENSSL_VERSION_NUMBER < 0x0090700fL) 
+-#define OPENSSL_CONST
+-#define NID_userId NID_uniqueIdentifier
++ #define OPENSSL_CONST
++ #define NID_userId NID_uniqueIdentifier
+ #else
+-#define OPENSSL_CONST const
++ #define OPENSSL_CONST const
++#endif
++
++/* ugly workaround for extremely ugly usage of OpenSSL API */
++#if (OPENSSL_VERSION_NUMBER >= 0x10000000L)
++ #define STACK       _STACK
++ #define SKVAL_RET_T char*
++#else
++ #define SKVAL_RET_T void*
+ #endif
+ 
+ 
+@@ -236,7 +244,7 @@
+ static void*                (*cl_com_ssl_func__SSL_CTX_get_ex_data)                 (SSL_CTX *ssl,int idx);
+ static int                  (*cl_com_ssl_func__SSL_CTX_set_ex_data)                 (SSL_CTX *ssl,int idx,void *data);
+ static int                  (*cl_com_ssl_func__sk_num)                              (const STACK *);
+-static char*                (*cl_com_ssl_func__sk_value)                            (const STACK *, int);
++static SKVAL_RET_T          (*cl_com_ssl_func__sk_value)                            (const STACK *, int);
+ static int                  (*cl_com_ssl_func__X509_STORE_get_by_subject)           (X509_STORE_CTX *vs,int type,X509_NAME *name, X509_OBJECT *ret);
+ static void                 (*cl_com_ssl_func__EVP_PKEY_free)                       (EVP_PKEY *pkey);
+ static void                 (*cl_com_ssl_func__X509_STORE_CTX_set_error)            (X509_STORE_CTX *ctx,int s);
+@@ -1707,7 +1715,7 @@
+       }
+ 
+       func_name = "sk_value";
+-      cl_com_ssl_func__sk_value = (char* (*)(const STACK *, int))dlsym(cl_com_ssl_crypto_handle, func_name);
++      cl_com_ssl_func__sk_value = (SKVAL_RET_T (*)(const STACK *, int))dlsym(cl_com_ssl_crypto_handle, func_name);
+       if (cl_com_ssl_func__sk_value == NULL) {
+          CL_LOG_STR(CL_LOG_ERROR,"dlsym error: can't get function address:", func_name);
+          had_errors++;
+diff -ruN --exclude .svn GE2011.11/source/libs/cull/cull_state.c gridscheduler-trunk/source/libs/cull/cull_state.c
+--- GE2011.11/source/libs/cull/cull_state.c	2011-11-14 12:00:46.000000000 -0700
++++ gridscheduler-trunk/source/libs/cull/cull_state.c	2012-04-17 09:13:36.352340452 -0600
+@@ -220,7 +220,7 @@
+ *******************************************************************************/
+ static void cull_state_destroy(void* theState)
+ {
+-   sge_free((char*)theState);
++   FREE(theState);
+ }
+ 
+ /****** cull_state/cull_state_getspecific() ************************************
+diff -ruN --exclude .svn GE2011.11/source/libs/cull/cull_where.c gridscheduler-trunk/source/libs/cull/cull_where.c
+--- GE2011.11/source/libs/cull/cull_where.c	2011-11-14 12:00:46.000000000 -0700
++++ gridscheduler-trunk/source/libs/cull/cull_where.c	2012-03-14 15:42:54.703119797 -0600
+@@ -731,7 +731,7 @@
+    case CHAR:
+       if (mt_get_type(cp->operand.cmp.mt) != lCharT)
+          incompatibleType(MSG_CULL_WHERE_SHOULDBECHART);
+-#if USING_GCC_2_96 || __GNUC__ >= 3 || __INSIGHT__
++#if __GNUC__ >= 3 || __INSIGHT__
+       cp->operand.cmp.val.c = va_arg(*app, int);
+ #else
+       cp->operand.cmp.val.c = va_arg(*app, lChar);
+@@ -741,7 +741,7 @@
+    case BOOL:
+       if (mt_get_type(cp->operand.cmp.mt) != lBoolT)
+          incompatibleType(MSG_CULL_WHERE_SHOULDBEBOOL);
+-#if USING_GCC_2_96 || __GNUC__ >= 3 || __INSIGHT__
++#if __GNUC__ >= 3 || __INSIGHT__
+       cp->operand.cmp.val.b = va_arg(*app, int);
+ #else
+       cp->operand.cmp.val.b = va_arg(*app, lBool);
+@@ -1162,17 +1162,20 @@
+ 
+    DENTER(CULL_LAYER, "lCompare");
+ 
+-   if (!ep) {
++   if (!ep)
++   {
+       LERROR(LEELEMNULL);
+       DRETURN(0);
+    }
+ 
+    /* no conditions ok */
+-   if (!cp) {
++   if (!cp)
++   {
+       DRETURN(1);
+    }
+ 
+-   switch (cp->op) {
++   switch (cp->op)
++   {
+    case EQUAL:
+    case NOT_EQUAL:
+    case LOWER_EQUAL:
+@@ -1181,17 +1184,21 @@
+    case GREATER:
+    case SUBSCOPE:
+ 
+-      switch (mt_get_type(cp->operand.cmp.mt)) {
++      switch (mt_get_type(cp->operand.cmp.mt))
++      {
+       case lIntT:
+          result = intcmp(lGetPosInt(ep, cp->operand.cmp.pos), cp->operand.cmp.val.i);
+          break;
++
+       case lStringT:
+-         if (!(str1 = lGetPosString(ep, cp->operand.cmp.pos))) {
++         if (!(str1 = lGetPosString(ep, cp->operand.cmp.pos)))
++         {
+             LERROR(LENULLSTRING);
+             DPRINTF(("lGetPosString in lCompare\n"));
+             DRETURN(0);
+          }
+-         if (!(str2 = cp->operand.cmp.val.str)) {
++         if (!(str2 = cp->operand.cmp.val.str))
++         {
+             DPRINTF(("cp->operand.cmp.val.str in lCompare\n"));
+             LERROR(LENULLSTRING);
+             DRETURN(0);
+@@ -1199,13 +1206,16 @@
+          result = strcmp(str1, str2);
+          DPRINTF(("strcmp(%s, %s)(lStringT) = %d\n", str1, str2, result));
+          break;
++
+       case lHostT:
+-         if (!(str1 = lGetPosHost(ep, cp->operand.cmp.pos))) {
++         if (!(str1 = lGetPosHost(ep, cp->operand.cmp.pos)))
++         {
+             LERROR(LENULLSTRING);
+             DPRINTF(("lGetPosHost in lCompare\n"));
+             DRETURN(0);
+          }
+-         if (!(str2 = cp->operand.cmp.val.host)) {
++         if (!(str2 = cp->operand.cmp.val.host))
++         {
+             DPRINTF(("cp->operand.cmp.val.host in lCompare\n"));
+             LERROR(LENULLSTRING);
+             DRETURN(0);
+@@ -1215,61 +1225,68 @@
+          break;
+ 
+       case lUlongT:
+-         result = ulongcmp(lGetPosUlong(ep, cp->operand.cmp.pos), 
+-                           cp->operand.cmp.val.ul);
++         result = ulongcmp(lGetPosUlong(ep, cp->operand.cmp.pos), cp->operand.cmp.val.ul);
+          break;
++
+       case lListT:
+-         result = (lFindFirst(lGetPosList(ep, cp->operand.cmp.pos), 
+-                              cp->operand.cmp.val.cp) != NULL);
++         result = (lFindFirst(lGetPosList(ep, cp->operand.cmp.pos), cp->operand.cmp.val.cp) != NULL);
+          DRETURN(result);
++
+       case lFloatT:
+-         result = floatcmp(lGetPosFloat(ep, cp->operand.cmp.pos), 
+-                           cp->operand.cmp.val.fl);
++         result = floatcmp(lGetPosFloat(ep, cp->operand.cmp.pos), cp->operand.cmp.val.fl);
+          break;
++
+       case lDoubleT:
+-         result = doublecmp(lGetPosDouble(ep, cp->operand.cmp.pos), 
+-                            cp->operand.cmp.val.db);
++         result = doublecmp(lGetPosDouble(ep, cp->operand.cmp.pos), cp->operand.cmp.val.db);
+          break;
++
+       case lLongT:
+-         result = longcmp(lGetPosLong(ep, cp->operand.cmp.pos), 
+-                          cp->operand.cmp.val.l);
++         result = longcmp(lGetPosLong(ep, cp->operand.cmp.pos), cp->operand.cmp.val.l);
+          break;
++
+       case lCharT:
+-         result = charcmp(lGetPosChar(ep, cp->operand.cmp.pos), 
+-                          cp->operand.cmp.val.c);
++         result = charcmp(lGetPosChar(ep, cp->operand.cmp.pos), cp->operand.cmp.val.c);
+          break;
++
+       case lBoolT:
+-         result = boolcmp(lGetPosBool(ep, cp->operand.cmp.pos), 
+-                          cp->operand.cmp.val.b);
++         result = boolcmp(lGetPosBool(ep, cp->operand.cmp.pos), cp->operand.cmp.val.b);
+          break;
++
+       case lRefT:
+-         result = refcmp(lGetPosRef(ep, cp->operand.cmp.pos), 
+-                         cp->operand.cmp.val.ref);
++         result = refcmp(lGetPosRef(ep, cp->operand.cmp.pos), cp->operand.cmp.val.ref);
+          break;
++
+       default:
+          unknownType("lCompare");
+          DRETURN(0);
+       }
+ 
+-      switch (cp->op) {
++      switch (cp->op)
++      {
+       case EQUAL:
+          result = (result == 0);
+          break;
++
+       case NOT_EQUAL:
+          result = (result != 0);
+          break;
++
+       case LOWER_EQUAL:
+          result = (result == -1 || result == 0);
+          break;
++
+       case LOWER:
+          result = (result == -1);
+          break;
++
+       case GREATER_EQUAL:
+          result = (result == 1 || result == 0);
+          break;
++
+       case GREATER:
+          result = (result == 1);
+          break;
++
+       default:
+          LERROR(LEOPUNKNOWN);
+          DRETURN(0);
+@@ -1278,79 +1295,97 @@
+ 
+    case STRCASECMP:
+    case HOSTNAMECMP:
+-      if ((mt_get_type(cp->operand.cmp.mt) != lStringT) && (mt_get_type(cp->operand.cmp.mt) != lHostT)) {
++      if ((mt_get_type(cp->operand.cmp.mt) != lStringT) && (mt_get_type(cp->operand.cmp.mt) != lHostT))
++      {
+          unknownType("lCompare");
+          DRETURN(0);
+       }
+ 
+-      if (mt_get_type(cp->operand.cmp.mt) == lStringT) {
++      if (mt_get_type(cp->operand.cmp.mt) == lStringT)
++      {
+          str1 = lGetPosString(ep, cp->operand.cmp.pos);
+-      } else {
++      }
++      else
++      {
+          str1 = lGetPosHost(ep, cp->operand.cmp.pos);
+       }
+-      if (str1 == NULL) {
++      if (str1 == NULL)
++      {
+           LERROR(LENULLSTRING);
+           DPRINTF(("lGetPosString in lCompare\n"));
+           DRETURN(0);
+       }
+ 
+-      if (!(str2 = cp->operand.cmp.val.str)) {
++      if (!(str2 = cp->operand.cmp.val.str))
++      {
+          DPRINTF(("cp->operand.cmp.val.str in lCompare\n"));
+          LERROR(LENULLSTRING);
+          DRETURN(0);
+       }
+ 
+-      if (cp->op == STRCASECMP ) {
++      if (cp->op == STRCASECMP )
++      {
+          result = SGE_STRCASECMP(str1, str2);
+-      } else {
++      }
++      else
++      {
+          result = sge_hostcmp(str1, str2);
+       }
+       result = (result == 0);
+       break;
+ 
+    case PATTERNCMP:
+-      if ((mt_get_type(cp->operand.cmp.mt) != lStringT) && (mt_get_type(cp->operand.cmp.mt) != lHostT)) {
++      if ((mt_get_type(cp->operand.cmp.mt) != lStringT) && (mt_get_type(cp->operand.cmp.mt) != lHostT))
++      {
+          unknownType("lCompare");
+          DRETURN(0);
+       }
+ 
+-      if (mt_get_type(cp->operand.cmp.mt) == lStringT) {
+-         if (!(str1 = lGetPosString(ep, cp->operand.cmp.pos))) {
++      if (mt_get_type(cp->operand.cmp.mt) == lStringT)
++      {
++         if (!(str1 = lGetPosString(ep, cp->operand.cmp.pos)))
++         {
+             str1 = "";
+          }
+ 
+-         if (!(str2 = cp->operand.cmp.val.str)) {
++         if (!(str2 = cp->operand.cmp.val.str))
++         {
+             DPRINTF(("cp->operand.cmp.val.str in lCompare\n"));
+             LERROR(LENULLSTRING);
+             DRETURN(0);
+          }
+-      } else {
+-         if (!(str1 = lGetPosHost(ep, cp->operand.cmp.pos))) {
++      }
++      else
++      {
++         if (!(str1 = lGetPosHost(ep, cp->operand.cmp.pos)))
++         {
+             str1 = "";
+          }
+ 
+-         if (!(str2 = cp->operand.cmp.val.host)) {
++         if (!(str2 = cp->operand.cmp.val.host))
++         {
+             DPRINTF(("cp->operand.cmp.val.host in lCompare\n"));
+             LERROR(LENULLSTRING);
+             DRETURN(0);
+          }
+       }
+ 
+-      result = !fnmatch(str2, str1, 0);
++      result = !fnmatch(str2, str1, FNM_NOESCAPE);
+       break;
+ 
+ 
+    case BITMASK:
+-      if (mt_get_type(cp->operand.cmp.mt) != lUlongT) {
++      if (mt_get_type(cp->operand.cmp.mt) != lUlongT)
++      {
+          unknownType("lCompare");
+          DRETURN(0);
+       }
+-      result = bitmaskcmp(lGetPosUlong(ep, cp->operand.cmp.pos), 
+-                          cp->operand.cmp.val.ul);
++      result = bitmaskcmp(lGetPosUlong(ep, cp->operand.cmp.pos), cp->operand.cmp.val.ul);
+       break;
+ 
+    case AND:
+-      if (!lCompare(ep, cp->operand.log.first)) {
++      if (!lCompare(ep, cp->operand.log.first))
++      {
+          result = 0;
+          break;
+       }
+diff -ruN --exclude .svn GE2011.11/source/libs/cull/pack.c gridscheduler-trunk/source/libs/cull/pack.c
+--- GE2011.11/source/libs/cull/pack.c	2011-11-14 12:00:46.000000000 -0700
++++ gridscheduler-trunk/source/libs/cull/pack.c	2012-02-08 09:46:01.908118454 -0700
+@@ -37,7 +37,13 @@
+ #include <stdlib.h>
+ #include <sys/types.h>
+ #include <netinet/in.h>
+-#include <rpc/rpc.h>
++
++#if defined(CYGWIN)
++# include <rpc/xdr.h>
++#else
++# include <rpc/rpc.h>
++#endif
++
+ #include <rpc/types.h>
+ 
+ #if defined(INTERIX)
+diff -ruN --exclude .svn GE2011.11/source/libs/evc/sge_event_client.c gridscheduler-trunk/source/libs/evc/sge_event_client.c
+--- GE2011.11/source/libs/evc/sge_event_client.c	2011-11-14 12:00:51.000000000 -0700
++++ gridscheduler-trunk/source/libs/evc/sge_event_client.c	2012-04-17 09:13:36.722327174 -0600
+@@ -798,14 +798,13 @@
+    pthread_mutex_lock(&((*sge_evc)->event_control.mutex));
+    pthread_cond_broadcast(&((*sge_evc)->event_control.cond_var));
+    pthread_mutex_unlock(&((*sge_evc)->event_control.mutex));
+-                                                                                                  
++
+    pthread_cond_destroy(&((*sge_evc)->event_control.cond_var));
+    pthread_mutex_destroy(&((*sge_evc)->event_control.mutex));
+    lFreeList(&((*sge_evc)->event_control.new_events));
+ 
+    lFreeElem(&((*sge_evc)->ec));
+    FREE(*sge_evc);
+-   *sge_evc = NULL;
+    
+    DRETURN_VOID;
+ }
+@@ -2215,7 +2214,7 @@
+    if (sge_evc->ec == NULL) {
+       ERROR((SGE_EVENT, MSG_EVENT_UNINITIALIZED_EC));
+    } else if (event < sgeE_ALL_EVENTS || event >= sgeE_EVENTSIZE) {
+-      WARNING((SGE_EVENT, MSG_EVENT_ILLEGALEVENTID_I, event ));
++      WARNING((SGE_EVENT, MSG_EVENT_ILLEGALEVENTID_I, event));
+    } else {
+       lListElem *sub_event = lGetElemUlong(lGetList(sge_evc->ec, EV_subscribed), EVS_id, event);
+ 
+@@ -2224,7 +2223,7 @@
+       } 
+       else { 
+          ec2_mod_subscription_flush(thiz, event, EV_NOT_FLUSHED, EV_NO_FLUSH);
+-      } 
++      }
+ 
+       if (lGetBool(sge_evc->ec, EV_changed)) {
+          ret = true;
+diff -ruN --exclude .svn GE2011.11/source/libs/gdi/sge_gdi2.c gridscheduler-trunk/source/libs/gdi/sge_gdi2.c
+--- GE2011.11/source/libs/gdi/sge_gdi2.c	2011-11-14 12:00:48.000000000 -0700
++++ gridscheduler-trunk/source/libs/gdi/sge_gdi2.c	2012-04-17 09:13:36.512334711 -0600
+@@ -1154,8 +1154,8 @@
+    unsigned long dummy_mid;
+    unsigned long* mid_pointer = NULL;
+    int use_execd_handle = 0;
+-   u_long32 progid = sge_ctx->get_who(sge_ctx);
+-   
++   u_long32 progid;
++
+    DENTER(GDI_LAYER, "gdi2_send_message");
+ 
+    /* CR- TODO: This is for tight integration of qrsh -inherit
+@@ -1166,10 +1166,14 @@
+     *       to a cl_com_handle_t* handle and use this handle to
+     *       send/receive messages to the correct endpoint.
+     */
+-   if ( tocomproc[0] == '\0') {
++   if (tocomproc[0] == '\0')
++   {
+       DEBUG((SGE_EVENT,"tocomproc is empty string\n"));
+    }
+-   switch (progid) {
++
++   progid = sge_ctx->get_who(sge_ctx);
++   switch (progid)
++   {
+       case QMASTER:
+       case EXECD:
+          use_execd_handle = 0;
+@@ -1205,17 +1209,20 @@
+                               CL_FALSE, sge_get_execd_port(), CL_TCP_DEFAULT,
+                               "execd_handle" , 0 , 1 , 0 );
+          handle = cl_com_get_handle("execd_handle", 0);
+-         if (handle == NULL) {
+-            ERROR((SGE_EVENT,MSG_GDI_CANT_CREATE_HANDLE_TOEXECD_S, tocomproc));
+-            ERROR((SGE_EVENT,cl_get_error_text(commlib_error)));
++         if (handle == NULL)
++         {
++            ERROR((SGE_EVENT, MSG_GDI_CANT_CREATE_HANDLE_TOEXECD_S, tocomproc));
++            ERROR((SGE_EVENT, cl_get_error_text(commlib_error)));
+          }
+       }
+    }
+ 
+-   if (synchron) {
++   if (synchron)
++   {
+       ack_type = CL_MIH_MAT_ACK;
+    }
+-   if (mid != NULL) {
++   if (mid != NULL)
++   {
+       mid_pointer = &dummy_mid;
+    }
+ 
+@@ -1223,7 +1230,8 @@
+                                  ack_type, (cl_byte_t**)buffer, (unsigned long)buflen,
+                                  mid_pointer, 0, tag, CL_FALSE, (cl_bool_t)synchron);
+ 
+-   if (mid != NULL) {
++   if (mid != NULL)
++   {
+       *mid = dummy_mid;
+    }
+ 
+@@ -1243,13 +1251,11 @@
+ {
+    
+    int ret;
+-   cl_com_handle_t* handle = NULL;
+-   cl_com_message_t* message = NULL;
+-   cl_com_endpoint_t* sender = NULL;
++   cl_com_handle_t *handle = NULL;
++   cl_com_message_t *message = NULL;
++   cl_com_endpoint_t *sender = NULL;
+    int use_execd_handle = 0;
+-
+-   u_long32 progid = sge_ctx->get_who(sge_ctx);
+-   u_long32 sge_execd_port = sge_ctx->get_sge_execd_port(sge_ctx);
++   u_long32 progid;
+ 
+ 
+    DENTER(GDI_LAYER, "gdi2_receive_message");
+@@ -1264,89 +1270,119 @@
+     */
+ 
+ 
+-   if (fromcommproc[0] == '\0') {
++   if (fromcommproc[0] == '\0')
++   {
+       DEBUG((SGE_EVENT,"fromcommproc is empty string\n"));
+    }
+-   switch (progid) {
++
++   progid = sge_ctx->get_who(sge_ctx);
++   switch (progid)
++   {
+       case QMASTER:
+       case EXECD:
+          use_execd_handle = 0;
+          break;
+       default:
+-         if (strcmp(fromcommproc,prognames[QMASTER]) == 0) {
++         if (strcmp(fromcommproc,prognames[QMASTER]) == 0)
++         {
+             use_execd_handle = 0;
+-         } else {
+-            if (fromcommproc != NULL && fromcommproc[0] != '\0') {
++         }
++         else
++         {
++            if (fromcommproc != NULL && fromcommproc[0] != '\0')
++            {
+                use_execd_handle = 1;
+             }
+          }
+    }
+ 
+-   if (use_execd_handle == 0) {
++   if (use_execd_handle == 0)
++   {
+       /* normal gdi send to qmaster */
+       DEBUG((SGE_EVENT,"standard gdi receive message\n"));
+       handle = sge_ctx->get_com_handle(sge_ctx);
+-   } else {
++   }
++   else
++   {
+       /* we have to send a message to another component than qmaster */
+       DEBUG((SGE_EVENT,"search handle to \"%s\"\n", fromcommproc));
+       handle = cl_com_get_handle("execd_handle", 0);
+-      if (handle == NULL) {
++      if (handle == NULL)
++      {
+          int commlib_error = CL_RETVAL_OK;
+-         cl_framework_t  communication_framework = CL_CT_TCP;
+-         DEBUG((SGE_EVENT,"creating handle to \"%s\"\n", fromcommproc));
+-         if (feature_is_enabled(FEATURE_CSP_SECURITY)) {
++         cl_framework_t communication_framework = CL_CT_TCP;
++         u_long32 sge_execd_port = sge_ctx->get_sge_execd_port(sge_ctx);
++
++         DEBUG((SGE_EVENT, "creating handle to \"%s\"\n", fromcommproc));
++         if (feature_is_enabled(FEATURE_CSP_SECURITY))
++         {
+             DPRINTF(("using communication lib with SSL framework (execd_handle)\n"));
+             communication_framework = CL_CT_SSL;
+          }
+          
+          cl_com_create_handle(&commlib_error, communication_framework, CL_CM_CT_MESSAGE,
+-                              CL_FALSE, sge_execd_port, CL_TCP_DEFAULT, 
+-                              "execd_handle" , 0 , 1 , 0 );
++                              CL_FALSE, sge_execd_port, CL_TCP_DEFAULT, "execd_handle", 0, 1, 0);
++
+          handle = cl_com_get_handle("execd_handle", 0);
+-         if (handle == NULL) {
+-            ERROR((SGE_EVENT,MSG_GDI_CANT_CREATE_HANDLE_TOEXECD_S, fromcommproc));
+-            ERROR((SGE_EVENT,cl_get_error_text(commlib_error)));
++         if (handle == NULL)
++         {
++            ERROR((SGE_EVENT, MSG_GDI_CANT_CREATE_HANDLE_TOEXECD_S, fromcommproc));
++            ERROR((SGE_EVENT, cl_get_error_text(commlib_error)));
+          }
+       }
+    } 
+ 
+    ret = cl_commlib_receive_message(handle, fromhost, fromcommproc, *fromid, (cl_bool_t)synchron, 0, &message, &sender);
+ 
+-   if (ret == CL_RETVAL_CONNECTION_NOT_FOUND) {
+-      if (fromcommproc[0] != '\0' && fromhost[0] != '\0') {
++   if (ret == CL_RETVAL_CONNECTION_NOT_FOUND)
++   {
++      if (fromcommproc[0] != '\0' && fromhost[0] != '\0')
++      {
+           /* The connection was closed, reopen it */
+-          ret = cl_commlib_open_connection(handle,fromhost,fromcommproc, *fromid);
+-          INFO((SGE_EVENT,"reopen connection to %s,%s,"sge_U32CFormat" (1)\n", fromhost , fromcommproc , sge_u32c(*fromid)));
+-          if (ret == CL_RETVAL_OK) {
+-             INFO((SGE_EVENT,"reconnected successfully\n"));
++          ret = cl_commlib_open_connection(handle, fromhost, fromcommproc, *fromid);
++          INFO((SGE_EVENT, "reopen connection to %s,%s, "sge_U32CFormat" (1)\n", fromhost , fromcommproc , sge_u32c(*fromid)));
++          if (ret == CL_RETVAL_OK)
++          {
++             INFO((SGE_EVENT, "reconnected successfully\n"));
+              ret = cl_commlib_receive_message(handle, fromhost, fromcommproc, *fromid, (cl_bool_t) synchron, 0, &message, &sender);
+           } 
+-      } else {
+-         DEBUG((SGE_EVENT,"can't reopen a connection to unspecified host or commproc (1)\n"));
++      }
++      else
++      {
++         DEBUG((SGE_EVENT, "can't reopen a connection to unspecified host or commproc (1)\n"));
+       }
+    }
+ 
+-   if (message != NULL && ret == CL_RETVAL_OK) {
++   if (message != NULL && ret == CL_RETVAL_OK)
++   {
+       *buffer = (char *)message->message;
+       message->message = NULL;
+       *buflen = message->message_length;
+-      if (tag) {
++      if (tag)
++      {
+          *tag = (int)message->message_tag;
+       }
+ 
+-      if (sender != NULL) {
++      if (sender != NULL)
++      {
+          DEBUG((SGE_EVENT,"received from: %s,"sge_U32CFormat"\n",sender->comp_host, sge_u32c(sender->comp_id)));
+-         if (fromcommproc != NULL && fromcommproc[0] == '\0') {
++         if (fromcommproc != NULL && fromcommproc[0] == '\0')
++         {
+             strcpy(fromcommproc, sender->comp_name);
+          }
+-         if (fromhost != NULL) {
++
++         if (fromhost != NULL)
++         {
+             strcpy(fromhost, sender->comp_host);
+          }
+-         if (fromid != NULL) {
++
++         if (fromid != NULL)
++         {
+             *fromid = (u_short)sender->comp_id;
+          }
+       }
+    }
++
+    cl_com_free_message(&message);
+    cl_com_free_endpoint(&sender);
+ 
+@@ -1472,9 +1508,9 @@
+    if (!success) {
+       if (!already_logged) {
+          ERROR((SGE_EVENT, MSG_CONF_GETCONF_S, lGetString(lFirst(alp), AN_text)));
+-         already_logged = 1;       
++         already_logged = 1;
+       }
+-                   
++
+       lFreeList(&alp);
+       lFreeList(&lp);
+       lFreeElem(&hep);
+@@ -1527,7 +1563,7 @@
+    u_long32 progid = ctx->get_who(ctx);
+    
+    /* TODO: move this function to execd */
+-   DENTER(GDI_LAYER, "gdi2_wait_for_confgdi2_wait_for_conf");
++   DENTER(GDI_LAYER, "gdi2_wait_for_conf");
+    /*
+     * for better performance retrieve 2 configurations
+     * in one gdi call
+diff -ruN --exclude .svn GE2011.11/source/libs/gdi/sge_gdi_packet.c gridscheduler-trunk/source/libs/gdi/sge_gdi_packet.c
+--- GE2011.11/source/libs/gdi/sge_gdi_packet.c	2011-11-14 12:00:48.000000000 -0700
++++ gridscheduler-trunk/source/libs/gdi/sge_gdi_packet.c	2012-04-17 09:13:36.514334639 -0600
+@@ -370,7 +370,7 @@
+       lFreeList(&((*task)->answer_list));
+       lFreeWhat(&((*task)->enumeration));
+       lFreeWhere(&((*task)->condition));
+-      *task = (sge_gdi_task_class_t *) sge_free((char *) (*task));
++      FREE(*task);
+    }
+    DRETURN(ret);
+ }
+@@ -737,7 +737,8 @@
+    bool ret = true;
+ 
+    DENTER(TOP_LAYER, "sge_gdi_packet_free");
+-   if (packet != NULL && *packet != NULL) {
++   if (packet != NULL && *packet != NULL)
++   {
+       sge_gdi_task_class_t *task = NULL;
+       sge_gdi_task_class_t *next_task = NULL;
+       int local_ret1;
+@@ -753,11 +754,10 @@
+       if (local_ret1 != 0 || local_ret2 != 0) {
+          ret = false;
+       }
+-      (*packet)->host = sge_free((char *) (*packet)->host);
+-      (*packet)->commproc = sge_free((char *) (*packet)->commproc);
+-
+-      (*packet)->auth_info = sge_free((char *) (*packet)->auth_info);
+-      *packet = (sge_gdi_packet_class_t *)sge_free((char *) *packet);
++      FREE((*packet)->host);
++      FREE((*packet)->commproc);
++      FREE((*packet)->auth_info);
++      FREE( *packet);
+    }
+    DRETURN(ret);
+ }
+diff -ruN --exclude .svn GE2011.11/source/libs/gdi/sge_gdi_packet_pb_cull.c gridscheduler-trunk/source/libs/gdi/sge_gdi_packet_pb_cull.c
+--- GE2011.11/source/libs/gdi/sge_gdi_packet_pb_cull.c	2011-11-14 12:00:48.000000000 -0700
++++ gridscheduler-trunk/source/libs/gdi/sge_gdi_packet_pb_cull.c	2012-04-17 09:13:36.515334603 -0600
+@@ -316,7 +316,7 @@
+             auth_info = NULL;
+             first = false;
+          } else {
+-            auth_info = (char *) sge_free((char *) auth_info);
++            FREE(auth_info);
+          }
+ 
+          /* EB: TODO: ST: cleanup - set last parameter to true */
+diff -ruN --exclude .svn GE2011.11/source/libs/gdi/version.c gridscheduler-trunk/source/libs/gdi/version.c
+--- GE2011.11/source/libs/gdi/version.c	2011-11-14 12:00:48.000000000 -0700
++++ gridscheduler-trunk/source/libs/gdi/version.c	2012-04-17 09:13:36.513334675 -0600
+@@ -34,7 +34,7 @@
+ 
+ #include "gdi/version.h"
+ 
+-const char GDI_VERSION[] = "2011.11"; /* "6.2u5"; */
++const char GDI_VERSION[] = "2011.11p1"; /* "6.2u5"; */
+ 
+ const gdi_ulong32 GRM_GDI_VERSION = 0x100020F8;
+ 
+diff -ruN --exclude .svn GE2011.11/source/libs/japi/drmaa.c gridscheduler-trunk/source/libs/japi/drmaa.c
+--- GE2011.11/source/libs/japi/drmaa.c	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/libs/japi/drmaa.c	2012-02-08 09:46:01.518131887 -0700
+@@ -121,7 +121,7 @@
+ *******************************************************************************/
+ 
+ /* Defined in rshd.c */
+-#if defined(DARWIN9) || defined(DARWIN10)
++#if defined(DARWIN9)
+ #  include <crt_externs.h>
+ #  define environ (*_NSGetEnviron())
+ #else
+diff -ruN --exclude .svn GE2011.11/source/libs/jgdi/jgdi_common.c gridscheduler-trunk/source/libs/jgdi/jgdi_common.c
+--- GE2011.11/source/libs/jgdi/jgdi_common.c	2011-11-14 12:00:51.000000000 -0700
++++ gridscheduler-trunk/source/libs/jgdi/jgdi_common.c	2012-04-17 09:13:36.674328897 -0600
+@@ -5261,17 +5261,19 @@
+  * Method:    nativeSgeEdit
+  * Signature: (Ljava/lang/String;)I
+  */
+-JNIEXPORT jint JNICALL Java_com_sun_grid_jgdi_util_shell_editor_EditorUtil_nativeSgeEdit(JNIEnv *env, jclass clazz, jstring path) {
+-   jint ret = 0;
++JNIEXPORT jint JNICALL Java_com_sun_grid_jgdi_util_shell_editor_EditorUtil_nativeSgeEdit(JNIEnv *env, jclass clazz, jstring path)
++{
++   jint ret;
+    uid_t uid = getuid();
+-   uid_t gid = getgid();
++   gid_t gid = getgid();
+    const char *strpath = NULL;
+ 
+    DENTER(TOP_LAYER, "Java_com_sun_grid_jgdi_util_shell_editor_EditorUtil_nativeSgeEdit");
+ 
+    strpath = (*env)->GetStringUTFChars(env, path, 0);
+    ret = sge_edit(strpath, uid, gid);
+-   if (strpath) { 
++   if (strpath)
++   { 
+       (*env)->ReleaseStringUTFChars(env, path, strpath);
+    }
+ 
+diff -ruN --exclude .svn GE2011.11/source/libs/rmon/sgermon.h gridscheduler-trunk/source/libs/rmon/sgermon.h
+--- GE2011.11/source/libs/rmon/sgermon.h	2011-11-14 12:00:49.000000000 -0700
++++ gridscheduler-trunk/source/libs/rmon/sgermon.h	2012-04-17 09:13:36.616330978 -0600
+@@ -203,18 +203,23 @@
+ #else /* NO_SGE_COMPILE_DEBUG */
+ 
+ #define DENTER_MAIN( layer, program )
++#define DENTER_( layer, function)
+ #define DENTER( layer, function)
+ #define DEXIT
++#define DEXIT_
+ #define DRETURN(x) return x
++#define DRETURN_(x) return x
+ #define DRETURN_VOID return
++#define DRETURN_VOID_ return
+ #define DTRACE
+ #define DLOCKPRINTF(x)
+ #define DPRINTF(x)
++#define DPRINTF_(x)
+ #define DTIMEPRINTF(x)
+ #define DSPECIALPRINTF(x)
+ #define DCLOSE
+ #define TRACEON
+-#define ISTRACE
++#define ISTRACE            0
+ #define SGE_EXIT(x, y)     sge_exit((x), (y))
+ 
+ #endif /* NO_SGE_COMPILE_DEBUG */
+diff -ruN --exclude .svn GE2011.11/source/libs/sgeobj/sge_conf.c gridscheduler-trunk/source/libs/sgeobj/sge_conf.c
+--- GE2011.11/source/libs/sgeobj/sge_conf.c	2011-11-14 12:00:49.000000000 -0700
++++ gridscheduler-trunk/source/libs/sgeobj/sge_conf.c	2012-02-08 09:46:02.325104092 -0700
+@@ -35,8 +35,9 @@
+ #include <stdlib.h>
+ #include <unistd.h>
+ 
+-#ifdef LINUX
++#ifdef __GNU_LIBRARY__
+ #include <mcheck.h>
++#define HAVE_MCHECK
+ #endif
+ 
+ #include "rmon/sgermon.h"
+@@ -163,7 +164,7 @@
+ static bool enable_reschedule_kill = false;
+ static bool enable_reschedule_slave = false;
+ 
+-#ifdef LINUX
++#ifdef HAVE_MCHECK
+ static bool enable_mtrace = false;
+ #endif
+ 
+@@ -645,7 +646,7 @@
+       char* execd_params = mconf_get_execd_params();
+       char* reporting_params = mconf_get_reporting_params();
+       u_long32 load_report_time = mconf_get_load_report_time();
+-#ifdef LINUX
++#ifdef HAVE_MCHECK
+       bool mtrace_before = enable_mtrace;
+ #endif
+ 
+@@ -725,7 +726,7 @@
+          if (parse_bool_param(s, "ENABLE_FORCED_QDEL_IF_UNKNOWN", &enable_forced_qdel_if_unknown)) {
+             continue;
+          } 
+-#ifdef LINUX
++#ifdef HAVE_MCHECK
+          if (parse_bool_param(s, "ENABLE_MTRACE", &enable_mtrace)) {
+             continue;
+          }
+@@ -800,7 +801,7 @@
+       sge_free_saved_vars(conf_context);
+       conf_context = NULL;
+      
+-#ifdef LINUX
++#ifdef HAVE_MCHECK
+       /* enable/disable GNU malloc library facility for recording of all 
+          memory allocation/deallocation 
+          requires MALLOC_TRACE in environment (see mtrace(3) under Linux) */
+diff -ruN --exclude .svn GE2011.11/source/libs/sgeobj/sge_var.c gridscheduler-trunk/source/libs/sgeobj/sge_var.c
+--- GE2011.11/source/libs/sgeobj/sge_var.c	2011-11-14 12:00:49.000000000 -0700
++++ gridscheduler-trunk/source/libs/sgeobj/sge_var.c	2012-04-17 09:13:36.566332773 -0600
+@@ -314,7 +314,7 @@
+          strcat(sharedlib_path, ":");
+          strcat(sharedlib_path, old_value);
+          lSetString(sharedlib_elem, VA_value, sharedlib_path);
+-         sharedlib_path = sge_free(sharedlib_path);
++         FREE(sharedlib_path);
+       } else {
+          DPRINTF(("overwriting empty sharedlib path %s\n", 
+                   sharedlib_path_name));
+@@ -327,7 +327,8 @@
+       lSetString(sharedlib_elem, VA_value, sge_sharedlib_path);
+    }
+ 
+-   sge_sharedlib_path = sge_free(sge_sharedlib_path);
++   FREE(sge_sharedlib_path);
++
+    DEXIT;
+ }
+ 
+@@ -965,7 +966,7 @@
+    *a = '\0';
+ 
+    lSetString(ep, VA_value, new_env_value);
+-   sge_free(new_env_value);
++   FREE(new_env_value);
+    return;
+ 
+ }
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_dstring.c gridscheduler-trunk/source/libs/uti/sge_dstring.c
+--- GE2011.11/source/libs/uti/sge_dstring.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_dstring.c	2012-04-17 09:13:36.461336541 -0600
+@@ -108,7 +108,7 @@
+          }
+          if (dyn_buffer != NULL) {
+             ret = function(sb, dyn_buffer);
+-            sge_free(dyn_buffer);
++            FREE(dyn_buffer);
+          } else {
+             /* error: no memory */
+             ret = NULL;
+@@ -123,7 +123,7 @@
+             va_end(ap_copy);
+ 
+             ret = function(sb, dyn_buffer);
+-            sge_free(dyn_buffer);
++            FREE(dyn_buffer);
+          } else {
+             /* error: no memory */
+             ret = NULL;
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_edit.c gridscheduler-trunk/source/libs/uti/sge_edit.c
+--- GE2011.11/source/libs/uti/sge_edit.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_edit.c	2012-03-21 09:25:09.535954703 -0600
+@@ -48,47 +48,63 @@
+ {
+    SGE_STRUCT_STAT before, after;
+    pid_t pid;
+-   int status;
+-   int ws = 0;
+ 
+    DENTER(TOP_LAYER, "sge_edit");;
+ 
+-   if (fname == NULL) {
++   if (fname == NULL)
++   {
+       ERROR((SGE_EVENT, MSG_NULLPOINTER));
+       return -1;
+    }
+ 
+-   if (SGE_STAT(fname, &before)) {
++   if (SGE_STAT(fname, &before))
++   {
+       ERROR((SGE_EVENT, MSG_FILE_EDITFILEXDOESNOTEXIST_S, fname));
+       DEXIT;
+       return -1;
+    }
+ 
+-   chown(fname, myuid, mygid);
++   if (chown(fname, myuid, mygid) != 0)
++   {
++      ERROR((SGE_EVENT, MSG_FILE_CANNOT_CHOWN, fname));
++      DEXIT;
++      return -1;
++   }
+ 
+    pid = fork();
+-   if (pid) {
+-      while (ws != pid) {
++   if (pid)
++   {
++      int ws = 0;
++
++      while (ws != pid)
++      {
++         int status;
++
+          ws = waitpid(pid, &status, 0);
+-         if (WIFEXITED(status)) {
+-            if (WEXITSTATUS(status) != 0) {
+-               ERROR((SGE_EVENT, MSG_QCONF_EDITOREXITEDWITHERROR_I,
+-                      (int) WEXITSTATUS(status)));
++         if (WIFEXITED(status))
++         {
++            if (WEXITSTATUS(status) != 0)
++            {
++               ERROR((SGE_EVENT, MSG_QCONF_EDITOREXITEDWITHERROR_I, (int) WEXITSTATUS(status)));
+                DEXIT;
+                return -1;
+             }
+-            else {
+-               if (SGE_STAT(fname, &after)) {
++            else
++            {
++               if (SGE_STAT(fname, &after))
++               {
+                   ERROR((SGE_EVENT, MSG_QCONF_EDITFILEXNOLONGEREXISTS_S, fname));
+                   DEXIT;
+                   return -1;
+                }
+                if ((before.st_mtime != after.st_mtime) || 
+-                    (before.st_size != after.st_size)) { 
++                   (before.st_size  != after.st_size))
++               { 
+                   DEXIT;
+                   return 0;
+                }
+-               else {
++               else
++               {
+                   /* file is unchanged; inform caller */
+                   DEXIT;
+                   return 1;
+@@ -96,15 +112,17 @@
+             }
+          }
+ #ifndef WIN32  /* signals b18 */
+-         if (WIFSIGNALED(status)) {
+-            ERROR((SGE_EVENT, MSG_QCONF_EDITORWASTERMINATEDBYSIGX_I,
+-                   (int) WTERMSIG(status)));
++         if (WIFSIGNALED(status))
++         {
++            ERROR((SGE_EVENT, MSG_QCONF_EDITORWASTERMINATEDBYSIGX_I, (int) WTERMSIG(status)));
+             DEXIT;
+             return -1;
+          }
+ #endif
+       }
+-   } else {
++   }
++   else
++   {
+       const char *cp = NULL;
+ 
+       sge_set_def_sig_mask(NULL, NULL);
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_env.c gridscheduler-trunk/source/libs/uti/sge_env.c
+--- GE2011.11/source/libs/uti/sge_env.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_env.c	2012-04-17 09:13:36.462336505 -0600
+@@ -137,7 +137,7 @@
+    }   
+    sge_env_state_destroy((*pst)->sge_env_state_handle);
+    FREE(*pst);
+-   *pst = NULL;
++
+    DEXIT;
+ }
+ 
+@@ -166,7 +166,7 @@
+ 
+    FREE(s->sge_root);
+    FREE(s->sge_cell);
+-   sge_free((char*)s);
++   FREE(s);
+ 
+    DEXIT;
+ }
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_getloadavg.c gridscheduler-trunk/source/libs/uti/sge_getloadavg.c
+--- GE2011.11/source/libs/uti/sge_getloadavg.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_getloadavg.c	2012-03-21 09:25:09.551954133 -0600
+@@ -1175,7 +1175,7 @@
+ {
+    int   elem = 0;   
+ 
+-#if defined(ALPHA4) || defined(ALPHA5) || defined(IRIX) || defined(HPUX) || defined(CRAY) || defined(NECSX4) || defined(NECSX5) || defined(OGLIBC_LINUX) || defined(HAS_AIX_PERFLIB)
++#if defined(ALPHA4) || defined(ALPHA5) || defined(IRIX) || defined(HPUX) || defined(CRAY) || defined(NECSX4) || defined(NECSX5) || defined(HAS_AIX_PERFLIB) || defined(OGLIBC_LINUX)
+    elem = get_load_avg(loadavg, nelem);
+ #elif defined(SOLARIS) || defined(FREEBSD) || defined(NETBSD) || defined(DARWIN) || defined(LINUX)
+    elem = getloadavg(loadavg, nelem);  /* <== library function */
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_hostname.c gridscheduler-trunk/source/libs/uti/sge_hostname.c
+--- GE2011.11/source/libs/uti/sge_hostname.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_hostname.c	2012-02-08 09:46:02.068112943 -0700
+@@ -97,7 +97,7 @@
+  * safe.  This will require that you update aimk to include the correct defines
+  * for each architecture.
+  ******************************************************************************/
+-#if defined(LINUX)
++#if defined(LINUX_NATIVE)
+       if (getservbyname_r(service, "tcp", se_result, buffer, size, &se) != 0)
+          se = NULL;
+ #elif defined(SOLARIS)
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_htable.c gridscheduler-trunk/source/libs/uti/sge_htable.c
+--- GE2011.11/source/libs/uti/sge_htable.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_htable.c	2012-03-21 09:25:09.546954312 -0600
+@@ -152,15 +152,15 @@
+    
+ #ifdef SGE_USE_PROFILING
+    clock_t start = 0;
+-#endif   
+    char buffer[1024];
+    dstring buffer_wrapper;
++#endif
+ 
+    DENTER_(BASIS_LAYER, "sge_htable_resize");
+ 
++#ifdef SGE_USE_PROFILING
+    sge_dstring_init(&buffer_wrapper, buffer, sizeof(buffer));
+ 
+-#ifdef SGE_USE_PROFILING
+    if(prof_is_active(SGE_PROF_HT_RESIZE) && log_state_get_log_level() >= LOG_DEBUG) {
+       struct tms t_buf;
+       DEBUG((SGE_EVENT, "hash stats before resizing: %s\n", 
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_log.c gridscheduler-trunk/source/libs/uti/sge_log.c
+--- GE2011.11/source/libs/uti/sge_log.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_log.c	2012-04-17 09:13:36.463336469 -0600
+@@ -80,10 +80,9 @@
+ static void log_buffer_once_init(void);
+ static void log_context_once_init(void);
+ 
+-static void log_buffer_destroy(void* theState);
++static void pthread_key_destructor(void *theState);
+ static log_buffer_t* log_buffer_getspecific(void);
+ 
+-static void log_context_destroy(void* theState);
+ static log_context_t* log_context_getspecific(void);
+ static sge_gdi_ctx_class_t* log_state_get_log_context(void);
+ 
+@@ -692,15 +691,15 @@
+ *******************************************************************************/
+ static void log_buffer_once_init(void)
+ {
+-   pthread_key_create(&log_buffer_key, &log_buffer_destroy);
++   pthread_key_create(&log_buffer_key, &pthread_key_destructor);
+ } /* log_once_init */
+ 
+-/****** uti/log/log_buffer_destroy() ****************************************
++/****** uti/log/pthread_key_destructor() ****************************************
+ *  NAME
+-*     log_buffer_destroy() -- Free thread local storage
++*     pthread_key_destructor() -- Free thread local storage
+ *
+ *  SYNOPSIS
+-*     static void log_buffer_destroy(void* theState) 
++*     static void pthread_key_destructor(void *theState) 
+ *
+ *  FUNCTION
+ *     Free thread local storage.
+@@ -712,14 +711,15 @@
+ *     static void - none
+ *
+ *  NOTES
+-*     MT-NOTE: log_buffer_destroy() is MT safe.
++*     MT-NOTE: pthread_key_destructor() is MT safe.
+ *
+ *******************************************************************************/
+-static void log_buffer_destroy(void* theBuffer)
++static void pthread_key_destructor(void *theContext)
+ {
+-   sge_free((char*)theBuffer);
++   FREE(theContext);
+ }
+ 
++
+ /****** uti/log/log_buffer_getspecific() ****************************************
+ *  NAME
+ *     log_buffer_getspecific() -- Get thread local log state
+@@ -789,34 +789,9 @@
+ *******************************************************************************/
+ static void log_context_once_init(void)
+ {
+-   pthread_key_create(&log_context_key, &log_context_destroy);
++   pthread_key_create(&log_context_key, &pthread_key_destructor);
+ } /* log_once_init */
+ 
+-/****** uti/log/log_context_destroy() ****************************************
+-*  NAME
+-*     log_context_destroy() -- Free thread local storage
+-*
+-*  SYNOPSIS
+-*     static void log_context_destroy(void* theState) 
+-*
+-*  FUNCTION
+-*     Free thread local storage.
+-*
+-*  INPUTS
+-*     void* theState - Pointer to memroy which should be freed.
+-*
+-*  RESULT
+-*     static void - none
+-*
+-*  NOTES
+-*     MT-NOTE: log_context_destroy() is MT safe.
+-*
+-*******************************************************************************/
+-static void log_context_destroy(void* theContext)
+-{
+-   sge_free((char*)theContext);
+-}
+-
+ /****** uti/log/log_context_getspecific() ****************************************
+ *  NAME
+ *     log_context_getspecific() -- Get thread local log context
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_log.h gridscheduler-trunk/source/libs/uti/sge_log.h
+--- GE2011.11/source/libs/uti/sge_log.h	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_log.h	2012-04-17 09:13:36.463336469 -0600
+@@ -38,7 +38,7 @@
+ #include "basis_types.h"
+ #include "msg_utilib.h"
+ 
+-#define LOG_PROF       0      /* no action, but it has to be printed allways */
++#define LOG_PROF       0      /* no action, but it has to be printed always */
+ 
+ void log_state_set_log_level(u_long32);
+ void log_state_set_log_file(char *file);
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_monitor.c gridscheduler-trunk/source/libs/uti/sge_monitor.c
+--- GE2011.11/source/libs/uti/sge_monitor.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_monitor.c	2012-03-21 09:25:09.545954348 -0600
+@@ -35,7 +35,7 @@
+ #include <pthread.h>
+ #include <dlfcn.h>
+ 
+-#if defined(LINUX) || defined(AIX43) || defined(AIX51) || defined(IRIX) || defined(SOLARIS) || defined(HP11)
++#if defined(LINUX) || defined(AIX) || defined(IRIX) || defined(SOLARIS) || defined(HP11)
+ #  include <malloc.h>
+ #endif
+ 
+@@ -90,7 +90,7 @@
+ static dstring Info_Line= DSTRING_INIT;
+ 
+ /* mallinfo related data */
+-#if defined(LINUX) || defined(AIX43) || defined(AIX51) || defined(IRIX) || defined(SOLARIS) || defined(HP11)
++#if defined(LINUX) || defined(AIX) || defined(IRIX) || defined(SOLARIS) || defined(HP11)
+ static bool mallinfo_initialized = false;
+ static void *mallinfo_shlib_handle = NULL;
+ static struct mallinfo (*mallinfo_func_pointer)(void) = NULL;
+@@ -166,7 +166,7 @@
+    monitor->work_line = NULL;
+    monitor->thread_name = NULL;
+ 
+-#if defined(LINUX) || defined(AIX43) || defined(AIX51) || defined(IRIX) || defined(SOLARIS) || defined(HP11)
++#if defined(LINUX) || defined(AIX) || defined(IRIX) || defined(SOLARIS) || defined(HP11)
+    sge_mutex_lock("sge_monitor_status", SGE_FUNC, __LINE__, &global_mutex);
+    if (mallinfo_shlib_handle != NULL) {  
+       dlclose(mallinfo_shlib_handle);
+@@ -211,7 +211,7 @@
+    /*
+     * initialize the mallinfo function pointer if it is available
+     */
+-#if defined(LINUX) || defined(AIX43) || defined(AIX51) || defined(IRIX) || defined(SOLARIS) || defined(HP11)
++#if defined(LINUX) || defined(AIX) || defined(IRIX) || defined(SOLARIS) || defined(HP11)
+    sge_mutex_lock("sge_monitor_status", SGE_FUNC, __LINE__, &global_mutex);
+    if (mallinfo_initialized == false) {
+       const char *function_name = "mallinfo";
+@@ -448,7 +448,7 @@
+       sge_dstring_append(&Info_Line, "\n");
+    }
+ 
+-#if defined(LINUX) || defined(AIX43) || defined(AIX51) || defined(IRIX) || defined(SOLARIS) || defined(HP11)
++#if defined(LINUX) || defined(AIX) || defined(IRIX) || defined(SOLARIS) || defined(HP11)
+    if (mallinfo_func_pointer != NULL) {
+       struct mallinfo mallinfo_data = mallinfo_func_pointer();
+ 
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_os.c gridscheduler-trunk/source/libs/uti/sge_os.c
+--- GE2011.11/source/libs/uti/sge_os.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_os.c	2012-02-08 09:46:02.056113356 -0700
+@@ -436,7 +436,7 @@
+    /* child */
+    SETPGRP;
+ 
+-#if !(defined(__hpux) || defined(CRAY) || defined(WIN32) || defined(SINIX) || defined(INTERIX))
++#if !(defined(__hpux) || defined(CRAY) || defined(WIN32) || defined(SINIX) || defined(INTERIX) || defined(CYGWIN))
+    if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
+       /* disassociate contolling tty */
+       ioctl(fd, TIOCNOTTY, (char *) NULL);
+@@ -579,7 +579,7 @@
+ int sge_daemonize(int *keep_open, unsigned long nr_of_fds, sge_gdi_ctx_class_t *ctx)
+ {
+ 
+-#if !(defined(__hpux) || defined(CRAY) || defined(WIN32) || defined(SINIX) || defined(INTERIX))
++#if !(defined(__hpux) || defined(CRAY) || defined(WIN32) || defined(SINIX) || defined(INTERIX) || defined(CYGWIN))
+    int fd;
+ #endif
+  
+@@ -613,7 +613,7 @@
+  
+    SETPGRP;                      
+  
+-#if !(defined(__hpux) || defined(CRAY) || defined(WIN32) || defined(SINIX) || defined(INTERIX))
++#if !(defined(__hpux) || defined(CRAY) || defined(WIN32) || defined(SINIX) || defined(INTERIX) || defined(CYGWIN))
+    if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
+       /* disassociate contolling tty */
+       ioctl(fd, TIOCNOTTY, (char *) NULL);
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_prog.c gridscheduler-trunk/source/libs/uti/sge_prog.c
+--- GE2011.11/source/libs/uti/sge_prog.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_prog.c	2012-04-17 09:13:36.460336577 -0600
+@@ -663,7 +663,7 @@
+    FREE(s->unqualified_hostname);
+    FREE(s->user_name);
+    FREE(s->default_cell);
+-   sge_free((char*)s);
++   FREE(s);
+ }
+ 
+ /****** uti/prog/prog_state_getspecific() **************************************
+@@ -819,7 +819,6 @@
+       
+    prog_state_destroy((*pst)->sge_prog_state_handle);
+    FREE(*pst);
+-   *pst = NULL;
+ 
+    DEXIT;
+ }
+@@ -885,7 +884,7 @@
+       } else {
+          thiz->set_user_name(thiz, paswd->pw_name);
+       }
+-   }   
++   }
+  
+    /*
+    if (ret) {
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_pty.c gridscheduler-trunk/source/libs/uti/sge_pty.c
+--- GE2011.11/source/libs/uti/sge_pty.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_pty.c	2012-03-21 09:25:09.547954276 -0600
+@@ -55,6 +55,7 @@
+ #  include <stropts.h>
+ #  include <termio.h>
+ #elif defined(FREEBSD) || defined(NETBSD)
++#  include <sys/ioctl.h>
+ #  include <termios.h>
+ #else
+ #  include <termio.h>
+@@ -132,7 +133,7 @@
+ {
+    char *ptr;
+    int  fdm;
+-#if defined(AIX43) || defined(AIX51)
++#if defined(AIX)
+    char default_pts_name[] = "/dev/ptc";
+ #else
+    char default_pts_name[] = "/dev/ptmx";
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_signal.c gridscheduler-trunk/source/libs/uti/sge_signal.c
+--- GE2011.11/source/libs/uti/sge_signal.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_signal.c	2012-02-08 09:46:02.052113498 -0700
+@@ -41,7 +41,7 @@
+ 
+ #include "msg_utilib.h"
+ 
+-#ifdef WIN32
++#if defined(WIN32) || defined(CYGWIN)
+ #   define SIGIOT 6
+ #   define SIGURG 16
+ #   define SIGIO 23
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_stdio.c gridscheduler-trunk/source/libs/uti/sge_stdio.c
+--- GE2011.11/source/libs/uti/sge_stdio.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_stdio.c	2012-04-17 09:13:36.461336541 -0600
+@@ -58,13 +58,6 @@
+ #   include "sge_smf.h"
+ #endif
+ 
+-#ifdef NO_SGE_COMPILE_DEBUG
+-#   undef SGE_EXIT
+-#   define SGE_EXIT(x)     exit(x)
+-#endif
+- 
+-static void addenv(char *, char *);
+- 
+ static void addenv(char *key, char *value)
+ {
+    char *str;
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_uidgid.c gridscheduler-trunk/source/libs/uti/sge_uidgid.c
+--- GE2011.11/source/libs/uti/sge_uidgid.c	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_uidgid.c	2012-02-08 09:46:02.070112874 -0700
+@@ -1174,17 +1174,21 @@
+    gid_t *list;
+    int groups;
+ 
+-   if(err_str != NULL) {
++   if (err_str != NULL)
++   {
+       err_str[0] = 0;
+    }
+ 
+-   if (add_grp_id == 0) {
++   if (add_grp_id == 0)
++   {
+       return 0;
+    }
+ 
+    max_groups = sge_sysconf(SGE_SYSCONF_NGROUPS_MAX);
+-   if (max_groups <= 0) {
+-      if(err_str != NULL) {
++   if (max_groups <= 0)
++   {
++      if(err_str != NULL)
++      {
+          sprintf(err_str, MSG_SYSTEM_ADDGROUPIDFORSGEFAILED_UUS, sge_u32c(getuid()), 
+                  sge_u32c(geteuid()), MSG_SYSTEM_INVALID_NGROUPS_MAX);
+       }
+@@ -1200,46 +1204,67 @@
+ #else
+    list = (gid_t*) malloc(max_groups*sizeof(gid_t));
+ #endif
+-   if (list == NULL) {
+-      if(err_str != NULL) {
++   if (list == NULL)
++   {
++      if (err_str != NULL)
++      {
+          int error = errno;
+-         sprintf(err_str, MSG_SYSTEM_ADDGROUPIDFORSGEFAILED_UUS, sge_u32c(getuid()), 
+-                 sge_u32c(geteuid()), strerror(error));
++         sprintf(err_str, MSG_SYSTEM_ADDGROUPIDFORSGEFAILED_UUS, sge_u32c(getuid()), sge_u32c(geteuid()), strerror(error));
+       }
+       return -1;
+    }
+  
+    groups = getgroups(max_groups, list);
+-   if (groups == -1) {
+-      if(err_str != NULL) {
++   if (groups == -1)
++   {
++      if (err_str != NULL)
++      {
+          int error = errno;
+-         sprintf(err_str, MSG_SYSTEM_ADDGROUPIDFORSGEFAILED_UUS, sge_u32c(getuid()), 
+-                 sge_u32c(geteuid()), strerror(error));
++         sprintf(err_str, MSG_SYSTEM_ADDGROUPIDFORSGEFAILED_UUS, sge_u32c(getuid()), sge_u32c(geteuid()), strerror(error));
+       }
+       free(list);
+       return -1;
+    }   
+ #if !defined(INTERIX)
+-   if (groups < max_groups) {
++   if (groups < max_groups)
++   {
+       list[groups] = add_grp_id;
+       groups++;
+       groups = setgroups(groups, list);
+-      if (groups == -1) {
+-         if(err_str != NULL) {
++      if (groups == -1)
++      {
++         if (err_str != NULL)
++         {
+             int error = errno;
+-            sprintf(err_str, MSG_SYSTEM_ADDGROUPIDFORSGEFAILED_UUS, sge_u32c(getuid()), 
+-                    sge_u32c(geteuid()), strerror(error));
++            sprintf(err_str, MSG_SYSTEM_ADDGROUPIDFORSGEFAILED_UUS, sge_u32c(getuid()), sge_u32c(geteuid()), strerror(error));
+          }
+          free(list);
+          return -1;
+       }
+-   } else {
+-      if(err_str != NULL) {
+-         sprintf(err_str, MSG_SYSTEM_ADDGROUPIDFORSGEFAILED_UUS, sge_u32c(getuid()), 
+-                 sge_u32c(geteuid()), MSG_SYSTEM_USER_HAS_TOO_MANY_GIDS);
++   }
++   else
++   {
++#if defined(DARWIN)
++      list[max_groups-1] = add_grp_id;
++
++      if (setgroups(max_groups, list) == -1)
++      {
++         if (err_str != NULL)
++         {
++            int error = errno;
++            sprintf(err_str, MSG_SYSTEM_ADDGROUPIDFORSGEFAILED_UUS, sge_u32c(getuid()), sge_u32c(geteuid()), strerror(error));
++         }
++         free(list);
++         return -1;
++      }
++#else
++      if (err_str != NULL)
++      {
++         sprintf(err_str, MSG_SYSTEM_ADDGROUPIDFORSGEFAILED_UUS, sge_u32c(getuid()), sge_u32c(geteuid()), MSG_SYSTEM_USER_HAS_TOO_MANY_GIDS);
+       }
+       free(list);
+       return -1;
++#endif
+    }                      
+ #endif
+    free(list);
+diff -ruN --exclude .svn GE2011.11/source/libs/uti/sge_unistd.h gridscheduler-trunk/source/libs/uti/sge_unistd.h
+--- GE2011.11/source/libs/uti/sge_unistd.h	2011-11-14 12:00:47.000000000 -0700
++++ gridscheduler-trunk/source/libs/uti/sge_unistd.h	2012-02-08 09:46:02.051113532 -0700
+@@ -44,7 +44,7 @@
+ #  include "../wingrid/wingrid.h"
+ #endif
+ 
+-#if defined(SOLARIS) || defined(LINUX) || defined(IRIX)
++#if defined(SOLARIS) || defined(LINUX_NATIVE) || defined(IRIX)
+ #  define SGE_OPEN2(filename, oflag)       open64(filename, oflag)
+ #  define SGE_OPEN3(filename, oflag, mode) open64(filename, oflag, mode)
+ #else
+@@ -89,7 +89,7 @@
+ #  define SGE_OFF_T off_t
+ #endif                
+ 
+-#if defined(IRIX) || defined(SOLARIS) || defined(LINUX)
++#if defined(SOLARIS) || defined(LINUX_NATIVE) || defined(IRIX)
+ #  define SGE_READDIR(directory) readdir64(directory)
+ #  define SGE_READDIR_R(directory, entry, result) readdir64_r(directory, entry, result)
+ #  define SGE_TELLDIR(directory) telldir64(directory)
+@@ -103,7 +103,7 @@
+ #  define SGE_STRUCT_DIRENT struct dirent
+ #endif       
+ 
+-#if defined(_UNICOS) || defined(SOLARIS) || defined(__hpux) || defined(LINUX) || defined(AIX) || defined(SINIX) || defined(NECSX4) || defined(NECSX5) || defined(DARWIN9) || defined(DARWIN10)
++#if defined(_UNICOS) || defined(SOLARIS) || defined(__hpux) || defined(LINUX) || defined(AIX) || defined(SINIX) || defined(NECSX4) || defined(NECSX5) || defined(DARWIN9)
+ #   define SETPGRP setpgrp()
+ #elif defined(__sgi)
+ #   define SETPGRP BSDsetpgrp(getpid(),getpid())
+diff -ruN --exclude .svn GE2011.11/source/scripts/compilearch gridscheduler-trunk/source/scripts/compilearch
+--- GE2011.11/source/scripts/compilearch	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/scripts/compilearch	2012-02-08 09:46:01.436134714 -0700
+@@ -117,10 +117,18 @@
+       BUILDARCH=UNICOS_TS_IEEE
+       TARGET_BITS=TARGET_32BIT
+       ;;
++   cygwin-x86)
++      BUILDARCH=CYGWIN_X86
++      TARGET_BITS=TARGET_32BIT
++      ;;
+    darwin-x86)
+       BUILDARCH=DARWIN_X86
+       TARGET_BITS=TARGET_32BIT
+       ;;
++   darwin-x64)
++      BUILDARCH=DARWIN_X64
++      TARGET_BITS=TARGET_64BIT
++      ;;
+    darwin-ppc)
+       BUILDARCH=DARWIN_PPC
+       TARGET_BITS=TARGET_32BIT
+diff -ruN --exclude .svn GE2011.11/source/scripts/distinst gridscheduler-trunk/source/scripts/distinst
+--- GE2011.11/source/scripts/distinst	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/scripts/distinst	2012-04-17 09:13:36.284342893 -0600
+@@ -146,6 +146,7 @@
+    echo "       -resetprog     = set ARCH="" (useful to override distinst.privat)"
+    echo "       -tcc           = create file .COMMON_CHANGED if common changed"
+    echo "       -v             = more verbose"
++   echo "       -y             = automatically accept all prompts"
+    echo "       -vdir <dir>    = define version directory for distribution"
+    echo "<other progs>:"
+    echo "       \"arco\"       = ARCo files (dbwriter, reporting)"
+@@ -235,6 +236,7 @@
+    echo "necsx6                NECSX 6.x"
+    echo "darwin-ppc            MacOS 10.x PowerPC"
+    echo "darwin-x86            MacOS 10.x x86"
++   echo "darwin-x64            MacOS 10.x x86-64"
+    echo "fbsd-alpha            Alpha FreeBSD"
+    echo "fbsd-amd64            AMD64 FreeBSD"
+    echo "fbsd-i386             x86 FreeBSD"
+@@ -430,6 +432,7 @@
+ instarco=false
+ instguiinst=true
+ instsgeinspect=false
++accept_prompts=false
+ enforce_shlibpath=false
+ 
+ cmdname=`basename $0`
+@@ -564,6 +567,9 @@
+    -v)
+       verbose=true
+       ;;
++   -y)
++      accept_prompts=true
++      ;;
+    -vdir)
+       shift
+       if [ "$1" != "" ]; then
+@@ -682,16 +688,18 @@
+ echo   "    Installing:" $PROG
+ echo   " Architectures:" $ARCH
+ echo   "Base directory:" $DEST_SGE_ROOT
+-printf "   OK [Y/N][Y]: "
+ 
+-read ans
+-if [ "$ans" = y -o "$ans" = Y -o "$ans" = "" ]; then
+-   :
+-else
+-   echo
+-   echo Ciao
+-   echo
+-   exit 1
++if [ $accept_prompts = false ]; then
++   printf "   OK [Y/N][Y]: "
++   read ans
++   if [ "$ans" = y -o "$ans" = Y -o "$ans" = "" ]; then
++      :
++   else
++      echo
++      echo Ciao
++      echo
++      exit 1
++   fi
+ fi
+ 
+ echo
+@@ -862,10 +870,6 @@
+       Execute rm -rf $DEST_SGE_ROOT/util/update_commands
+       Execute rm -f $DEST_SGE_ROOT/util/sge_update.sh
+ 
+-      # Install arch.dist as arch for installation process
+-      # Execute rm -f $DEST_SGE_ROOT/util/arch
+-      # Execute mv $DEST_SGE_ROOT/util/arch.dist $DEST_SGE_ROOT/util/arch
+-
+       Execute chmod 755 $DEST_SGE_ROOT/util/install_modules \
+ 			$DEST_SGE_ROOT/util/upgrade_modules \
+                         $DEST_SGE_ROOT/util/rctemplates \
+@@ -1539,7 +1543,7 @@
+ 
+                if [ $DSTARCH = tru64 ]; then
+                   libname="$lib.$shlibext"
+-               elif [ $DSTARCH = darwin-ppc -o $DSTARCH = darwin-x86 ];  then
++               elif [ $DSTARCH = darwin-ppc -o $DSTARCH = darwin-x86 -o $DSTARCH = darwin-x64 ];  then
+                   libname="$lib.$OPENSSLSOVERSION.$shlibext"
+                else
+                   libname="$lib.$shlibext.$OPENSSLSOVERSION"
+@@ -1555,7 +1559,7 @@
+                   InstallProg $libname
+                   if [ $DSTARCH = tru64 ]; then
+                      :
+-                  elif [ $DSTARCH = darwin-ppc -o $DSTARCH = darwin-x86 ]; then
++                  elif [ $DSTARCH = darwin-ppc -o $DSTARCH = darwin-x86 -o $DSTARCH = darwin-x64 ]; then
+                      (cd $DEST_SGE_ROOT/${UTILPREFIX}/$DSTARCH; \
+                       ln -s $lib.$OPENSSLSOVERSION.$shlibext $lib.$shlibext)
+                   else
+diff -ruN --exclude .svn GE2011.11/source/scripts/test_spooling_performance.sh gridscheduler-trunk/source/scripts/test_spooling_performance.sh
+--- GE2011.11/source/scripts/test_spooling_performance.sh	2011-11-14 12:00:44.000000000 -0700
++++ gridscheduler-trunk/source/scripts/test_spooling_performance.sh	2012-04-17 09:13:36.286342821 -0600
+@@ -272,10 +272,9 @@
+       DSTARCH=$i
+       SetArchBin $i
+ 
+-      # Install arch.dist as arch for installation process
+       Execute rm -rf $SPOOLDIR/util
+       Execute mkdir -p $SPOOLDIR/util
+-      Execute cp dist/util/arch.dist $SPOOLDIR/util/arch
++      Execute cp dist/util/arch $SPOOLDIR/util/arch
+ 
+       # Install this script
+       sed '/\_\_\_CREATEDIST_MARK_START/,/\_\_\_CREATEDIST_MARK_END/d' scripts/test_spooling_performance.sh > $SPOOLDIR/test_spooling_performance.sh
+@@ -338,12 +337,13 @@
+    done
+ else
+ #___CREATEDIST_MARK_END
+-   echo "spooling in $SPOOLDIR"
+-   if [ ! -d $SPOOLDIR ]; then
+-      echo "$SPOOLDIR does not exists"
++   if [ ! -d "$SPOOLDIR" ]; then
++      echo "SPOOLDIR ($SPOOLDIR) does not exist"
+       exit 1
+    fi
+ 
++   echo "spooling in $SPOOLDIR"
++
+    if [ -f util/arch ]; then
+       ARCH=`util/arch`
+       ARCHBIN=bin/${ARCH}
+diff -ruN --exclude .svn GE2011.11/source/utilbin/authuser.c gridscheduler-trunk/source/utilbin/authuser.c
+--- GE2011.11/source/utilbin/authuser.c	2011-11-14 12:00:55.000000000 -0700
++++ gridscheduler-trunk/source/utilbin/authuser.c	2012-03-21 09:25:09.849943527 -0600
+@@ -72,13 +72,13 @@
+ #include <security/pam_appl.h>
+ #endif
+ 
+-#if defined(DARWIN) || defined(AIX51) || defined(AIX43) || defined(INTERIX) || defined(FREEBSD) || defined(ALPHA5) || defined(WINDOWS) || defined(NETBSD)
++#if defined(DARWIN) || defined(AIX) || defined(INTERIX) || defined(FREEBSD) || defined(ALPHA5) || defined(WINDOWS) || defined(NETBSD)
+ #define JUTI_NO_SHADOW
+ #else
+ #include <shadow.h>
+ #endif
+ 
+-#if defined(AIX51) || defined(AIX43)
++#if defined(AIX)
+ #include <userpw.h>
+ #endif
+ 
+@@ -595,7 +595,7 @@
+ static auth_result_t get_crypted_password(const char* username, char* buffer, size_t size,
+                                 error_handler_t *error_handler) {
+                      
+-#if defined(AIX43) || defined(AIX51)
++#if defined(AIX)
+ #define BUFSIZE 1024
+    char buf[BUFSIZE];
+    struct userpw *pw = NULL;
+diff -ruN --exclude .svn GE2011.11/source/utilbin/infotext.c gridscheduler-trunk/source/utilbin/infotext.c
+--- GE2011.11/source/utilbin/infotext.c	2011-11-14 12:00:55.000000000 -0700
++++ gridscheduler-trunk/source/utilbin/infotext.c	2012-03-21 09:25:09.847943598 -0600
+@@ -66,7 +66,7 @@
+ static void  sge_infotext_raw(char *format_string);
+ static void  sge_infotext_usage(void);
+ static int   sge_infotext_get_nr_of_substrings(const char* buffer, const char* substring);
+-#if defined(ALPHA) || defined(SOLARISAMD64) || defined(ALPHA5) || defined(ALINUX) || defined(HPUX) || __GNUC__ >= 3 || defined(NETBSD)
++#if defined(ALPHA) || defined(SOLARISAMD64) || defined(ALPHA5) || defined(HPUX) || defined(NETBSD) || __GNUC__ >= 3
+ static char *sge_infotext_string_replace(dstring* buf, const char *arg, const char *what, const char *with, int only_first );
+ #endif
+ static char* sge_infotext_string_input_parsing(dstring* buf,char* string);
+@@ -547,7 +547,7 @@
+ }
+ 
+ 
+-#if defined(ALPHA) || defined(SOLARISAMD64) || defined(ALPHA5) || defined(ALINUX) || defined(HPUX) || defined(IRIX65) || __GNUC__ >= 3 || defined(NETBSD)
++#if defined(ALPHA) || defined(SOLARISAMD64) || defined(ALPHA5) || defined(HPUX) || defined(IRIX65) || defined(NETBSD) || __GNUC__ >= 3
+ static char *sge_infotext_string_replace(dstring* tmp_buf, const char *arg, const char *what, const char *with, int only_first) {
+    int i;
+    char *p1;
+@@ -1052,7 +1052,7 @@
+    DPRINTF(("pass 4\n"));
+    {
+       if (real_args > 0) {
+-#if defined(SOLARISAMD64) || defined(ALPHA) || defined(ALPHA5) || defined(ALINUX) || defined(HPUX) || defined(IRIX65) || __GNUC__ >= 3 || defined(NETBSD)
++#if defined(SOLARISAMD64) || defined(ALPHA) || defined(ALPHA5) || defined(HPUX) || defined(IRIX65) || defined(NETBSD) || __GNUC__ >= 3
+       for(i=0;i<real_args;i++) {
+ /*      printf("argument[%d]: \"%s\"\n",i,argv[first_arg +i]); */
+          sge_dstring_copy_string(&buffer, sge_infotext_string_replace(&tmp_buf, (char*)sge_dstring_get_string(&buffer2),"%s",argv[first_arg +i],1));
diff --git a/gridengine.spec b/gridengine.spec
index 9b1675b..cc2e0b9 100644
--- a/gridengine.spec
+++ b/gridengine.spec
@@ -6,7 +6,7 @@
 
 Name:    gridengine
 Version: 2011.11
-Release: 1.svn115%{?dist}
+Release: 2.svn131%{?dist}
 Summary: Grid Engine - Distributed Computing Management software
 
 Group:   Applications/System
@@ -36,10 +36,9 @@ Source9: gridengine.sysconfig
 Source10: http://gridengine.sunsource.net/nonav/issues/showattachment.cgi/165/libcore.c
 Source11: README
 Source12: maketarball
-Patch0: gridengine-svn.patch
-# Link ssl libraries dynamically so dependencies are pulled in
-# http://gridengine.sunsource.net/issues/show_bug.cgi?id=2845
-Patch1: gridengine-ssl.patch
+Patch0: gridengine-svn131.patch
+# Upstream security patch
+Patch1: env-code-injection-GE2011.11p1.patch
 # Don't need to make rc files in inst_common.sh
 # Partially http://gridengine.sunsource.net/issues/show_bug.cgi?id=2780
 Patch3: gridengine-rctemplates.patch
@@ -175,6 +174,7 @@ cp %SOURCE8 %SOURCE11 .
 #Remove unneeded shbangs
 sed -i -e '/^#! *\/bin\/sh/d' source/dist/util/install_modules/*.sh
 %patch0 -p1 -b .svn
+%patch1 -p0 -b .env-code-injection
 %patch3 -p1 -b .rctemplates
 %patch4 -p1 -b .sge_ca
 %patch5 -p1 -b .jni
@@ -628,6 +628,10 @@ fi
 
 
 %changelog
+* Tue Apr 17 2012 Orion Poplawski <orion at cora.nwra.com> 2011.11-2.svn131
+- Update to svn 131
+- Add upstream env-code-injection security patch
+
 * Wed Mar 21 2012 Orion Poplawski <orion at cora.nwra.com> 2011.11-1.svn115
 - Update to svn 115
 - Add back SysV init script handling for EL builds


More information about the scm-commits mailing list