]> andersk Git - gssapi-openssh.git/commitdiff
o Merge from OPENSSH_3_4P1_GSI_20020701 to OPENSSH_3_4P1_GSI_20020923.
authorcphillip <cphillip>
Mon, 23 Sep 2002 19:32:59 +0000 (19:32 +0000)
committercphillip <cphillip>
Mon, 23 Sep 2002 19:32:59 +0000 (19:32 +0000)
  o Repair conflicts in configure.ac.

22 files changed:
openssh/Makefile.in
openssh/acconfig.h
openssh/auth.c
openssh/auth1.c
openssh/auth2-gss.c
openssh/auth2.c
openssh/canohost.c
openssh/canohost.h
openssh/configure.ac
openssh/gss-genr.c
openssh/gss-serv.c
openssh/kexgss.c
openssh/monitor.c
openssh/msg.c
openssh/openbsd-compat/bsd-misc.h
openssh/pkg_data_src.gpt
openssh/readconf.h
openssh/servconf.c
openssh/ssh-gss.h
openssh/sshconnect1.c
openssh/sshconnect2.c
openssh/sshd_config.5

index 8f0f95c1017acec1e261f0da75c31c66aae41893..b63c20b6d1753f27a4228b8b789d31ba1f275639 100644 (file)
@@ -49,6 +49,7 @@ EXEEXT=@EXEEXT@
 
 INSTALL_SSH_PRNG_CMDS=@INSTALL_SSH_PRNG_CMDS@
 INSTALL_SSH_RAND_HELPER=@INSTALL_SSH_RAND_HELPER@
+INSTALL_GSISSH=@INSTALL_GSISSH@
 
 @NO_SFTP@SFTP_PROGS=sftp-server$(EXEEXT) sftp$(EXEEXT)
 
@@ -250,14 +251,16 @@ install-files: scard-install
        ln -s ssh$(EXEEXT) $(DESTDIR)$(bindir)/slogin
        -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
        ln -s ssh.1 $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
-       -rm -f $(DESTDIR)$(bindir)/gsissh
-       ln -s ssh$(EXEEXT) $(DESTDIR)$(bindir)/gsissh
-       -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/gsissh.1
-       ln -s ssh.1 $(DESTDIR)$(mandir)/$(mansubdir)1/gsissh.1
-       -rm -f $(DESTDIR)$(bindir)/gsiscp
-       ln -s scp$(EXEEXT) $(DESTDIR)$(bindir)/gsiscp
-       -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/gsiscp.1
-       ln -s scp.1 $(DESTDIR)$(mandir)/$(mansubdir)1/gsiscp.1
+       if [ ! -z "$(INSTALL_GSISSH)" ]; then \
+               rm -f $(DESTDIR)$(bindir)/gsissh; \
+               ln -s ssh$(EXEEXT) $(DESTDIR)$(bindir)/gsissh; \
+               rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/gsissh.1; \
+               ln -s ssh.1 $(DESTDIR)$(mandir)/$(mansubdir)1/gsissh.1; \
+               rm -f $(DESTDIR)$(bindir)/gsiscp; \
+               ln -s scp$(EXEEXT) $(DESTDIR)$(bindir)/gsiscp; \
+               rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/gsiscp.1; \
+               ln -s scp.1 $(DESTDIR)$(mandir)/$(mansubdir)1/gsiscp.1; \
+       fi
        if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \
                $(srcdir)/mkinstalldirs $(DESTDIR)$(sysconfdir); \
        fi
@@ -381,8 +384,10 @@ uninstallall:      uninstall
 
 uninstall: 
        -rm -f $(DESTDIR)$(bindir)/slogin
-       -rm -f $(DESTDIR)$(bindir)/gsiscp
-       -rm -f $(DESTDIR)$(bindir)/gsissh
+       if [ ! -z "$(INSTALL_GSISSH)" ]; then \
+               rm -f $(DESTDIR)$(bindir)/gsiscp; \
+               rm -f $(DESTDIR)$(bindir)/gsissh; \
+       fi
        -rm -f $(DESTDIR)$(bindir)/ssh$(EXEEXT)
        -rm -f $(DESTDIR)$(bindir)/scp$(EXEEXT)
        -rm -f $(DESTDIR)$(bindir)/ssh-add$(EXEEXT)
@@ -396,8 +401,10 @@ uninstall:
        -rm -f $(DESTDIR)$(RAND_HELPER)$(EXEEXT)
        -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh.1
        -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/scp.1
-       -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/gsissh.1
-       -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/gsiscp.1
+       if [ ! -z "$(INSTALL_GSISSH)" ]; then \
+               rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/gsissh.1; \
+               rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/gsiscp.1; \
+       fi
        -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-add.1
        -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-agent.1
        -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keygen.1
index 3564029d5f7a318fad695aa26912d8cd3be80532..0353314dd8dfe64f78f26f73306fe4164c64f9d7 100644 (file)
 /* Define if compiler implements __func__ */
 #undef HAVE___func__
 
+/* Define this if you're building with GSSAPI MechGlue */
+#undef MECHGLUE
+
 /* Define this is you want GSSAPI support in the version 2 protocol */
 #undef GSSAPI
 
index 066b50d6ba1dcc132182cd8d57c166988242ffab..45855d4083f5437d0c31dbe14e0ac6d965987c3b 100644 (file)
@@ -252,7 +252,7 @@ auth_log(Authctxt *authctxt, int authenticated, char *method, char *info)
            authmsg,
            method,
            authctxt->valid ? "" : "illegal user ",
-           authctxt->user,
+           (authctxt->user[0]) ? authctxt->user : "<implicit>",
            get_remote_ipaddr(),
            get_remote_port(),
            info);
index a5b267027e2dee52a509a85319a36ae7e9571c99..39145cb78bff10b6bcc9a5567922afb2de226cab 100644 (file)
@@ -59,11 +59,13 @@ auth1_gss_protocol_error(int type, u_int32_t plen, void *ctxt)
           "Unknown packet type %d", type);
 }
 
+#ifdef GSI
 int
 gsi_gridmap(char *subject_name, char **mapped_name)
 {
     return(globus_gss_assist_gridmap(subject_name, mapped_name) == 0);
 }
+#endif
 
 /*
  * SSH1 GSSAPI clients may send us a user name of the form:
index a67b9ebdf2d4c2682dc53ea95ebbafa0014ae833..597b61404213f3a1b9aa087c32423a85b999b5cd 100644 (file)
@@ -129,12 +129,14 @@ input_gssapi_token(int type, u_int32_t plen, void *ctxt)
         Gssctxt *gssctxt;
         gss_buffer_desc send_tok,recv_tok;
         OM_uint32 maj_status, min_status;
+       int len;
         
         if (authctxt == NULL || (authctxt->methoddata == NULL && !use_privsep))
                 fatal("No authentication or GSSAPI context");
                 
         gssctxt=authctxt->methoddata;
-        recv_tok.value=packet_get_string(&recv_tok.length);
+        recv_tok.value=packet_get_string(&len);
+       recv_tok.length=len; /* int vs. size_t */
         
         maj_status=PRIVSEP(ssh_gssapi_accept_ctx(gssctxt, &recv_tok, 
                                                 &send_tok, NULL));
@@ -188,6 +190,28 @@ input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt)
        if (authctxt == NULL || (authctxt->methoddata == NULL && !use_privsep))
                 fatal("No authentication or GSSAPI context");
                 
+       if ((strcmp(authctxt->user, "") == 0) && (authctxt->pw == NULL)) {
+           char *lname = NULL;
+           PRIVSEP(ssh_gssapi_localname(&lname));
+           if (lname && lname[0] != '\0') {
+               xfree(authctxt->user);
+               authctxt->user = lname;
+               debug("set username to %s from gssapi context", lname);
+               authctxt->pw = PRIVSEP(getpwnamallow(authctxt->user));
+           } else {
+               debug("failed to set username from gssapi context");
+           }
+       }
+       if (authctxt->pw) {
+#ifdef USE_PAM
+           PRIVSEP(start_pam(authctxt->pw->pw_name));
+#endif
+       } else {
+           authctxt->valid = 0;
+           authenticated = 0;
+           goto finish;
+       }
+
         gssctxt=authctxt->methoddata;
 
        /* ssh1 needs to exchange the hash of the keys */
@@ -219,6 +243,7 @@ input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt)
 
         authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user));
 
+finish:
         authctxt->postponed = 0;
         dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);
         dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE, NULL);
index 3309d74a92a549fa6882cf6b5ec3765867e78b4e..57742536686b512b23c6b08566b4cb96c4d957c8 100644 (file)
@@ -36,7 +36,6 @@ RCSID("$OpenBSD: auth2.c,v 1.93 2002/05/31 11:35:15 markus Exp $");
 #include "dispatch.h"
 #include "pathnames.h"
 #include "monitor_wrap.h"
-#include "misc.h"
 
 #ifdef GSSAPI
 #include "ssh-gss.h"
@@ -161,26 +160,29 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
 
 #ifdef GSSAPI
        if (strcmp(user, "") == 0) {
-           char *lname = NULL;
-           debug("gssapi received empty username");
-           PRIVSEP(ssh_gssapi_localname(&lname));
-           if (lname && lname[0] != '\0') {
-               xfree(user);
-               user = lname;
-               debug("gssapi successfully set username to %s", user);
-           } else if (authctxt->valid) {
-               debug("failed to set username from gssapi context");
-               goto finish;
+           debug("received empty username for %s", method);
+           if (strcmp(method, "external-keyx") == 0) {
+               char *lname = NULL;
+               PRIVSEP(ssh_gssapi_localname(&lname));
+               if (lname && lname[0] != '\0') {
+                   xfree(user);
+                   user = lname;
+                   debug("set username to %s from gssapi context", user);
+               } else if (authctxt->valid) {
+                   debug("failed to set username from gssapi context");
+               }
            }
        }
 #endif
 
-       debug("userauth-request for user %s service %s method %s", user, service, method);
+       debug("userauth-request for user %s service %s method %s",
+             (user && user[0]) ? user : "<implicit>", service, method);
        debug("attempt %d failures %d", authctxt->attempt, authctxt->failures);
 
        if ((style = strchr(user, ':')) != NULL)
                *style++ = 0;
 
+       authctxt->attempt++;
        if (!authctxt->user ||
            strcmp(user, authctxt->user) != 0) {
                /* setup auth context */
@@ -196,6 +198,16 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
                    xfree(authctxt->style);
                    authctxt->style = NULL;
                }
+#ifdef GSSAPI
+               /* We'll verify the username after we set it from the
+                  GSSAPI context. */
+               if ((strcmp(user, "") == 0) &&
+                   ((strcmp(method, "gssapi") == 0) ||
+                    (strcmp(method, "external-keyx") == 0))) {
+                   authctxt->pw = NULL;
+                   authctxt->valid = 1;
+               } else {
+#endif
                authctxt->pw = PRIVSEP(getpwnamallow(user));
                if (authctxt->pw && strcmp(service, "ssh-connection")==0) {
                        authctxt->valid = 1;
@@ -210,12 +222,15 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
                        PRIVSEP(start_pam("NOUSER"));
 #endif
                }
+#ifdef GSSAPI
+               }
+#endif
                setproctitle("%s%s", authctxt->pw ? user : "unknown",
                    use_privsep ? " [net]" : "");
                authctxt->user = xstrdup(user);
                authctxt->service = xstrdup(service);
                authctxt->style = style ? xstrdup(style) : NULL;
-               if (use_privsep)
+               if (use_privsep && (authctxt->attempt == 1))
                        mm_inform_authserv(service, style);
        }
        /* reset state */
@@ -234,7 +249,7 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
                debug2("input_userauth_request: try method %s", method);
                authenticated = m->userauth(authctxt);
        }
-finish:
+
        userauth_finish(authctxt, authenticated, method);
 
        xfree(service);
index 00c499ca041fb96cdcc9d3cdece2e90865196ef7..b61c3841ce0397422ecff6ce23d747c3f448a549 100644 (file)
@@ -355,3 +355,75 @@ get_local_port(void)
 {
        return get_port(1);
 }
+
+/* If *host is a name for the loopback interface, try to change
+   it to local hostname (not necessarily fully-qualified). */
+void
+resolve_localhost(char **host)
+{
+    struct hostent *hostinfo;
+
+    hostinfo = gethostbyname(*host);
+    if (hostinfo &&
+       hostinfo->h_addrtype == AF_INET) {
+       struct in_addr addr;
+       addr = *(struct in_addr *)(hostinfo->h_addr);
+       if (ntohl(addr.s_addr) == INADDR_LOOPBACK) {
+           char buf[MAXHOSTNAMELEN];
+           if (gethostname(buf, sizeof(buf)) == 0) {
+               xfree(*host);
+               *host = xstrdup(buf);
+           }
+       }
+    }
+}
+
+/* A (hopefully) portable way to make a fully-qualified hostname for
+   GSSAPI authentication without relying on a potentially remote,
+   untrusted resolver.
+   Note: getdomainname() is not portable.
+*/
+void
+make_fqhn(char **host)
+{
+    char *domainname = NULL, *fqhn = NULL, myhn[MAXHOSTNAMELEN];
+    struct hostent *hent = NULL;
+    int i;
+
+    if (strchr(*host, '.')) {
+       return;                 /* already fully qualified */
+    }
+
+    /* Otherwise, figure out our local domainname without using
+       getdomainname(). */
+    if (gethostname(myhn, sizeof(myhn)) < 0) {
+       debug("gethostname() failed, can't convert %s to fqhn", *host);
+       return;
+    }
+    if ((domainname = strchr(myhn, '.')) == NULL) {
+       
+       /* Resolving our local hostname should be secure
+          (unlike resolving a remote hostname). */
+       if ((hent = gethostbyname(myhn)) != NULL) {
+           if ((domainname = strchr(hent->h_name, '.')) == NULL) {
+               for (i=0;
+                    hent->h_aliases[i] &&
+                        (domainname =
+                         strchr(hent->h_aliases[i], '.')) == NULL;
+                    i++);
+           }
+       }
+    }
+
+    if (domainname) {
+       domainname++;
+       fqhn = xmalloc(strlen(*host)+strlen(domainname)+1);
+       sprintf(fqhn, "%s.%s", *host, domainname);
+       xfree(*host);
+       *host = fqhn;
+       return;
+    }
+
+    debug("unable to determine fully-qualified local hostname");
+    return;
+}
index 4347b488a145a4e192df82e471dc498adaf74b0f..e31e50aaa9632d69b26655139543612c86b6d594 100644 (file)
@@ -23,3 +23,6 @@ char          *get_local_name(int);
 
 int             get_remote_port(void);
 int             get_local_port(void);
+
+void            resolve_localhost(char **host);
+void            make_fqhn(char **host);
index 704697bbe461af1e3dda2fa12ef406da9f65279e..0ae6eef0da8f41c9bcf8ed7478f0590c530a1bb4 100644 (file)
@@ -477,6 +477,43 @@ int main(void){struct dirent d;return(sizeof(d.d_name)<=sizeof(char));}
        ]
 )
 
+# Check whether the user wants GSSAPI mechglue support
+AC_ARG_WITH(mechglue,
+       [  --with-mechglue=PATH    Build with GSSAPI mechglue library],
+       [
+               AC_MSG_CHECKING(for mechglue library)
+
+               if test -e ${withval}/libgssapi.a ; then
+                   mechglue_lib=${withval}/libgssapi.a
+               elif test -e ${withval}/lib/libgssapi.a ; then
+                   mechglue_lib=${withval}/lib/libgssapi.a
+               else
+                   AC_MSG_ERROR("Can't find libgssapi in ${withval}");
+               fi
+               LIBS="$LIBS ${mechglue_lib}"
+               AC_MSG_RESULT(${mechglue_lib})
+
+#              if test -e ${withval}/gssapi.h ; then
+#                  CPPFLAGS="$CPPFLAGS -I${withval}"
+#              elif test -e ${withval}/include/gssapi.h ; then
+#                  CPPFLAGS="$CPPFLAGS -I${withval}/include"
+#              else
+#                  AC_MSG_ERROR("Can't find gssapi.h in ${withval}");
+#              fi
+               
+               AC_CHECK_LIB(dl, dlopen, , )
+               if test $ac_cv_lib_dl_dlopen = yes; then
+                  LDFLAGS="$LDFLAGS -ldl -Wl,-Bsymbolic"
+               fi
+
+               AC_DEFINE(GSSAPI)
+               AC_DEFINE(MECHGLUE)
+               GSSAPI="mechglue"
+
+       ]
+)
+
+
 # Check whether the user wants GSI (Globus) support
 gsi_path="no"
 AC_ARG_WITH(gsi,
@@ -504,9 +541,16 @@ AC_ARG_WITH(globus-flavor,
 
 if test "x$gsi_path" != "xno" ; then
        # Globus GSSAPI configuration
-       AC_DEFINE(GSSAPI)
        AC_DEFINE(GSI)
 
+       if test "$GSSAPI" -a "$GSSAPI" != "mechglue"; then
+               AC_MSG_ERROR([Previously configured GSSAPI library conflicts with Globus/GSI.])
+       fi
+       if test -z "$GSSAPI"; then
+               AC_DEFINE(GSSAPI)
+               GSSAPI="GSI"
+       fi
+
        # Find GLOBUS/GSI installation Directory
        AC_MSG_CHECKING(for Globus/GSI installation directory)
 
@@ -537,15 +581,23 @@ if test "x$gsi_path" != "xno" ; then
                 fi
 
                AC_MSG_RESULT($globus_flavor_type)
-               GSI_LIBS="${gsi_path}/lib/libglobus_gss_assist_${globus_flavor_type}.a ${gsi_path}/lib/libglobus_gssapi_gsi_${globus_flavor_type}.a"
-               GSI_CFLAGS="-I${GLOBUS_FLAVOR_TYPE_INCL_DIR}"
+               if test "$GSSAPI" = "mechglue"; then
+                       GSI_LIBS="${gsi_path}/lib/libglobus_gss_assist_${globus_flavor_type}.a"
+               else
+                       GSI_LIBS="${gsi_path}/lib/libglobus_gss_assist_${globus_flavor_type}.a ${gsi_path}/lib/libglobus_gssapi_gsi_${globus_flavor_type}.a"
+               fi
+               GSI_CPPFLAGS="-I${GLOBUS_FLAVOR_TYPE_INCL_DIR}"
        fi
 
        LIBS="$LIBS $GSI_LIBS"
        LDFLAGS="$LDFLAGS $GSI_LDFLAGS"
-       CFLAGS="$CFLAGS $GSI_CFLAGS"
-# End Globus/GSI section
+       CPPFLAGS="$CPPFLAGS $GSI_CPPFLAGS"
+       INSTALL_GSISSH="yes"
+else
+       INSTALL_GSISSH=""
 fi
+AC_SUBST(INSTALL_GSISSH)
+# End Globus/GSI section
 
 # Check whether user wants S/Key support
 SKEY_MSG="no" 
@@ -1873,6 +1925,10 @@ AC_ARG_WITH(kerberos5,
                         fi
                         AC_CHECK_LIB(resolv, dn_expand, , )
 
+                       # If we're using some other GSSAPI
+                       if test "$GSSAPI" -a "$GSSAPI" != "mechglue"; then
+                               AC_MSG_ERROR([$GSSAPI GSSAPI library conflicts with Kerberos support.  Use mechglue instead.])
+                       fi
                        AC_CHECK_LIB(gssapi,gss_init_sec_context,
                                [ AC_DEFINE(GSSAPI)
                                  K5LIBS="-lgssapi $K5LIBS" ],
@@ -1883,7 +1939,7 @@ AC_ARG_WITH(kerberos5,
                                        $K5LIBS)
                                ],
                                $K5LIBS)
-                       
+               
                        AC_CHECK_HEADER(gssapi.h, ,
                                [ unset ac_cv_header_gssapi_h
                                  CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi" 
@@ -1893,11 +1949,23 @@ AC_ARG_WITH(kerberos5,
                                ]
                        )
 
+                       AC_CHECK_LIB(gssapi, gss_krb5_copy_ccache, /bin/true,
+                               [ K5LIBS="-lgssapi_krb5 $K5LIBS"
+                                 AC_CHECK_LIB(gssapi_krb5, gss_krb5_copy_ccache, /bin/true,
+                                       AC_MSG_WARN([Cannot find gss_krb5_copy_ccache -- build may fail]),
+                                       $K5LIBS)
+                               ],
+                               $K5LIBS)
+
                        oldCPP="$CPPFLAGS"
                        CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
                        AC_CHECK_HEADER(gssapi_krb5.h, ,
                                        [ CPPFLAGS="$oldCPP" ])
 
+                       if test -z "$GSSAPI"; then
+                               GSSAPI="KRB5";
+                       fi
+
                         KRB5=yes
                 fi
         ]
index 511a1830c3405cfaa673f0be5d83f7469a566d92..5e5dc0ed2457aae915b0b9388135a4238c34b59e 100644 (file)
@@ -38,6 +38,7 @@
 #include "log.h"
 #include "compat.h"
 #include "monitor_wrap.h"
+#include "canohost.h"
 
 #include <netdb.h>
 
@@ -103,6 +104,7 @@ ssh_gssapi_mechanisms(int server,char *host) {
        Buffer          buf;
        int             i = 0;
        int             present;
+       int             mech_count=0;
        char *          mechs;
        Gssctxt *       ctx = NULL;     
 
@@ -128,13 +130,25 @@ ssh_gssapi_mechanisms(int server,char *host) {
                                                       &supported_mechs[i].oid,
                                                       host)))) {
                                /* Append gss_group1_sha1_x to our list */
+                               if (++mech_count > 1) {
+                                   buffer_append(&buf, ",", 1);
+                               }
                                buffer_append(&buf, gssprefix,
                                              strlen(gssprefix));
                                buffer_append(&buf, 
                                              supported_mechs[i].enc_name,
                                              strlen(supported_mechs[i].enc_name));
-                      }
-               }
+                               debug("GSSAPI mechanism %s (%s%s) supported",
+                                     supported_mechs[i].name, gssprefix,
+                                     supported_mechs[i].enc_name);
+                       } else {
+                           debug("no credentials for GSSAPI mechanism %s",
+                                 supported_mechs[i].name);
+                       }
+               } else {
+                   debug("GSSAPI mechanism %s not supported",
+                         supported_mechs[i].name);
+               }
        } while (supported_mechs[++i].name != NULL);
        
        buffer_put_char(&buf,'\0');
@@ -196,13 +210,14 @@ void ssh_gssapi_set_oid(Gssctxt *ctx, gss_OID oid) {
 enum ssh_gss_id ssh_gssapi_get_ctype(Gssctxt *ctxt) {
        enum ssh_gss_id i=0;
        
-       while(supported_mechs[i].name!=NULL &&
-               supported_mechs[i].oid.length != ctxt->oid->length &&
-               (memcmp(supported_mechs[i].oid.elements,
-                      ctxt->oid->elements,ctxt->oid->length) !=0)) {
+       while(supported_mechs[i].name!=NULL) {
+          if (supported_mechs[i].oid.length == ctxt->oid->length &&
+              (memcmp(supported_mechs[i].oid.elements,
+                      ctxt->oid->elements,ctxt->oid->length) == 0))
+              return i;
           i++;
        }
-       return(i);
+       return(GSS_LAST_ENTRY);
 }
 
 /* Set the GSS context's OID to the oid indicated by the given key exchange
@@ -226,6 +241,9 @@ gss_OID ssh_gssapi_id_kex(Gssctxt *ctx, char *name) {
 
   if (ctx) ssh_gssapi_set_oid(ctx,&supported_mechs[i].oid);
 
+  debug("using GSSAPI mechanism %s (%s%s)", supported_mechs[i].name,
+       gssprefix, supported_mechs[i].enc_name);
+
   return &supported_mechs[i].oid;
 }
 
@@ -235,7 +253,7 @@ static void
 ssh_gssapi_error_ex(OM_uint32 major_status,OM_uint32 minor_status,
                    int send_packet) {
        OM_uint32 lmaj, lmin;
-        gss_buffer_desc msg;
+        gss_buffer_desc msg = {0,NULL};
         OM_uint32 ctx;
         
         ctx = 0;
@@ -306,6 +324,7 @@ ssh_gssapi_delete_ctx(Gssctxt **ctx)
        if ((*ctx)==NULL)
                return;
                
+#if !defined(MECHGLUE) /* mechglue has some memory management issues */
        if ((*ctx)->context != GSS_C_NO_CONTEXT) 
                gss_delete_sec_context(&ms,&(*ctx)->context,GSS_C_NO_BUFFER);
        if ((*ctx)->name != GSS_C_NO_NAME)
@@ -321,6 +340,7 @@ ssh_gssapi_delete_ctx(Gssctxt **ctx)
                gss_release_name(&ms,&(*ctx)->client);  
        if ((*ctx)->client_creds != GSS_C_NO_CREDENTIAL)
                gss_release_cred(&ms,&(*ctx)->client_creds);
+#endif
        
        xfree(*ctx);
        *ctx=NULL; 
@@ -421,27 +441,22 @@ OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *ctx,gss_buffer_desc *recv_tok,
 /* Create a service name for the given host */
 OM_uint32
 ssh_gssapi_import_name(Gssctxt *ctx, const char *host) {
-       gss_buffer_desc gssbuf;
+       gss_buffer_desc gssbuf = {0,NULL};
        OM_uint32 maj_status, min_status;
-       struct hostent *hostinfo = NULL;
        char *xhost;
        
        /* Make a copy of the host name, in case it was returned by a
         * previous call to gethostbyname(). */ 
        xhost = xstrdup(host);
 
-       /* Make sure we have the FQDN. Some GSSAPI implementations don't do
+       /* If xhost is the loopback interface, switch it to our
+          true local hostname. */
+       resolve_localhost(&xhost);
+
+       /* Make sure we have the FQHN. Some GSSAPI implementations don't do
         * this for us themselves */
-       
-       hostinfo = gethostbyname(xhost);
-       
-       if ((hostinfo == NULL) || (hostinfo->h_name == NULL)) {
-               debug("Unable to get FQDN for \"%s\"", xhost);
-       } else {
-               xfree(xhost);
-               xhost = xstrdup(hostinfo->h_name);
-       }
-               
+       make_fqhn(&xhost);
+
         gssbuf.length = sizeof("host@")+strlen(xhost);
 
         gssbuf.value = xmalloc(gssbuf.length);
@@ -556,7 +571,7 @@ ssh_gssapi_server_ctx(Gssctxt **ctx,gss_OID oid) {
 
 OM_uint32 
 ssh_gssapi_client_ctx(Gssctxt **ctx,gss_OID oid, char *host) {
-       gss_buffer_desc token;
+       gss_buffer_desc token = {0,NULL};
        OM_uint32 major,minor;
        
        if (*ctx) ssh_gssapi_delete_ctx(ctx);
index b29df32fa64ef9581631f43abf5b107cbc690a3a..53321ace45dedaddff3b7f1ccad01b2ab804d3ad 100644 (file)
@@ -139,6 +139,9 @@ ssh_gssapi_krb5_localname(char **user)
 {
     krb5_principal princ;
 
+    if (ssh_gssapi_krb5_init() == 0)
+       return 0;
+
     if (krb5_parse_name(krb_context, gssapi_client_name.value, &princ)) {
        return(0);
     }
@@ -161,8 +164,8 @@ ssh_gssapi_krb5_localname(char **user)
  * populated.
  */
 
-void
-ssh_gssapi_krb5_storecreds() {
+OM_uint32
+ssh_gssapi_krb5_storecreds(gss_buffer_t export_buffer) {
        krb5_ccache ccache;
        krb5_error_code problem;
        krb5_principal princ;
@@ -170,34 +173,35 @@ ssh_gssapi_krb5_storecreds() {
        static char name[40];
        int tmpfd;
        OM_uint32 maj_status,min_status;
+       gss_cred_id_t krb5_cred_handle;
 
 
        if (gssapi_client_creds==NULL) {
                debug("No credentials stored"); 
-               return;
+               return GSS_S_NO_CRED;
        }
                
        if (ssh_gssapi_krb5_init() == 0)
-               return;
+               return GSS_S_FAILURE;
 
        if (options.gss_use_session_ccache) {
                snprintf(ccname,sizeof(ccname),"/tmp/krb5cc_%d_XXXXXX",geteuid());
        
                if ((tmpfd = mkstemp(ccname))==-1) {
                        log("mkstemp(): %.100s", strerror(errno));
-                       return;
+                       return GSS_S_FAILURE;
                }
                if (fchmod(tmpfd, S_IRUSR | S_IWUSR) == -1) {
                        log("fchmod(): %.100s", strerror(errno));
                        close(tmpfd);
-                       return;
+                       return GSS_S_FAILURE;
                }
         } else {
                snprintf(ccname,sizeof(ccname),"/tmp/krb5cc_%d",geteuid());
                tmpfd = open(ccname, O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR);
                if (tmpfd == -1) {
                        log("open(): %.100s", strerror(errno));
-                       return;
+                       return GSS_S_FAILURE;
                }
         }
 
@@ -207,7 +211,7 @@ ssh_gssapi_krb5_storecreds() {
         if ((problem = krb5_cc_resolve(krb_context, name, &ccache))) {
                 log("krb5_cc_default(): %.100s", 
                        krb5_get_err_text(krb_context,problem));
-                return;
+                return GSS_S_FAILURE;
         }
 
        if ((problem = krb5_parse_name(krb_context, gssapi_client_name.value, 
@@ -215,7 +219,7 @@ ssh_gssapi_krb5_storecreds() {
                log("krb5_parse_name(): %.100s", 
                        krb5_get_err_text(krb_context,problem));
                krb5_cc_destroy(krb_context,ccache);
-               return;
+               return GSS_S_FAILURE;
        }
        
        if ((problem = krb5_cc_initialize(krb_context, ccache, princ))) {
@@ -223,43 +227,35 @@ ssh_gssapi_krb5_storecreds() {
                        krb5_get_err_text(krb_context,problem));
                krb5_free_principal(krb_context,princ);
                krb5_cc_destroy(krb_context,ccache);
-               return;
+               return GSS_S_FAILURE;
        }
        
        krb5_free_principal(krb_context,princ);
 
-       #ifdef HEIMDAL
-       if ((problem = krb5_cc_copy_cache(krb_context, 
-                                          gssapi_client_creds->ccache,
-                                          ccache))) {
-               log("krb5_cc_copy_cache(): %.100s", 
-                       krb5_get_err_text(krb_context,problem));
-               krb5_cc_destroy(krb_context,ccache);
-               return;
-       }
-       #else
+#ifdef MECHGLUE
+       krb5_cred_handle =
+           __gss_get_mechanism_cred(gssapi_client_creds,
+                                    &(supported_mechs[GSS_KERBEROS].oid));
+#else
+       krb5_cred_handle = gssapi_client_creds;
+#endif
+
        if ((maj_status = gss_krb5_copy_ccache(&min_status, 
-                                              gssapi_client_creds
+                                              krb5_cred_handle
                                               ccache))) {
                log("gss_krb5_copy_ccache() failed");
                ssh_gssapi_error(maj_status,min_status);
                krb5_cc_destroy(krb_context,ccache);
-               return;
+               return GSS_S_FAILURE;
        }
-       #endif
        
        krb5_cc_close(krb_context,ccache);
 
+       export_buffer->length = strlen("KRB5CCNAME")+strlen(name)+1;
+       export_buffer->value = xmalloc(export_buffer->length+1);
+       sprintf(export_buffer->value, "%s=%s", "KRB5CCNAME", name);
 
-#ifdef USE_PAM
-       do_pam_putenv("KRB5CCNAME",name);
-#endif
-
-       gssapi_cred_store.filename=strdup(ccname);
-       gssapi_cred_store.envvar="KRB5CCNAME";
-       gssapi_cred_store.envval=strdup(name);
-
-       return;
+       return GSS_S_COMPLETE;
 }
 
 #endif /* KRB5 */
@@ -303,13 +299,12 @@ ssh_gssapi_gsi_localname(char **user)
  *
  * Make sure that this is called _after_ we've setuid to the user.
  */
-void
-ssh_gssapi_gsi_storecreds()
+OM_uint32
+ssh_gssapi_gsi_storecreds(gss_buffer_t export_buffer)
 {
        OM_uint32       major_status;
        OM_uint32       minor_status;
-       
-       
+
        if (gssapi_client_creds != NULL)
        {
                char *creds_env = NULL;
@@ -349,14 +344,14 @@ ssh_gssapi_gsi_storecreds()
                        {
                                *value = '\0';
                                value++;
-#ifdef USE_PAM
-                               do_pam_putenv("X509_USER_PROXY",value);
-#endif
-                               gssapi_cred_store.filename=NULL;
-                               gssapi_cred_store.envvar="X509_USER_PROXY";
-                               gssapi_cred_store.envval=strdup(value);
-
-                               return;
+                               export_buffer->length=
+                                   strlen("X509_USER_PROXY")+strlen(value)+1;
+                               export_buffer->value =
+                                   xmalloc(export_buffer->length+1);
+                               sprintf(export_buffer->value, "%s=%s",
+                                       "X509_USER_PROXY", value);
+                               
+                               return GSS_S_COMPLETE;
                        }
                        else
                        {
@@ -369,7 +364,8 @@ ssh_gssapi_gsi_storecreds()
                        log("Failed to export delegated credentials (error %ld)",
                            major_status);
                }
-       }       
+       }
+       return 0;
 }
 
 #endif /* GSI */
@@ -377,25 +373,40 @@ ssh_gssapi_gsi_storecreds()
 void
 ssh_gssapi_cleanup_creds(void *ignored)
 {
+       /* OM_uint32 min_stat; */
+
        if (gssapi_cred_store.filename!=NULL) {
                /* Unlink probably isn't sufficient */
-               debug("removing gssapi cred file\"%s\"",gssapi_cred_store.filename);
+               debug("removing gssapi cred file \"%s\"",gssapi_cred_store.filename);
                unlink(gssapi_cred_store.filename);
        }
+       /* DK ?? 
+       if (gssapi_client_creds != GSS_C_NO_CREDENTIAL)
+               gss_release_cred(&min_stat, &gssapi_client_creds);
+       */
 }
 
-void 
-ssh_gssapi_storecreds()
+OM_uint32
+ssh_gssapi_export_cred(OM_uint32 *            minor_status,
+                      const gss_cred_id_t    cred_handle,
+                      const gss_OID          desired_mech,
+                      OM_uint32              option_req,
+                      gss_buffer_t           export_buffer)
 {
+       OM_uint32 maj_stat = GSS_S_FAILURE;
+
+       if (option_req != 1) return GSS_S_UNAVAILABLE;
+       if (desired_mech != NULL) return GSS_S_BAD_MECH;
+
        switch (gssapi_client_type) {
 #ifdef KRB5
        case GSS_KERBEROS:
-               ssh_gssapi_krb5_storecreds();
+               maj_stat = ssh_gssapi_krb5_storecreds(export_buffer);
                break;
 #endif
 #ifdef GSI
        case GSS_GSI:
-               ssh_gssapi_gsi_storecreds();
+               maj_stat = ssh_gssapi_gsi_storecreds(export_buffer);
                break;
 #endif /* GSI */
        case GSS_LAST_ENTRY:
@@ -406,11 +417,65 @@ ssh_gssapi_storecreds()
                log("ssh_gssapi_do_child: Unknown mechanism");
        
        }
-       
+
+       if (GSS_ERROR(maj_stat)) {
+               *minor_status = GSS_S_FAILURE;
+       }
+       return maj_stat;
+}
+
+void 
+ssh_gssapi_storecreds()
+{
+       OM_uint32 maj_stat, min_stat;
+       gss_buffer_desc export_cred = GSS_C_EMPTY_BUFFER;
+       char *p;
+
+       if (gssapi_client_creds == GSS_C_NO_CREDENTIAL)
+               return;
+
+#ifdef HAVE_GSSAPI_EXT
+       maj_stat = gss_export_cred(&min_stat, gssapi_client_creds,
+                                  GSS_C_NO_OID, 1, &export_cred);
+       if (GSS_ERROR(maj_stat) && maj_stat != GSS_S_UNAVAILABLE) {
+               ssh_gssapi_error(maj_stat, min_stat);
+               return;
+       }
+#endif
+
+       /* If gss_export_cred() is not available, use old methods */
+       if (export_cred.length == 0) {
+           ssh_gssapi_export_cred(&min_stat, gssapi_client_creds,
+                                  GSS_C_NO_OID, 1, &export_cred);
+           if (GSS_ERROR(maj_stat)) {
+               ssh_gssapi_error(maj_stat, min_stat);
+           }
+       }
+
+       p = strchr((char *) export_cred.value, '=');
+       if (p == NULL) {
+               log("Failed to parse exported credentials string '%.100s'",
+                   (char *)export_cred.value);
+               gss_release_buffer(&min_stat, &export_cred);
+               return;
+       }
+       *p++ = '\0';
+       gssapi_cred_store.envvar = strdup((char *)export_cred.value);
+       gssapi_cred_store.envval = strdup(p);
+#ifdef USE_PAM
+       do_pam_putenv(gssapi_cred_store.envvar, gssapi_cred_store.envval);
+#endif
+       if (strncmp(p, "FILE:", 5) == 0) {
+           p += 5;
+       }
+       if (access(p, R_OK) == 0) {
+           gssapi_cred_store.filename = strdup(p);
+       }
+       gss_release_buffer(&min_stat, &export_cred);
+
        if (options.gss_cleanup_creds) {
                fatal_add_cleanup(ssh_gssapi_cleanup_creds, NULL);
        }
-
 }
 
 /* This allows GSSAPI methods to do things to the childs environment based
index 0cd9bf3cdf0ce8a1d08c5ef9e262120c6f3fbc17..da96461276202bc7fb2a5cb395d1ddaa1e97f509 100644 (file)
@@ -189,18 +189,20 @@ kexgss_client(Kex *kex)
                                debug("Received GSSAPI_CONTINUE");
                                if (maj_status == GSS_S_COMPLETE) 
                                        fatal("GSSAPI Continue received from server when complete");
-                               recv_tok.value=packet_get_string(&recv_tok.length);
+                               recv_tok.value=packet_get_string(&slen);
+                               recv_tok.length=slen; /* int vs. size_t */
                                break;
                        case SSH2_MSG_KEXGSS_COMPLETE:
                                debug("Received GSSAPI_COMPLETE");
                                packet_get_bignum2(dh_server_pub);
-                               msg_tok.value=
-                                   packet_get_string(&msg_tok.length);
+                               msg_tok.value=packet_get_string(&slen);
+                               msg_tok.length=slen; /* int vs. size_t */
 
                                /* Is there a token included? */
                                if (packet_get_char()) {
                                        recv_tok.value=
-                                           packet_get_string(&recv_tok.length);
+                                           packet_get_string(&slen);
+                                       recv_tok.length=slen; /* int/size_t */
                                        /* If we're already complete - protocol error */
                                        if (maj_status == GSS_S_COMPLETE)
                                                packet_disconnect("Protocol error: received token when complete");
@@ -239,6 +241,7 @@ kexgss_client(Kex *kex)
         memset(kbuf, 0, klen);
         xfree(kbuf);
         
+       slen=0;
         hash = kex_gssapi_hash(
            kex->client_version_string,
             kex->server_version_string,
@@ -302,6 +305,7 @@ kexgss_server(Kex *kex)
         BIGNUM *dh_client_pub = NULL;
        int type =0;
        gss_OID oid;
+       u_int slen;
        
        /* Initialise GSSAPI */
 
@@ -315,7 +319,7 @@ kexgss_server(Kex *kex)
        
        if (GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctxt,oid))))
           packet_disconnect("Unable to acquire credentials for the server");
-                                                                                                                                
+
        do {
                debug("Wait SSH2_MSG_GSSAPI_INIT");
                type = packet_read();
@@ -323,7 +327,8 @@ kexgss_server(Kex *kex)
                case SSH2_MSG_KEXGSS_INIT:
                        if (dh_client_pub!=NULL) 
                                packet_disconnect("Received KEXGSS_INIT after initialising");
-                       recv_tok.value=packet_get_string(&recv_tok.length);
+                       recv_tok.value=packet_get_string(&slen);
+                       recv_tok.length=slen; /* int vs. size_t */
 
                        dh_client_pub = BN_new();
                        
@@ -336,7 +341,8 @@ kexgss_server(Kex *kex)
                case SSH2_MSG_KEXGSS_CONTINUE:
                        if (dh_client_pub == NULL)
                                packet_disconnect("Received KEXGSS_CONTINUE without initialising");
-                       recv_tok.value=packet_get_string(&recv_tok.length);
+                       recv_tok.value=packet_get_string(&slen);
+                       recv_tok.length=slen; /* int vs. size_t */
                        break;
                default:
                        packet_disconnect("Protocol error: didn't expect packet type %d",
index f4180a2376e876000906ac16d845f9df1e9fcce0..582f0ca86026334706a1e264ebee8ca29e64ff05 100644 (file)
@@ -1600,8 +1600,10 @@ int
 mm_answer_gss_setup_ctx(int socket, Buffer *m) {
         gss_OID_desc oid;
         OM_uint32 major;
+       int len;
 
-        oid.elements=buffer_get_string(m,&oid.length);
+        oid.elements=buffer_get_string(m,&len);
+       oid.length=len;
                 
         major=ssh_gssapi_server_ctx(&gsscontext,&oid);
 
index 7275c847dabb00ead9937ad7d101ae76994fdea2..103aed2cde2cc8bb6c0dfc0fd8b05dd4a050a760 100644 (file)
@@ -22,7 +22,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "includes.h"
-RCSID("$OpenBSD: msg.c,v 1.3 2002/06/24 15:49:22 itojun Exp $");
+RCSID("$OpenBSD: msg.c,v 1.2 2002/06/19 00:27:55 deraadt Exp $");
 
 #include "buffer.h"
 #include "getput.h"
@@ -36,7 +36,7 @@ msg_send(int fd, u_char type, Buffer *m)
        u_char buf[5];
        u_int mlen = buffer_len(m);
 
-       debug3("msg_send: type %u", (unsigned int)type & 0xff);
+       debug3("msg_send: type %d", type);
 
        PUT_32BIT(buf, mlen + 1);
        buf[4] = type;          /* 1st byte of payload is mesg-type */
@@ -59,7 +59,7 @@ msg_recv(int fd, Buffer *m)
        if (res != sizeof(buf)) {
                if (res == 0)
                        return -1;
-               fatal("msg_recv: read: header %ld", (long)res);
+               fatal("msg_recv: read: header %d", res);
        }
        msg_len = GET_32BIT(buf);
        if (msg_len > 256 * 1024)
index 2d62ff6556a84940a8781c90d09035f451a9fa50..3e336dd8fb0df7a8242fcc81067130adf7d81020 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "config.h"
 
+#define get_progname bsd_get_progname
 char *get_progname(char *argv0);
 
 #ifndef HAVE_SETSID
index 3b938ead666e69db4f70a9c1b5ed5e7cb975d1ec..b6a30c4a6dcfea603363700119d074bf210bdfea 100644 (file)
@@ -24,7 +24,7 @@
     <Source_Dependencies Type="compile">
       <Dependency Name="globus_openssl">
         <Version>
-          <Version_Range Upper_Major="1000" Lower_Major="0" Upper_Minor="1000" Lower_Minor="8" />
+          <Version_Range Lower_Major="0" Lower_Minor="8" Upper_Major="0" Upper_Minor="40" />
         </Version>
       </Dependency>
       <Dependency Name="globus_gssapi_gsi">
@@ -53,7 +53,7 @@
     <Source_Dependencies Type="pgm_link">
       <Dependency Name="globus_openssl">
         <Version>
-          <Version_Range Upper_Major="1000" Lower_Major="0" Upper_Minor="1000" Lower_Minor="8" />
+          <Version_Range Lower_Major="0" Lower_Minor="8" Upper_Major="0" Upper_Minor="40" />
         </Version>
       </Dependency>
       <Dependency Name="globus_gss_assist">
@@ -67,7 +67,7 @@
     <Source_Setup_Dependency PkgType="pgm">
       <Setup_Dependency Name="trusted_ca_setup">
         <Version>
-          <Version_Range Upper_Major="1000" Lower_Major="2" Upper_Minor="1000" Lower_Minor="0" />
+          <Simple_Version Major="2"></Simple_Version>
         </Version>
       </Setup_Dependency>
       <Setup_Dependency Name="gsi_openssh_setup">
index 930163439390b8487c2b1d1c95709e7e1c79af90..f370adfdac16cc67b68390031016fafcff829b61 100644 (file)
@@ -86,7 +86,8 @@ typedef struct {
        char   *host_key_alias; /* hostname alias for .ssh/known_hosts */
        char   *proxy_command;  /* Proxy command for connecting the host. */
        char   *user;           /* User to log in as. */
-        int    implicit;
+       int    implicit;        /* Login user was not specified.
+                                  Server may choose based on authctxt. */
        int     escape_char;    /* Escape character; -2 = none */
 
        char   *system_hostfile;/* Path for /etc/ssh/ssh_known_hosts. */
index 0170f068794ce8d668850a38ba08678220c8b824..0528f7a5bf7d47dc31160c4c496f0bf7846029a6 100644 (file)
@@ -17,7 +17,6 @@ RCSID("$OpenBSD: servconf.c,v 1.112 2002/06/23 09:46:51 deraadt Exp $");
 #endif
 #if defined(KRB5)
 #ifdef HEIMDAL
-#include <krb.h>
 #else
 /* Bodge - but then, so is using the kerberos IV KEYFILE to get a Kerberos V
  * keytab */
index fdf9567ff9819a54bb05c91470fd09109ee65bbf..37d8721d3a916e58fdb1e5123c34e9300ce0b82a 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <gssapi.h>
 
+#ifndef MECHGLUE
 #ifdef KRB5
 #ifndef HEIMDAL
 #include <gssapi_generic.h>
@@ -43,6 +44,7 @@
 #endif /* GSS_C_NT_... */
 #endif /* !HEIMDAL */
 #endif /* KRB5 */
+#endif /* !MECHGLUE */
 
 /* draft-ietf-secsh-gsskeyex-03 */
 #define SSH2_MSG_KEXGSS_INIT                           30
@@ -135,6 +137,25 @@ void ssh_gssapi_clean_env();
 
 #ifdef GSI
 int gsi_gridmap(char *subject_name, char **mapped_name);
+#ifdef _HAVE_GSI_EXTENDED_GSSAPI
+#define HAVE_GSSAPI_EXT
+#endif
+#endif
+
+#ifdef MECHGLUE
+gss_cred_id_t __gss_get_mechanism_cred
+   (gss_cred_id_t,     /* union_cred */
+    gss_OID            /* mech_type */
+   );
+#ifndef _HAVE_GSI_EXTENDED_GSSAPI
+#define HAVE_GSSAPI_EXT
+OM_uint32 gss_export_cred
+    (OM_uint32 *,        /* minor_status */
+     const gss_cred_id_t,/* cred_handle */
+     const gss_OID,      /* desired mech */
+     OM_uint32,          /* option req */
+     gss_buffer_t);      /* output buffer */
+#endif
 #endif
 #endif /* GSSAPI */
 
index f69a72ca61a66988ca640e02f6509c953af95c94..605658ba367a4a5a85f92107906c7b402bcc0341 100644 (file)
@@ -1044,13 +1044,14 @@ char * get_gss_our_name()
     return NULL;
   }
 
-  maj_stat = gss_export_name(&min_stat,
-                             pname,
-                             tmpnamed);
+  maj_stat = gss_display_name(&min_stat,
+                             pname,
+                             tmpnamed,
+                             NULL);
   if (maj_stat != GSS_S_COMPLETE) {
-    return NULL;
+     return NULL;
   }
-  debug("gss_export_name finsished");
+  debug("gss_display_name finsished");
   retname = (char *)malloc(tmpname.length + 1);
   if (!retname) {
     return NULL;
@@ -1085,18 +1086,20 @@ int try_gssapi_authentication(char *host, Options *options)
   OM_uint32 ret_flags;
   int type;
   char *gssapi_auth_type = NULL;
-  struct hostent *hostinfo;
+  char *xhost;
+  unsigned int slen;
 
+  /* Make a copy of the host name, in case it was returned by a
+   * previous call to gethostbyname(). */      
+  xhost = xstrdup(host);
 
-  /*
-   * host is not guarenteed to be a FQDN, so we need to make sure it is.
-   */
-  hostinfo = gethostbyname(host);
+  /* If xhost is the loopback interface, switch it to our
+     true local hostname. */
+  resolve_localhost(&xhost);
 
-  if ((hostinfo == NULL) || (hostinfo->h_name == NULL)) {
-      debug("GSSAPI authentication: Unable to get FQDN for \"%s\"", host);
-      goto cleanup;
-  }
+  /* Make sure we have the FQHN. Some GSSAPI implementations don't do
+   * this for us themselves */
+  make_fqhn(&xhost);
 
   /*
    * Default flags
@@ -1125,17 +1128,14 @@ int try_gssapi_authentication(char *host, Options *options)
 
   debug("Attempting %s authentication", gssapi_auth_type);
 
-  service_name = (char *) malloc(strlen("host") +
-                                 strlen(hostinfo->h_name) +
-                                 2 /* 1 for '@', 1 for NUL */);
-
-  if (service_name == NULL) {
-    debug("malloc() failed");
-    goto cleanup;
-  }
+  service_name = (char *) xmalloc(strlen("host") +
+                                 strlen(xhost) +
+                                 2 /* 1 for '@', 1 for NUL */);
 
+  sprintf(service_name, "host@%s", xhost);
 
-  sprintf(service_name, "host@%s", hostinfo->h_name);
+  xfree(xhost);
+  xhost = NULL;
 
   name_type = GSS_C_NT_HOSTBASED_SERVICE;
 
@@ -1165,7 +1165,7 @@ int try_gssapi_authentication(char *host, Options *options)
 
 #endif /* GSSAPI */
 
-  debug("req_flags = %lu", req_flags);
+  debug("req_flags = %u", (unsigned int)req_flags);
 
   name_tok.value = service_name;
   name_tok.length = strlen(service_name) + 1;
@@ -1224,7 +1224,8 @@ int try_gssapi_authentication(char *host, Options *options)
   }
 
   /* Read the mechanism the server returned */
-  mech_oid.elements = packet_get_string((unsigned int *) &(mech_oid.length));
+  mech_oid.elements = packet_get_string(&slen);
+  mech_oid.length = slen;      /* safe typecast */
   packet_get_all();
 
   /*
@@ -1310,7 +1311,8 @@ int try_gssapi_authentication(char *host, Options *options)
         /* Does not return */
       }
 
-      recv_tok.value = packet_get_string((unsigned int *) &recv_tok.length);
+      recv_tok.value = packet_get_string(&slen);
+      recv_tok.length=slen;    /* safe typecast */
       packet_get_all();
       token_ptr = &recv_tok;
     }
@@ -1341,7 +1343,8 @@ int try_gssapi_authentication(char *host, Options *options)
     gss_qop_t qop_state;
 
 
-    wrapped_buf.value = packet_get_string(&(wrapped_buf.length));
+    wrapped_buf.value = packet_get_string(&slen);
+    wrapped_buf.length=slen;   /* safe typecast */
     packet_get_all();
 
     maj_stat = gss_unwrap(&min_stat,
@@ -1361,7 +1364,8 @@ int try_gssapi_authentication(char *host, Options *options)
     if (unwrapped_buf.length != sizeof(ssh_key_digest)) {
       packet_disconnect("Verification of SSHD keys through GSSAPI-secured channel failed: "
                         "Size of key hashes do not match (%d != %d)!",
-                        unwrapped_buf.length, sizeof(ssh_key_digest));
+                        (int)unwrapped_buf.length,
+                       (int)sizeof(ssh_key_digest));
     }
 
     if (memcmp(ssh_key_digest, unwrapped_buf.value, sizeof(ssh_key_digest)) != 0) {
index fc30f4d479706f0603a8403d4447d9757997e793..38cef29cfc391a5ea7caf648f31301bd5d80a86d 100644 (file)
@@ -519,11 +519,15 @@ userauth_gssapi(Authctxt *authctxt)
        authctxt->methoddata=(void *)gssctxt;
                
        packet_start(SSH2_MSG_USERAUTH_REQUEST);
+#ifdef GSI
         if(options.implicit && !(datafellows & SSH_BUG_GSS_EMPTYUSER)) {
            packet_put_cstring("");
        } else {
+#endif
            packet_put_cstring(authctxt->server_user);
+#ifdef GSI
        }
+#endif
        packet_put_cstring(authctxt->service);
         packet_put_cstring(authctxt->method->name);
 
@@ -591,12 +595,14 @@ input_gssapi_token(int type, u_int32_t plen, void *ctxt)
        Gssctxt *gssctxt;
        gss_buffer_desc send_tok,recv_tok;
        OM_uint32 status;
+       u_int slen;
        
        if (authctxt == NULL)
                fatal("input_gssapi_response: no authentication context");
        gssctxt = authctxt->methoddata;
        
-       recv_tok.value=packet_get_string(&recv_tok.length);
+       recv_tok.value=packet_get_string(&slen);
+       recv_tok.length=slen;   /* safe typecast */
 
        status=ssh_gssapi_init_ctx(gssctxt, options.gss_deleg_creds,
                                   &recv_tok, &send_tok, NULL);
@@ -634,11 +640,15 @@ userauth_external(Authctxt *authctxt)
                                 
         debug2("userauth_external");
         packet_start(SSH2_MSG_USERAUTH_REQUEST);
+#ifdef GSI
         if(options.implicit && !(datafellows & SSH_BUG_GSS_EMPTYUSER)) {
            packet_put_cstring("");
        } else {
+#endif
            packet_put_cstring(authctxt->server_user);
+#ifdef GSI
        }
+#endif
         packet_put_cstring(authctxt->service);
         packet_put_cstring(authctxt->method->name);
         packet_send();
index 28add0d6d1d2fc6589ccd4beb2e1274576d07dfd..9c7c5837ae7d7a85449743dde5e8a761d5e537d3 100644 (file)
@@ -249,6 +249,11 @@ Specifies whether a unique credentials cache name should be generated per
 session for storing delegated credentials.
 The default is
 .Dq yes .
+.It Cm GssapiCleanupCreds
+Specifies whether the credentials cache should be removed at the end
+of the session.
+The default is
+.Dq yes .
 .It Cm HostKey
 Specifies a file containing a private host key
 used by SSH.
This page took 0.156387 seconds and 5 git commands to generate.