summaryrefslogtreecommitdiff
path: root/gss-serv.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2007-06-12 23:40:39 +1000
committerDarren Tucker <dtucker@zip.com.au>2007-06-12 23:40:39 +1000
commit8f6d0ed60eb0d790564a5f47ba63c9bc3c734058 (patch)
treecbdc91acff173fdb6a2f6310d60b720a2ce815c2 /gss-serv.c
parent29a5707accd89cefb6c0a03ada09511c0cd6985a (diff)
- djm@cvs.openbsd.org 2007/06/12 08:20:00
[ssh-gss.h gss-serv.c gss-genr.c] relocate server-only GSSAPI code from libssh to server; bz #1225 patch from simon AT sxw.org.uk; ok markus@ dtucker@
Diffstat (limited to 'gss-serv.c')
-rw-r--r--gss-serv.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/gss-serv.c b/gss-serv.c
index e8191a859..bc498fd47 100644
--- a/gss-serv.c
+++ b/gss-serv.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: gss-serv.c,v 1.20 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: gss-serv.c,v 1.21 2007/06/12 08:20:00 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. 4 * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
@@ -29,6 +29,7 @@
29#ifdef GSSAPI 29#ifdef GSSAPI
30 30
31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/param.h>
32 33
33#include <stdarg.h> 34#include <stdarg.h>
34#include <string.h> 35#include <string.h>
@@ -64,6 +65,53 @@ ssh_gssapi_mech* supported_mechs[]= {
64 &gssapi_null_mech, 65 &gssapi_null_mech,
65}; 66};
66 67
68
69/*
70 * Acquire credentials for a server running on the current host.
71 * Requires that the context structure contains a valid OID
72 */
73
74/* Returns a GSSAPI error code */
75/* Privileged (called from ssh_gssapi_server_ctx) */
76static OM_uint32
77ssh_gssapi_acquire_cred(Gssctxt *ctx)
78{
79 OM_uint32 status;
80 char lname[MAXHOSTNAMELEN];
81 gss_OID_set oidset;
82
83 gss_create_empty_oid_set(&status, &oidset);
84 gss_add_oid_set_member(&status, ctx->oid, &oidset);
85
86 if (gethostname(lname, MAXHOSTNAMELEN)) {
87 gss_release_oid_set(&status, &oidset);
88 return (-1);
89 }
90
91 if (GSS_ERROR(ssh_gssapi_import_name(ctx, lname))) {
92 gss_release_oid_set(&status, &oidset);
93 return (ctx->major);
94 }
95
96 if ((ctx->major = gss_acquire_cred(&ctx->minor,
97 ctx->name, 0, oidset, GSS_C_ACCEPT, &ctx->creds, NULL, NULL)))
98 ssh_gssapi_error(ctx);
99
100 gss_release_oid_set(&status, &oidset);
101 return (ctx->major);
102}
103
104/* Privileged */
105OM_uint32
106ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid)
107{
108 if (*ctx)
109 ssh_gssapi_delete_ctx(ctx);
110 ssh_gssapi_build_ctx(ctx);
111 ssh_gssapi_set_oid(*ctx, oid);
112 return (ssh_gssapi_acquire_cred(*ctx));
113}
114
67/* Unprivileged */ 115/* Unprivileged */
68void 116void
69ssh_gssapi_supported_oids(gss_OID_set *oidset) 117ssh_gssapi_supported_oids(gss_OID_set *oidset)