diff -ru --new-file --exclude=CVS --exclude=configure --exclude=linux --exclude=autom4te-2.53.cache --exclude=config.h.in --exclude='config.h.in~' ../openssh-gssapi/Makefile.in ./Makefile.in
--- ../openssh-gssapi/Makefile.in	2003-08-22 23:02:12.000000000 +1000
+++ ./Makefile.in	2003-08-23 00:36:40.000000000 +1000
@@ -68,7 +68,7 @@
 	key.o dispatch.o kex.o mac.o uuencode.o misc.o \
 	rijndael.o ssh-dss.o ssh-rsa.o dh.o kexdh.o kexgex.o \
 	kexdhc.o kexgexc.o scard.o msg.o progressmeter.o dns.o \
-	entropy.o scard-opensc.o 
+	entropy.o scard-opensc.o gss-genr.o
 
 SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
 	sshconnect.o sshconnect1.o sshconnect2.o
@@ -82,6 +82,7 @@
 	monitor_mm.o monitor.o monitor_wrap.o monitor_fdpass.o \
 	kexdhs.o kexgexs.o \
 	auth-krb5.o auth2-krb5.o \
+	auth2-gss.o gss-serv.o gss-serv-krb5.o \
 	loginrec.o auth-pam.o auth-sia.o md5crypt.o
 
 MANPAGES	= scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-rand-helper.8.out ssh-keysign.8.out sshd_config.5.out ssh_config.5.out
diff -ru --new-file --exclude=CVS --exclude=configure --exclude=linux --exclude=autom4te-2.53.cache --exclude=config.h.in --exclude='config.h.in~' ../openssh-gssapi/acconfig.h ./acconfig.h
--- ../openssh-gssapi/acconfig.h	2003-08-22 23:02:12.000000000 +1000
+++ ./acconfig.h	2003-08-22 22:47:16.000000000 +1000
@@ -232,6 +232,9 @@
 /* Define if compiler implements __func__ */
 #undef HAVE___func__
 
+/* Define this is you want GSSAPI support in the version 2 protocol */
+#undef GSSAPI
+
 /* Define if you want Kerberos 5 support */
 #undef KRB5
 
diff -ru --new-file --exclude=CVS --exclude=configure --exclude=linux --exclude=autom4te-2.53.cache --exclude=config.h.in --exclude='config.h.in~' ../openssh-gssapi/configure.ac ./configure.ac
--- ../openssh-gssapi/configure.ac	2003-08-21 18:01:42.000000000 +1000
+++ ./configure.ac	2003-08-23 00:11:10.000000000 +1000
@@ -822,6 +822,7 @@
 			AC_CHECK_LIB(dl, dlopen, , )
 			AC_CHECK_LIB(pam, pam_set_item, , AC_MSG_ERROR([*** libpam missing]))
 			AC_CHECK_FUNCS(pam_getenvlist)
+			AC_CHECK_FUNCS(pam_putenv)
 
 			disable_shadow=yes
 			PAM_MSG="yes"
@@ -1937,6 +1938,31 @@
                         fi
 			AC_SEARCH_LIBS(dn_expand, resolv)
 
+			AC_CHECK_LIB(gssapi,gss_init_sec_context,
+				[ AC_DEFINE(GSSAPI)
+				  K5LIBS="-lgssapi $K5LIBS" ],
+				[ AC_CHECK_LIB(gssapi_krb5,gss_init_sec_context,
+					[ AC_DEFINE(GSSAPI)
+				  	  K5LIBS="-lgssapi_krb5 $K5LIBS" ],
+					AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]),
+					$K5LIBS)
+				],
+				$K5LIBS)
+			
+			AC_CHECK_HEADER(gssapi.h, ,
+				[ unset ac_cv_header_gssapi_h
+				  CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi" 
+				  AC_CHECK_HEADERS(gssapi.h, ,
+					AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
+				  ) 
+				]
+			)
+
+			oldCPP="$CPPFLAGS"
+			CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
+			AC_CHECK_HEADER(gssapi_krb5.h, ,
+					[ CPPFLAGS="$oldCPP" ])
+
                         KRB5=yes
                 fi
         ]
diff -ru --new-file --exclude=CVS --exclude=configure --exclude=linux --exclude=autom4te-2.53.cache --exclude=config.h.in --exclude='config.h.in~' ../openssh-gssapi/contrib/makegssname.pl ./contrib/makegssname.pl
--- ../openssh-gssapi/contrib/makegssname.pl	1970-01-01 10:00:00.000000000 +1000
+++ ./contrib/makegssname.pl	2003-08-22 23:06:23.000000000 +1000
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+
+use Convert::ASN1 qw(:tag);
+use Digest::MD5 qw(md5);
+use MIME::Base64;
+use Data::Dumper;
+ 
+$oid=shift;
+my $asn=Convert::ASN1->new;
+$asn->prepare("oid OBJECT IDENTIFIER");
+$encoded=$asn->encode(oid => $oid);
+Convert::ASN1::asn_dump($encoded);
+print Dumper($asn->decode($encoded));
+
+@entries=unpack("C*",$encoded);
+
+print "DER representation: ";
+foreach $entry (@entries) {
+  print "\\x";
+  printf "%02X",$entry;
+}
+print "\n";
+
+$digest = md5($encoded);
+# We only want the first 10 characters;
+# Conversations with the authors suggest that we want to use all of the
+# characters of the digest.
+#$digest = substr($digest,0,10);
+print "gsskeyex representation: ",encode_base64($digest),"\n";
+
+sub encode_object_id {
+  $string="";
+
+  my @data = ($_[0] =~ /(\d+)/g);
+
+  if(@data < 2) {
+      @data = (0);
+  }
+  else {
+      my $first = $data[1] + ($data[0] * 40);
+      splice(@data,0,2,$first);
+  }
+
+#  my $l = length $string;
+  $string .= pack("cw*", 0, @data);
+#  substr($string,$l,1) = asn_encode_length(length($string) - $l - 1);
+  return $string;
+}
+
+
diff -ru --new-file --exclude=CVS --exclude=configure --exclude=linux --exclude=autom4te-2.53.cache --exclude=config.h.in --exclude='config.h.in~' ../openssh-gssapi/ssh-gss.h ./ssh-gss.h
--- ../openssh-gssapi/ssh-gss.h	2003-08-22 22:34:31.000000000 +1000
+++ ./ssh-gss.h	2003-08-22 23:53:59.000000000 +1000
@@ -31,6 +31,18 @@
 
 #include <gssapi.h>
 
+#ifdef KRB5
+#ifndef HEIMDAL
+#include <gssapi_generic.h>
+
+/* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */
+/* It seems to be defined in gssapi_krb5.h -dtucker */
+#ifndef GSS_C_NT_HOSTBASED_SERVICE
+#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
+#endif /* GSS_C_NT_... */
+#endif /* !HEIMDAL */
+#endif /* KRB5 */
+
 /* draft-ietf-secsh-gsskeyex-06 */
 #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE		60
 #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN			61
