summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/auth-krb5.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2005-09-03 06:59:33 +0000
committerdes <des@FreeBSD.org>2005-09-03 06:59:33 +0000
commit755a16fa864cacbbd9fbefc822011b6741351d8d (patch)
treeb8088b859d6543143de670740f5c6f7bf4e0b23d /crypto/openssh/auth-krb5.c
parentc4dfc1ed3bdacd05d73791b2c8f8b580511a939f (diff)
downloadFreeBSD-src-755a16fa864cacbbd9fbefc822011b6741351d8d.zip
FreeBSD-src-755a16fa864cacbbd9fbefc822011b6741351d8d.tar.gz
Vendor import of OpenSSH 4.2p1.
Diffstat (limited to 'crypto/openssh/auth-krb5.c')
-rw-r--r--crypto/openssh/auth-krb5.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/crypto/openssh/auth-krb5.c b/crypto/openssh/auth-krb5.c
index 1c5b8e6..ac1333c 100644
--- a/crypto/openssh/auth-krb5.c
+++ b/crypto/openssh/auth-krb5.c
@@ -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 */
OpenPOWER on IntegriCloud