]> andersk Git - gssapi-openssh.git/blobdiff - openssh/auth-krb5.c
merged OpenSSH 4.2p1 to trunk
[gssapi-openssh.git] / openssh / auth-krb5.c
index 2f742534aa9af249352a1942d501f785d1859417..c7367b49a2772e4d8aacb14de39165cbdda22af8 100644 (file)
@@ -54,9 +54,6 @@ krb5_init(void *context)
                problem = krb5_init_context(&authctxt->krb5_ctx);
                if (problem)
                        return (problem);
-#ifdef KRB5_INIT_ETS
-               krb5_init_ets(authctxt->krb5_ctx);
-#endif
        }
        return (0);
 }
@@ -67,9 +64,6 @@ auth_krb5_password(Authctxt *authctxt, const char *password)
 #ifndef HEIMDAL
        krb5_creds creds;
        krb5_principal server;
-       char ccname[40];
-       int tmpfd;
-       mode_t old_umask;
 #endif
        krb5_error_code problem;
        krb5_ccache ccache = NULL;
@@ -146,26 +140,7 @@ auth_krb5_password(Authctxt *authctxt, const char *password)
                goto out;
        }
 
-       snprintf(ccname,sizeof(ccname),"FILE:/tmp/krb5cc_%d_XXXXXX",geteuid());
-
-       old_umask = umask(0177);
-       tmpfd = mkstemp(ccname + strlen("FILE:"));
-       umask(old_umask);
-       if (tmpfd == -1) {
-               logit("mkstemp(): %.100s", strerror(errno));
-               problem = errno;
-               goto out;
-       }
-
-       if (fchmod(tmpfd,S_IRUSR | S_IWUSR) == -1) {
-               logit("fchmod(): %.100s", strerror(errno));
-               close(tmpfd);
-               problem = errno;
-               goto out;
-       }
-       close(tmpfd);
-
-       problem = krb5_cc_resolve(authctxt->krb5_ctx, ccname, &authctxt->krb5_fwd_ccache);
+       problem = ssh_krb5_cc_gen(authctxt->krb5_ctx, &authctxt->krb5_fwd_ccache);
        if (problem)
                goto out;
 
@@ -234,4 +209,34 @@ krb5_cleanup_proc(Authctxt *authctxt)
        }
 }
 
+#ifndef HEIMDAL
+krb5_error_code
+ssh_krb5_cc_gen(krb5_context ctx, krb5_ccache *ccache) {
+       int tmpfd, ret;
+       char ccname[40];
+       mode_t old_umask;
+
+       ret = snprintf(ccname, sizeof(ccname),
+           "FILE:/tmp/krb5cc_%d_XXXXXXXXXX", geteuid());
+       if (ret == -1 || ret >= sizeof(ccname))
+               return ENOMEM;
+
+       old_umask = umask(0177);
+       tmpfd = mkstemp(ccname + strlen("FILE:"));
+       umask(old_umask);
+       if (tmpfd == -1) {
+               logit("mkstemp(): %.100s", strerror(errno));
+               return errno;
+       }
+
+       if (fchmod(tmpfd,S_IRUSR | S_IWUSR) == -1) {
+               logit("fchmod(): %.100s", strerror(errno));
+               close(tmpfd);
+               return errno;
+       }
+       close(tmpfd);
+
+       return (krb5_cc_resolve(ctx, ccname, ccache));
+}
+#endif /* !HEIMDAL */
 #endif /* KRB5 */
This page took 0.035551 seconds and 4 git commands to generate.