]> andersk Git - gssapi-openssh.git/blobdiff - openssh/gss-serv-krb5.c
Import of OpenSSH 3.8p1
[gssapi-openssh.git] / openssh / gss-serv-krb5.c
index f48e0991150b401d7a37e4fa4447380933a2ab2c..8ba3e7182a734d7ccb4bf375523505862655de1b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: gss-serv-krb5.c,v 1.1 2003/08/22 10:56:09 markus Exp $        */
+/*     $OpenBSD: gss-serv-krb5.c,v 1.2 2003/11/21 11:57:03 djm Exp $   */
 
 /*
  * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
 extern ServerOptions options;
 
 #ifdef HEIMDAL
-#include <krb5.h>
+# include <krb5.h>
 #else
-#include <gssapi_krb5.h>
+# ifdef HAVE_GSSAPI_KRB5
+#  include <gssapi_krb5.h>
+# elif HAVE_GSSAPI_GSSAPI_KRB5
+#  include <gssapi/gssapi_krb5.h>
+# endif
 #endif
 
 static krb5_context krb_context = NULL;
 
 /* Initialise the krb5 library, for the stuff that GSSAPI won't do */
 
-static int 
+static int
 ssh_gssapi_krb5_init()
 {
        krb5_error_code problem;
@@ -108,6 +112,7 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client)
        krb5_error_code problem;
        krb5_principal princ;
        OM_uint32 maj_status, min_status;
+       int len;
 
        if (client->creds == NULL) {
                debug("No credentials stored");
@@ -127,10 +132,10 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client)
        {
                int tmpfd;
                char ccname[40];
-    
-               snprintf(ccname, sizeof(ccname), 
+
+               snprintf(ccname, sizeof(ccname),
                    "FILE:/tmp/krb5cc_%d_XXXXXX", geteuid());
-    
+
                if ((tmpfd = mkstemp(ccname + strlen("FILE:"))) == -1) {
                        logit("mkstemp(): %.100s", strerror(errno));
                        problem = errno;
@@ -151,7 +156,7 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client)
        }
 #endif /* #ifdef HEIMDAL */
 
-       if ((problem = krb5_parse_name(krb_context, 
+       if ((problem = krb5_parse_name(krb_context,
            client->exportedname.value, &princ))) {
                logit("krb5_parse_name(): %.100s",
                    krb5_get_err_text(krb_context, problem));
@@ -169,7 +174,7 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client)
 
        krb5_free_principal(krb_context, princ);
 
-       if ((maj_status = gss_krb5_copy_ccache(&min_status, 
+       if ((maj_status = gss_krb5_copy_ccache(&min_status,
            client->creds, ccache))) {
                logit("gss_krb5_copy_ccache() failed");
                krb5_cc_destroy(krb_context, ccache);
@@ -178,11 +183,13 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client)
 
        client->store.filename = xstrdup(krb5_cc_get_name(krb_context, ccache));
        client->store.envvar = "KRB5CCNAME";
-       client->store.envval = xstrdup(client->store.filename);
+       len = strlen(client->store.filename) + 6;
+       client->store.envval = xmalloc(len);
+       snprintf(client->store.envval, len, "FILE:%s", client->store.filename);
 
 #ifdef USE_PAM
        if (options.use_pam)
-               do_pam_putenv(client->store.envvar,client->store.envval);
+               do_pam_putenv(client->store.envvar, client->store.envval);
 #endif
 
        krb5_cc_close(krb_context, ccache);
This page took 0.050477 seconds and 4 git commands to generate.